Recipe 14 of 30
Rebuild the Polymarket order book tick by tick from book events
Read one outcome token's tape from /events, starting at a book snapshot, and replay it in order; a snapshot replaces the ladder, a price_change sets one level, and a gap marker means wait for the next snapshot.
GET /v1/polymarket/events returns one token's raw book tape in one call, in the order the feed delivered it: full-book snapshots (book), one-level changes (price_change), prints (trade) and recorder markers (status). Start the window at a snapshot, apply the rows in the order they come back, and you hold the book as it stood after every change. The full parameter list is on Event tape.
Quick answer
Start the window at a book snapshot and read every change after it.
# one token's tape from a book snapshot onward: the snapshot, then every change after it, oldest first
curl -H "X-API-Key: $VIKE_API_KEY" \
"https://data.vike.io/v1/polymarket/events?token_id=95532524407959903145510583684979049735028502452973932716346555811355282494630&from_ms=1787180204123&to_ms=1787180804123&limit=6"Example response
Captured from the live API on 2026-10-24 at 17:21 UTC, all 6 rows of the page; the two bids ladders hold 82 levels each and are cut short. Apply the rows in the order returned. A book row with is_snapshot 1 replaces the token's whole ladder (parse bids and asks, which are JSON text); a price_change sets the size at price on its side (buy is the bid ladder, sell the ask ladder), and a size of 0 removes the level. In the capture the 0.782 bid is removed and then set to 6.25 shares, and the snapshot after the gap holds exactly that book; trade rows change nothing, because the matching price_change already carries the new size.
{
"events": [
{
"asks": "",
"best_ask": 0.0,
"best_bid": 0.0,
"bids": "[[0.001,100035.58],[0.002,50010.0],[0.003,23.58], ... ,[0.99,40105.0],[0.991,10077.0],[0.999,245560.72]]",
"event_type": "book",
"is_snapshot": 1,
"local_ts": 1787180204123,
"price": 0.0,
"seq": 8412,
"side": "none",
"size": 0.0,
"status": "",
"token_id": "95532524407959903145510583684979049735028502452973932716346555811355282494630",
"ts": 1787180183998
},
{
"asks": "",
"best_ask": 0.0,
"best_bid": 0.0,
"bids": "[[0.782,0.0]]",
"event_type": "price_change",
"is_snapshot": 0,
"local_ts": 1787180253349,
"price": 0.782,
"seq": 8413,
"side": "buy",
"size": 0.0,
"status": "",
"token_id": "95532524407959903145510583684979049735028502452973932716346555811355282494630",
"ts": 1787180253337
},
{
"asks": "",
"best_ask": 0.0,
"best_bid": 0.0,
"bids": "[[0.782,6.25]]",
"event_type": "price_change",
"is_snapshot": 0,
"local_ts": 1787180253921,
"price": 0.782,
"seq": 8414,
"side": "buy",
"size": 6.25,
"status": "",
"token_id": "95532524407959903145510583684979049735028502452973932716346555811355282494630",
"ts": 1787180253909
},
{
"asks": "",
"best_ask": 0.0,
"best_bid": 0.0,
"bids": "",
"event_type": "status",
"is_snapshot": 0,
"local_ts": 1787180325620,
"price": 0.0,
"seq": 0,
"side": "none",
"size": 0.0,
"status": "gap_start",
"token_id": "95532524407959903145510583684979049735028502452973932716346555811355282494630",
"ts": 1787180325620
},
{
"asks": "",
"best_ask": 0.0,
"best_bid": 0.0,
"bids": "",
"event_type": "status",
"is_snapshot": 0,
"local_ts": 1787180326567,
"price": 0.0,
"seq": 0,
"side": "none",
"size": 0.0,
"status": "live_resume",
"token_id": "95532524407959903145510583684979049735028502452973932716346555811355282494630",
"ts": 1787180326567
},
{
"asks": "",
"best_ask": 0.0,
"best_bid": 0.0,
"bids": "[[0.001,100035.58],[0.002,50010.0],[0.003,23.58], ... ,[0.99,40105.0],[0.991,10077.0],[0.999,245560.72]]",
"event_type": "book",
"is_snapshot": 1,
"local_ts": 1787180326583,
"price": 0.0,
"seq": 8415,
"side": "none",
"size": 0.0,
"status": "",
"token_id": "95532524407959903145510583684979049735028502452973932716346555811355282494630",
"ts": 1787180253909
}
],
"has_more": true,
"next_cursor": "1787180326583:8415:95532524407959903145510583684979049735028502452973932716346555811355282494630"
}Variations
Find the first snapshot of a window. Ask for book rows only with limit=1; its local_ts is the from_ms to replay from.
# the first full-book snapshot inside a window
curl -H "X-API-Key: $VIKE_API_KEY" \
"https://data.vike.io/v1/polymarket/events?token_id=95532524407959903145510583684979049735028502452973932716346555811355282494630&event_type=book&from_ms=1787180000000&to_ms=1787183633324&limit=1"Keep replaying: the next page. Pass next_cursor back as cursor with the same window, and keep going while has_more is true.
# the rows after the last one of the first page
curl -H "X-API-Key: $VIKE_API_KEY" \
"https://data.vike.io/v1/polymarket/events?token_id=95532524407959903145510583684979049735028502452973932716346555811355282494630&from_ms=1787180204123&to_ms=1787180804123&limit=50000&cursor=1787180326583:8415:95532524407959903145510583684979049735028502452973932716346555811355282494630"Both outcome tokens in one replay. token_ids takes up to 100 tokens. Rows interleave by local_ts; keep one book per token_id.
# the Yes and No books of one market, replayed together
curl -H "X-API-Key: $VIKE_API_KEY" \
"https://data.vike.io/v1/polymarket/events?token_ids=95532524407959903145510583684979049735028502452973932716346555811355282494630,107869950127184141743772429738701578723770582686430100389837827512148691029625&from_ms=1787180204123&to_ms=1787180804123&limit=50000"A whole day: the archive file. The archive's book_events stream holds the same rows for a whole UTC day. For the 5-minute BTC markets of
2026-10-23 it is one file of 1.65 GB and 97.8 million rows.
# where the day's full-book file is, with its size
curl -H "X-API-Key: $VIKE_API_KEY" \
"https://data.vike.io/v1/polymarket/archive/url?date=2026-10-23&stream=book_events&asset=btc&tenor=5m"Before you rely on it
After gap_start, the book you hold is wrong
When the recorder loses the feed it writes a status row gap_start, and live_resume when it is back; the
changes in between are missing. Drop the token's book at gap_start and start again from the next book row, as
the example response does. In the free archive sample (one 5-minute BTC market, 2026-10-23) such gaps came about every two
minutes, and the replay reproduced 5,610 of the 5,624 following snapshots exactly, so also reset on every snapshot.
A busy market outgrows the API
A window is at most 24 hours and a page at most 50,000 rows. The two tokens of the sample market produced 690,968
price changes in about ten minutes, so a day of such a market is thousands of pages: download the day's
book_events file instead.
Ask your agent
Connected to the Vike MCP server (https://vike.io/mcp) in Claude, ChatGPT or Cursor, ask it in plain words. The polymarket_tape tool answers, up to 1,000 rows a page, at 1 credit a call.
Show me the book events of Polymarket token 95532524407959903145510583684979049735028502452973932716346555811355282494630 from 22:56 to 23:06 UTC on 2026-08-19