A self-contained walk-through. By the end you’ll have a Python script
that pulls the last 50 resolved BTC 5m markets, downloads each one’s
orderbook history, and writes them to disk as JSON.
1. Mint a key
Create a key
Click Create key , give it a label (e.g. quickstart-laptop).
The full token is shown once — copy it now.
Tokens start with pql_live_ and are 48 characters. They can’t be
recovered — if you lose one, revoke it and mint a new one.
2. First call
export POLYQUANTLAB_API_KEY = "pql_live_…your-key…"
curl -s https://api.polyquantlab.com/v1/markets/resolved \
-G --data-urlencode "ticker=BTC" \
--data-urlencode "event_type=5m" \
--data-urlencode "limit=3" \
-H "Authorization: Bearer $POLYQUANTLAB_API_KEY " | jq '.markets[0]'
Expected — a single resolved market:
{
"market_id" : "0x198001cb01bbcd740a20f949a984f5eb479b6b951d7124f556a6ccef3ae815b9" ,
"ticker" : "BTC" ,
"event_type" : "5m" ,
"resolution_at" : "2026-05-28T02:45:00+00:00" ,
"resolved_at" : "2026-05-28T02:45:16+00:00" ,
"resolution_outcome" : "Down" ,
"strike_price" : 67890.12 ,
"question" : "Bitcoin Up or Down — May 28, 2:40AM-2:45AM ET"
}
3. Pull orderbook history
import os, asyncio, json
import httpx
BASE = "https://api.polyquantlab.com"
KEY = os.environ[ "POLYQUANTLAB_API_KEY" ]
HDRS = { "Authorization" : f "Bearer { KEY } " }
async def main ():
async with httpx.AsyncClient( timeout = 30 ) as c:
# 1. Get 50 most recent resolved BTC 5m markets.
r = await c.get(
f " { BASE } /v1/markets/resolved" ,
params = { "ticker" : "BTC" , "event_type" : "5m" , "limit" : 50 },
headers = HDRS ,
)
r.raise_for_status()
markets = r.json()[ "markets" ]
print ( f "got { len (markets) } markets" )
# 2. For each one, fetch its full orderbook snapshot stream.
for m in markets:
r = await c.get(
f " { BASE } /v1/markets/ { m[ 'market_id' ] } /orderbook" ,
params = { "limit" : 100_000 },
headers = HDRS ,
)
r.raise_for_status()
snaps = r.json().get( "snapshots" , [])
out = f "./data/ { m[ 'market_id' ][: 12 ] } .json"
os.makedirs( "./data" , exist_ok = True )
with open (out, "w" ) as f:
json.dump(snaps, f)
print ( f " { m[ 'market_id' ][: 12 ] } → { len (snaps) } snapshots" )
asyncio.run(main())
4. Next steps
Walk the book Convert the snapshot stream into realistic partial fills.
Run a server-side backtest Skip the local pull entirely — POST a strategy spec and we backtest
against the same data on our side.
Stream live snapshots Subscribe to the WebSocket for sub-second pushes instead of polling.
Browse the live audit Same audit numbers the dashboard renders — public, unedited.