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.
GET
/markets/{market_id}/orderbooksdk
client.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.
atint
Target timestamp (ms). Defaults to latest.
depthint
Max levels per side (1-100). Summary metrics always computed from full book.
book = client.orderbook.get("8150b888...", depth=10)
print(book.best_bid, book.best_ask, book.spread)
print(f"{book.bid_depth} USD on bids")jsonResponse
{
"data": {
"market_id": "8150b888...",
"platform": "polymarket",
"as_of": 1710400000000,
"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" }
],
"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
}
}GET
/markets/{market_id}/orderbook/historysdk
client.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.
walk() parameters
idstrrequired
Market UUID, series slug, or condition ID.
afterstr
Start time (ISO 8601 or ms).
beforestr
End time (ISO 8601 or ms).
Underlying history endpoint params
market_idstrrequired
Market UUID.
afterintrequired
Start of time range (exclusive, ms).
beforeintrequired
End of time range (exclusive, ms).
include_tradesbool= false
Include trade events in the stream.
limitint= 1000
Events per page.
walk = client.orderbook.walk(
"sol-up-or-down-5m",
after="2024-03-10",
before="2024-03-14",
)
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/metricssdk
client.orderbook.metrics(market_id, **params)Time-series of aggregated book metrics at a fixed resolution.
Parameters
market_idstrrequired
Market UUID.
afterintrequired
Start timestamp (ms).
beforeintrequired
End timestamp (ms).
resolutionstrrequired
"1m", "5m", "15m", "1h", "4h", or "1d".
orderstr= "asc"
Sort direction: "asc" or "desc".
limitint= 500
Buckets per page.
cursorstr
Pagination cursor.
Max time ranges per resolution: 24h (1m), 7d (5m), 14d (15m), 30d (1h), 90d (4h), 1y (1d).
metrics = client.orderbook.metrics(
"8150b888...",
after="2024-03-10",
before="2024-03-14",
resolution="5m",
)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
}
}