API & Developers

Polymarket Order Book API: Historical Depth for Backtesting

Use the PolyHistorical Polymarket order book API to fetch historical Level-2 bid/ask depth, market metadata, and snapshots for backtesting.

The Polymarket order book API from PolyHistorical is designed for historical analysis. It gives developers access to archived Level-2 order book snapshots, not just a live top-of-book quote or recent price history.

Historical API vs Live Order Book API

NeedLive order book APIPolyHistorical API
Current bid/askYesHistorical snapshots
BacktestingLimitedBuilt for tick-by-tick replay
Resolved marketsOften unavailableArchived after resolution
Full depthDepends on endpointEvery bid, ask, and price level
BTC/ETH/SOL Up/Down historyNot the focusCore coverage

Core Endpoints

GET /v1/markets
GET /v1/markets/{slug}
GET /v1/markets/{slug}/snapshots
GET /v1/markets/by-market-id/{id}/snapshots

Example Workflow

  1. List markets filtered by coin and timeframe.
  2. Select a resolved market slug.
  3. Fetch snapshots with include_orderbook=true.
  4. Walk the bid/ask ladders to simulate fills.
  5. Store results for strategy evaluation or research.

Python Example

import requests

BASE = "https://api.polyhistorical.com/v1"
headers = {"X-API-Key": "your_api_key"}

markets = requests.get(BASE + "/markets", params={"coin": "BTC", "market_type": "5m"}, headers=headers).json()
slug = markets["markets"][0]["slug"]

snapshots = requests.get(
    BASE + "/markets/" + slug + "/snapshots",
    params={"include_orderbook": "true", "limit": 1000},
    headers=headers
).json()

Best For

  • Trading bots that need historical training data
  • Backtesting engines that model slippage
  • Market microstructure research
  • Liquidity and spread analysis on resolved Polymarket markets

Related Resources