Data
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.
/markets/{market_id}/orderbookclient.orderbook.get(market_id, **params)Reconstruct the full L2 order book at a given timestamp. Defaults to the latest available state.
[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"){
"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
}/markets/{market_id}/orderbook/historyclient.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.
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){
"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 }
}/markets/{market_id}/orderbook/metricsclient.orderbook.metrics(market_id, **params)Time-series of aggregated book metrics at a fixed resolution.
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",
){
"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
}
}