Order Book

Reconstruct L2 order books at any point in time, stream raw events, or query aggregated metrics. All prices are YES-centric with 4-decimal precision. Sizes and depths are share counts; a level's dollar value is price times size. What the archive holds and how far back it goes is on Polymarket order book data.

GET/markets/{market_id}/orderbook
sdkclient.orderbook.get(market_id, **params)

Reconstruct the full L2 order book at a given timestamp. Defaults to the latest available state.

Parameters
market_idstrrequired
Market UUID or Polymarket condition id.
atint | str
Target timestamp (ms epoch or ISO 8601). Defaults to latest.
depthint
Max levels per side (1-100). Summary metrics always computed from full book.
neareststr= "after"
When at is earlier than data_start: "after" returns the book at data_start, "before" returns DATA_NOT_AVAILABLE.
Response fields
as_ofint
Time of the book state (ms epoch).
requested_atint
The at requested (ms epoch).
neareststr
"before": book at or before at. "after": book at data_start.
[market] = client.markets.list( series_id="btc-multi-strikes-weekly", status="active", sort="-volume", take=1, ) book = client.orderbook.get( market.id, depth=10, ) print(book.best_bid, book.best_ask, book.spread) print(f"{book.bid_depth} shares on bids")
jsonResponse
{ "market_id": "eca78376-8d28-5bca-963c-b8f10c13b2b8", "platform": "polymarket", "as_of": 1787564992484, "requested_at": 1787565010759, "nearest": "before", "bids": [ { "price": 0.033, "size": 84.0 }, { "price": 0.031, "size": 970.0 } ], "asks": [ { "price": 0.043, "size": 970.0 }, { "price": 0.044, "size": 970.0 } ], "best_bid": 0.033, "best_ask": 0.043, "spread": 0.01, "midpoint": 0.038, "bid_depth": 13930.81, "ask_depth": 13607.99, "bid_levels": 17, "ask_levels": 11 }
GET/markets/{market_id}/orderbook/history
sdkclient.orderbook.walk(id, **params)

Stream order book snapshots and deltas over a time range. The SDK's walk() iterator reconstructs full book state at each point, yielding (Market, OrderBook) tuples. Accepts a market UUID, series slug, or condition ID. History is built after a market resolves, usually within 2 hours. Before that the market answers 409 EXPORT_NOT_READY, and a single-market walk raises ExportNotReadyError.

walk() parameters
idstrrequired
Market UUID, series slug, or condition ID.
afterstr
Start time (ISO 8601 or ms).
beforestr
End time (ISO 8601 or ms).
coalescebool= false
Yield a book only at each trade and snapshot.
Underlying history endpoint params
market_idstrrequired
Market UUID.
afterint | strrequired
Start of time range, exclusive (ms epoch or ISO 8601).
beforeint | strrequired
End of time range, exclusive (ms epoch or ISO 8601).
include_tradesbool= false
Include trade events in the stream.
coalescebool= false
Emit only the net level change between trades. The book is still exact at every trade and snapshot.
limitint= 10000
Events per page (max 100000).
takeint
SDK only. Caps total items returned across pages.
from datetime import datetime, timedelta, timezone end = datetime.now(timezone.utc) - timedelta(days=1) walk = client.orderbook.walk( "btc-up-or-down-5m", after=end - timedelta(minutes=5), before=end, ) for market, book in walk: print(market.question, book.midpoint)
jsonResponse
{ "market_id": "8150b888-0297-5275-...", "platform": "polymarket", "data": [ { "type": "snapshot", "t": 1710400000000, "is_reseed": false, "bids": [ { "price": 0.6200, "size": 1250.0000 }, { "price": 0.6100, "size": 3400.0000 } ], "asks": [ { "price": 0.6300, "size": 980.0000 }, { "price": 0.6400, "size": 2100.0000 } ] }, { "type": "delta", "t": 1710400001234, "price": 0.6200, "size": 1580.0000, "side": "BUY" }, { "type": "delta", "t": 1710400002100, "price": 0.6300, "size": 0.0000, "side": "SELL" }, { "type": "trade", "t": 1710400001500, "id": "01HQXYZ...", "price": 0.6200, "size": 150.0000, "side": "BUY" } ], "meta": { "cursor": "eyJ0IjoxNzEwNDAwMDAyfQ", "has_more": true } }
GET/markets/{market_id}/orderbook/metrics
sdkclient.orderbook.metrics(market_id, **params)

Time-series of aggregated book metrics at a fixed resolution.

Parameters
market_idstrrequired
Market UUID.
afterint | strrequired
Start timestamp (ms epoch or ISO 8601).
beforeint | strrequired
End timestamp (ms epoch or ISO 8601).
resolutionstrrequired
"1m", "5m", "15m", "1h", "4h", or "1d".
orderstr= "asc"
Sort direction: "asc" or "desc".
limitint= 500
Buckets per page.
cursorstr
Pagination cursor.
takeint
SDK only. Caps total items returned across pages.

Max time ranges per resolution: 24h (1m), 7d (5m), 14d (15m), 30d (1h), 90d (4h), 1y (1d).

from datetime import datetime, timedelta, timezone end = datetime.now(timezone.utc) - timedelta(days=1) [market] = client.markets.list( series_id="btc-up-or-down-5m", status="resolved", close_before=end, sort="-close_time", take=1, ) metrics = client.orderbook.metrics( market.id, after=end - timedelta(minutes=10), before=end, resolution="1m", )
jsonResponse
{ "market_id": "8150b888-67f6-58ed-...", "platform": "polymarket", "resolution": "5m", "data": [ { "t": 1710028800000, "best_bid": 0.6200, "best_ask": 0.6300, "spread": 0.0100, "midpoint": 0.6250, "bid_depth": 18230.0000, "ask_depth": 15440.0000, "bid_levels": 42, "ask_levels": 38 }, { "t": 1710029100000, "best_bid": 0.6300, "best_ask": 0.6400, "spread": 0.0100, "midpoint": 0.6350, "bid_depth": 19100.0000, "ask_depth": 14800.0000, "bid_levels": 44, "ask_levels": 36 } ], "meta": { "cursor": "eyJ0IjoxNzEwMDI5MTAwMDAwfQ==", "has_more": true } }