> ## Documentation Index
> Fetch the complete documentation index at: https://docs.oddpool.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Historical top of book

> Lightweight timeseries of best bid, best ask, mid, and spread per token.

Lightweight timeseries of best bid, best ask, mid, and spread per token. Same data as the orderbook endpoint but without the full level arrays.

<Info>
  Polymarket markets have two tokens (YES and NO) per condition. Use `asset_id` to filter to a specific token.
</Info>

## Parameters

<ParamField query="market_id" type="string" required>
  Polymarket condition ID (`0x...`).
</ParamField>

<ParamField query="asset_id" type="string">
  Filter by specific token ID. Omit to get both YES and NO tokens.
</ParamField>

<ParamField query="start_time" type="integer">
  Start time in Unix ms. Omit with `end_time` to get latest data.
</ParamField>

<ParamField query="end_time" type="integer">
  End time in Unix ms. Omit with `start_time` to get latest data.
</ParamField>

<ParamField query="granularity" type="string" default="1m">
  Snapshot interval: `1m` or `5m`.
</ParamField>

<ParamField query="limit" type="integer" default="100">
  Max rows per page (1-200).
</ParamField>

<ParamField query="pagination_key" type="string">
  Cursor from previous response for next page.
</ParamField>

## Example

```bash theme={null}
curl -H "X-API-Key: oddpool_..." \
  "https://api.oddpool.com/historical/polymarket/top-of-book?market_id=0x36e8ca24...&asset_id=56914066...&start_time=1774015200000&end_time=1774018800000&granularity=5m"
```

## Response

```json theme={null}
{
  "snapshots": [
    {
      "asset_id": "56914066788195652124...",
      "market_id": "0x00000977017fa72fb6b1...",
      "timestamp": 1774026026396,
      "best_bid": 0.987,
      "best_ask": 0.99,
      "mid": 0.9885,
      "spread": 0.003
    }
  ],
  "pagination": { ... }
}
```

<Note>
  `best_bid` and `best_ask` are `null` when the book had no resting orders at sample time. Filter client-side if you only want quoted snapshots.
</Note>
