# GameStats

Resource class for interacting with the GunSpec Game Stats Snapshots API. Wraps all `/v1/game-stats` endpoints. Instantiated internally by the GunSpec client and exposed as `client.gameStats`.

Source: https://docs.gunspec.io/en/sdk/game-stats

## client.gameStats.listVersions()

`GET /v1/game-stats/versions`

Auth: API key required  
Tier: Builder+

List all available game stats snapshot versions.

### Response 200 (application/json)

| Field | Type | Description |
| --- | --- | --- |
| `data` | GameStatsVersion[] | The response payload. |
| `data[].id` | integer | Autoincrementing version id. |
| `data[].version` | string | Version label, e.g. `2025.1`. |
| `data[].description` | string \| null | Prose summary of the record, where one has been written. |
| `data[].firearmCount` | integer | How many firearms carried game statistics in this version. |
| `data[].createdAt` | string | When the record was first added, `YYYY-MM-DD HH:MM:SS` in UTC. |

```json
{
  "success": true,
  "data": [
    {
      "id": 1,
      "version": "2025.1",
      "description": "Initial game stats snapshot",
      "firearmCount": 450,
      "createdAt": "2025-06-01 12:00:00"
    }
  ]
}
```

### Errors

| Status | Code | Message |
| --- | --- | --- |
| 400 | `VALIDATION_ERROR` | Validation error |
| 401 | `UNAUTHORIZED` | API key required |
| 403 | `FORBIDDEN` | Valid key, not permitted |
| 429 | `RATE_LIMITED` | Rate limit exceeded |
| 500 | `INTERNAL_ERROR` | Unexpected server error |

### Example

```bash
curl --request GET \
  --url 'https://api.gunspec.io/v1/game-stats/versions' \
  --header 'X-API-Key: your_key'
```

## client.gameStats.listFirearms()

`GET /v1/game-stats/versions/{version}/firearms`

Auth: API key required  
Tier: Builder+

List all firearms in a specific game stats snapshot version.

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `version` | string | yes | Snapshot version |

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `page` | integer | no | Page number, from 1 to 10,000 |
| `per_page` | integer | no | Items per page (max 100) |

### Response 200 (application/json)

| Field | Type | Description |
| --- | --- | --- |
| `data` | GameStatsSnapshotEntry[] | One page of results |
| `data[].firearm_id` | string | Slug of the firearm this row is about. |
| `data[].firearm_name` | string | Display name at the time the snapshot was taken. |
| `data[].game_damage` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data[].game_accuracy` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data[].game_range` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data[].game_fire_rate` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data[].game_mobility` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data[].game_recoil_control` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data[].game_reload_speed` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data[].game_concealment` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `pagination.page` | number | Current page number |
| `pagination.per_page` | number | Items per page |
| `pagination.total` | number | Total matching records (Builder and above) |

```json
{
  "success": true,
  "data": [
    {
      "firearm_id": "glock-g17-gen5",
      "firearm_name": "Glock 17 Gen5",
      "game_damage": 42,
      "game_accuracy": 68,
      "game_range": 35,
      "game_fire_rate": 55,
      "game_mobility": 78,
      "game_recoil_control": 62,
      "game_reload_speed": 72,
      "game_concealment": 70
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 20,
    "per_page": 20,
    "total": 42,
    "totalPages": 3
  }
}
```

### Errors

| Status | Code | Message |
| --- | --- | --- |
| 400 | `VALIDATION_ERROR` | Validation error |
| 401 | `UNAUTHORIZED` | API key required |
| 403 | `FORBIDDEN` | Valid key, not permitted |
| 404 | `NOT_FOUND` | Resource not found |
| 429 | `RATE_LIMITED` | Rate limit exceeded |
| 500 | `INTERNAL_ERROR` | Unexpected server error |

### Example

```bash
curl --request GET \
  --url 'https://api.gunspec.io/v1/game-stats/versions/2025.1/firearms' \
  --header 'X-API-Key: your_key'
```

## client.gameStats.getFirearm()

`GET /v1/game-stats/versions/{version}/firearms/{id}`

Auth: API key required  
Tier: Builder+

Get a single firearm's game stats from a specific snapshot version.

### Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `version` | string | yes | Snapshot version |
| `id` | string | yes | Firearm slug |

### Response 200 (application/json)

| Field | Type | Description |
| --- | --- | --- |
| `data` | GameStatsSnapshotEntry | The response payload |
| `data.firearm_id` | string | Slug of the firearm this row is about. |
| `data.firearm_name` | string | Display name at the time the snapshot was taken. |
| `data.game_damage` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data.game_accuracy` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data.game_range` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data.game_fire_rate` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data.game_mobility` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data.game_recoil_control` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data.game_reload_speed` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |
| `data.game_concealment` | integer \| null | Editorial game statistic as it stood in this snapshot, 0-100. |

```json
{
  "success": true,
  "data": {
    "firearm_id": "glock-g17-gen5",
    "firearm_name": "Glock 17 Gen5",
    "game_damage": 42,
    "game_accuracy": 68,
    "game_range": 35,
    "game_fire_rate": 55,
    "game_mobility": 78,
    "game_recoil_control": 62,
    "game_reload_speed": 72,
    "game_concealment": 70
  }
}
```

### Errors

| Status | Code | Message |
| --- | --- | --- |
| 400 | `VALIDATION_ERROR` | Validation error |
| 401 | `UNAUTHORIZED` | API key required |
| 403 | `FORBIDDEN` | Valid key, not permitted |
| 404 | `NOT_FOUND` | Resource not found |
| 429 | `RATE_LIMITED` | Rate limit exceeded |
| 500 | `INTERNAL_ERROR` | Unexpected server error |

### Example

```bash
curl --request GET \
  --url 'https://api.gunspec.io/v1/game-stats/versions/2025.1/firearms/glock-g17-gen5' \
  --header 'X-API-Key: your_key'
```
