# How to Fetch CS2 Prices in Go

> A Go integration can fetch all current CS2 prices from `GET /v1/prices/latest`, decode the gzip-compressed JSON response, and select exact items locally from the `items` map.

Keep the API key on the server. Every `/v1` request needs `Authorization: Bearer <key>` and `Accept-Encoding: gzip`; responses use JSON and normalize prices to USD.

## Request and response model

The current endpoint returns `response_time`, `currency`, and every tracked item across BUFF, Youpin, CSFloat, Skinport, Steam, and C5Game. Items are keyed by exact `market_hash_name`, and supported phase or tier records appear under `variants`.

Model numeric quote fields as nullable. A source object can exist while `ask`, `bid`, or a volume field is null, and source capabilities differ. Skinport has no bid, while CSFloat and C5Game have no bid volume.

When a Go transport is configured manually, confirm where gzip decoding occurs. A client that explicitly sends `Accept-Encoding: gzip` may need to wrap the response body in a gzip reader before JSON decoding; it should never decompress an already decoded body twice.

## Integration flow

Create a request with a context deadline, check the HTTP status before decoding the success shape, and validate `currency` and `items`. Resolve selected names from the full map and measure source age from each `collected_at` relative to `response_time`.

Preserve the full source object even if the application selects one lowest cash ask. That keeps evidence for later changes to freshness, source, or price-side policy. Nested variants should be indexed by their full `name`, not silently replaced by their parent item.

Historical POST requests accept up to 100 items and can return successful `items` beside `errors[]`. A Go model for history should retain those item-level errors independently from request-wide HTTP failures.

## Applicable endpoints

| Endpoint | Returns | Plans |
| --- | --- | --- |
| `GET /v1/prices/latest` | Current all-item, all-source snapshot | All plans |
| `POST /v1/prices/history` | OHLC for up to 100 exact item names | Scale, Enterprise |

## Go integration notes

- All plans allow unlimited requests at 10 requests per second per user. Reuse one current snapshot for many local lookups instead of downloading it per item.
- A missing or null quote is not zero. Pointer fields or another explicit nullable representation preserve that distinction.
- `updated_at` is the marketplace's update time; `collected_at` is when cs2.sh fetched the row and is the freshness field for consumers.
- The [current-price API reference](/docs/api-reference/prices-latest) contains maintained Go request examples; this page focuses on the data contract.
