API & Developers

Binance Polymarket API Pagination Guide

Learn how to paginate through Polymarket historical snapshots and Binance depth results with limit and offset parameters.

Use pagination when a historical market or order book query returns more records than one response can contain. PolyHistorical endpoints use limit and offset; the response reports the returned limit, current offset, and total result count.

Why PolyHistorical Fits This Workflow

Market-list requests accept up to 100 results, while market snapshot requests accept up to 1,000. Binance snapshot endpoints also expose limit and offset pagination. Keep the query filters fixed while paging, and advance the offset by the number of rows actually returned.

Useful Data Inputs

InputWhy it matters
Market listsUse a limit up to 100 and increase offset until the response total is reached.
Polymarket snapshotsUse a limit up to 1,000; request order book depth only when needed.
Binance Spot and Futures snapshotsPage through depth results for cross-venue time-series analysis.
Fixed filtersPreserve the same coin, market type, and time range on each page.

Pagination Workflow

# 1. List Polymarket BTC 5m markets
curl -H "X-API-Key: YOUR_API_KEY" \
  "https://api.polyhistorical.com/v1/markets?coin=BTC&market_type=5m&resolved=true&limit=20"

# 2. Pull a page of Polymarket order book snapshots
curl -H "X-API-Key: YOUR_API_KEY" \
  "https://api.polyhistorical.com/v1/markets/MARKET_SLUG/snapshots?include_orderbook=true&limit=1000&offset=0"

# 3. Request the next Polymarket snapshot page by setting offset=1000

# 4. Pull Binance BTCUSDT spot depth snapshots for the same window
curl -H "X-API-Key: YOUR_API_KEY" \
  "https://api.polyhistorical.com/v1/btc/spot/snapshots?limit=1000&offset=0&start_time=START_MS&end_time=END_MS"

Backtesting Questions to Answer

  • Advance by the actual number of rows returned, not by a hard-coded page size.
  • Stop when the response contains no rows or the accumulated offset reaches total.
  • Retry rate-limited requests according to the API's response headers.
  • Keep the query and market slug consistent across every page.

Related Resources

Core Polymarket Data Resources