# DataQuality

Resource class for interacting with the GunSpec Data Quality API. Wraps all `/v1/data` endpoints. Instantiated internally by the GunSpec client and exposed as `client.dataQuality`.

Source: https://docs.gunspec.io/en/sdk/data-quality

## client.dataQuality.coverage()

`GET /v1/data/coverage`

Auth: API key required  
Tier: Enterprise

Get overall data coverage statistics for the database. Returns per-field and aggregate coverage metrics showing what percentage of records have data for each field.

### Response 200 (application/json)

| Field | Type | Description |
| --- | --- | --- |
| `data` | object | The response payload. |
| `data.firearms` | object | Per-field completeness across the firearms table. |
| `data.firearms.total` | integer | Total records matching the query across every page. |
| `data.firearms.fields` | object | Per-field completeness, keyed by column name. |
| `data.calibers` | object | Per-field completeness across the calibers table. |
| `data.calibers.total` | integer | Total records matching the query across every page. |
| `data.calibers.fields` | object | Per-field completeness, keyed by column name. |
| `data.manufacturers` | object | Per-field completeness across the manufacturers table. |
| `data.manufacturers.total` | integer | Total records matching the query across every page. |
| `data.manufacturers.fields` | object | Per-field completeness, keyed by column name. |

```json
{
  "success": true,
  "data": {
    "firearms": {
      "total": 8630,
      "fields": {
        "year_introduced": {
          "filled": 8140,
          "percentage": 88.8
        }
      }
    },
    "calibers": {
      "total": 8630,
      "fields": {
        "year_introduced": {
          "filled": 8140,
          "percentage": 88.8
        }
      }
    },
    "manufacturers": {
      "total": 8630,
      "fields": {
        "year_introduced": {
          "filled": 8140,
          "percentage": 88.8
        }
      }
    }
  }
}
```

### 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/data/coverage' \
  --header 'X-API-Key: your_key'
```

## client.dataQuality.confidence()

`GET /v1/data/confidence`

Auth: API key required  
Tier: Enterprise

Get firearms with confidence scores below a specified threshold. Useful for identifying records that may need additional data verification or enrichment.

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `below` | number | no | Only return records scoring below this threshold |
| `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` | object[] | One page of results |
| `data[].id` | string | Slug of the firearm. |
| `data[].name` | string | Display name, as the maker writes it. |
| `data[].data_confidence` | number | How completely the record is specified and how well it is sourced, 0 to 1. A record-level completeness and provenance measure, **not** a per-field probability of correctness. `dataConfidence` on the camelCase endpoints. |
| `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": [
    {
      "id": "glock-g17-gen5",
      "name": "Glock 17 Gen5",
      "data_confidence": 0.42
    }
  ],
  "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 |
| 429 | `RATE_LIMITED` | Rate limit exceeded |
| 500 | `INTERNAL_ERROR` | Unexpected server error |

### Example

```bash
curl --request GET \
  --url 'https://api.gunspec.io/v1/data/confidence?below=0.5' \
  --header 'X-API-Key: your_key'
```
