API & Developers

Polymarket CLOB API Pagination: Retrieve Historical Snapshots

Use limit and offset to page through Polymarket markets and historical order book snapshots with the PolyHistorical API.

When a Polymarket market list or snapshot history spans more than one response, use the PolyHistorical API's limit and offset query parameters to fetch successive pages. The API returns the requested limit and the current offset alongside each result set.

Page Through Markets

The markets endpoint accepts a limit from 1 to 100. Set filters such as coin, market type, and resolution status on every request, then increase the offset by the number of markets returned.

GET /v1/markets?coin=BTC&market_type=5m&resolved=true&limit=100&offset=0

Page Through Snapshot History

The snapshots endpoint accepts up to 1,000 records per request. Add include_orderbook=true when the analysis needs bid and ask depth; leave it false when price fields alone are sufficient.

GET /v1/markets/{slug}/snapshots?limit=1000&offset=0&include_orderbook=true

Python Example

This loop follows the response's reported total and advances by the actual number of rows received, avoiding assumptions that every page is full.

import requests

base = "https://api.polyhistorical.com/v1"
headers = {"X-API-Key": "YOUR_API_KEY"}
params = {"coin": "BTC", "market_type": "5m", "resolved": True, "limit": 100, "offset": 0}
markets = []

while True:
    response = requests.get(f"{base}/markets", headers=headers, params=params)
    response.raise_for_status()
    data = response.json()
    batch = data["markets"]
    markets.extend(batch)
    params["offset"] += len(batch)
    if not batch or params["offset"] >= data["total"]:
        break

Reliable Pagination Checklist

  • Keep your filters unchanged across pages so offsets refer to one consistent result set.
  • Use the response's total and the actual batch length to detect completion.
  • For snapshots, keep the market slug and requested time window fixed while advancing the offset.
  • Handle authentication failures and rate-limit responses before retrying a page.

Related Resources

Core Polymarket Data Resources