# GET /health

Service health status.

Returns current health for marketplace sources, variant collectors, public endpoint datasets, the item schema, and aggregate database counts. No authentication is required.

Once health data is ready, the endpoint returns HTTP `200` even when the JSON `status` is `degraded` or `down`. HTTP `503` means the health snapshot itself is not ready.

## Request

`GET https://api.cs2.sh/health`

**curl**

```bash
curl https://api.cs2.sh/health \
  -H "Accept-Encoding: gzip" --compressed
```

**Python**

```python
import requests

headers = {
    "Accept-Encoding": "gzip",
}

response = requests.get(
    "https://api.cs2.sh/health",
    headers=headers,
)

response.raise_for_status()
data = response.json()
```

**Node**

```javascript
const headers = {
  "Accept-Encoding": "gzip",
};

const response = await fetch("https://api.cs2.sh/health", { headers });

if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
```

**Go**

```go
package main

import (
    "compress/gzip"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    req, _ := http.NewRequest("GET", "https://api.cs2.sh/health", nil)
    req.Header.Set("Accept-Encoding", "gzip")

    resp, err := http.DefaultClient.Do(req)
    if err != nil { panic(err) }
    defer resp.Body.Close()

    if resp.StatusCode < 200 || resp.StatusCode >= 300 {
        body, _ := io.ReadAll(resp.Body)
        panic(fmt.Sprintf("HTTP %d: %s", resp.StatusCode, body))
    }

    var reader io.Reader = resp.Body
    if resp.Header.Get("Content-Encoding") == "gzip" {
        gz, err := gzip.NewReader(resp.Body)
        if err != nil { panic(err) }
        defer gz.Close()
        reader = gz
    }

    var data any
    if err := json.NewDecoder(reader).Decode(&data); err != nil { panic(err) }
    fmt.Printf("%#v\n", data)
}
```

**R**

```r
library(httr2)

resp <- request("https://api.cs2.sh/health") |>
  req_headers(
    `Accept-Encoding` = "gzip"
  ) |>
  req_perform()

data <- resp_body_json(resp)
```

## Response

```json
{
  "status": "up",
  "last_refreshed_at": "string",
  "schema_ready": false,
  "sources": null,
  "variants": null,
  "endpoints": null,
  "stats": {
    "total_events": 0,
    "market_hash_names": 0,
    "variant_items": 0
  }
}
```

## Response fields

[HealthResponse](/docs/objects#healthresponse) fields:

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | `string` | Yes | Allowed: `up`, `degraded`, `down`. Overall API data health. |
| `last_refreshed_at` | `string (date-time)` | Yes | When this health snapshot was generated. |
| `schema_ready` | `boolean` | Yes | Whether the item schema is available. |
| `sources` | [`Record<string, HealthEntry>`](/docs/objects#healthentry) | Yes | Marketplace health keyed by source. |
| `variants` | [`Record<string, HealthEntry>`](/docs/objects#healthentry) | Yes | Variant-price health keyed by source collector. |
| `endpoints` | [`Record<string, HealthEntry>`](/docs/objects#healthentry) | Yes | Dataset health keyed by endpoint name. |
| `stats` | [HealthStats](/docs/objects#healthstats) | Yes | Aggregate database counts at the last health refresh. |

## Health entries

Entries under `sources`, `variants`, and `endpoints` contain `updated_at`, `collected_at`, and `status`. Status is `up`, `degraded`, or `down` based on that dataset's expected refresh rate.

`schema_ready` tells you whether [GET /v1/schema](/docs/schema) is available. `stats` contains `total_events`, `market_hash_names`, and `variant_items`.

Full schemas: [HealthEntry](/docs/objects#healthentry) and [HealthStats](/docs/objects#healthstats).

### HealthEntry

Freshness and status for one source, variant collector, or endpoint dataset.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `updated_at` | `string (date-time)` | Yes | Most recent source-data timestamp represented by this entry. |
| `collected_at` | `string (date-time)` | Yes | When cs2.sh most recently collected or produced this dataset. |
| `status` | `string` | Yes | Allowed: `up`, `degraded`, `down`. Health derived from the dataset's expected refresh rate. |

### HealthStats

Aggregate database counts at the last health refresh.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `total_events` | `integer` | Yes | Total stored market-data events. |
| `market_hash_names` | `integer` | Yes | Unique item names represented in current market data. |
| `variant_items` | `integer` | Yes | Unique variant item names represented in current market data. |
