vike-polymarket-order-book
Every call here takes an outcome token id (a long decimal number), never the market's condition_id (0x...). Get the token id of the outcome you want, by its label, from outcomes[].token_id in vike-data polymarket markets or clob_token_ids in vike-data polymarket market <condition_id> (see vike-polymarket-find-market).
Call it
Use the first of these that is available:
- MCP:
polymarket_orderbook(token_id, optionalts,depth);polymarket_market_stats(token_id);polymarket_tape(token_id,from_ms,to_ms,event_type: "price_change", optionalcursor,limit). - CLI:
T=97531408855841405410232789703119036119573635076996943730887685044477538494161 vike-data polymarket orderbook $T --depth 5 --json # the book now vike-data polymarket orderbook $T --ts 1796087347000 --depth 5 --json # the last full snapshot at or before that moment vike-data polymarket market-stats $T --json # recorded since when, how much vike-data polymarket tape --token-id $T --from-ms 1796170000000 --to-ms 1796173700000 --event-type price_change --limit 5000 --json - curl: the credential is
VIKE_API_KEY, elseapi_keyoranon_tokenfrom~/.vike/config.json(Windows%USERPROFILE%\.vike\config.json); with none, get a free anonymous token withcurl -s -X POST https://data.vike.io/v1/anon -H 'Content-Type: application/json' -d '{"source":"skill-curl"}'and save itstokenthere as"anon_token"(seevike-core).curl -s "https://data.vike.io/v1/polymarket/orderbook?token_id=$T&depth=5&ts=1796087347000" -H "X-API-KEY: $TOKEN" curl -s "https://data.vike.io/v1/polymarket/market_stats?token_id=$T" -H "X-API-KEY: $TOKEN" curl -s "https://data.vike.io/v1/polymarket/events?token_id=$T&from_ms=1796170000000&to_ms=1796173700000&event_type=price_change&limit=5000" -H "X-API-KEY: $TOKEN"
--depth is levels per side, 1 to 25 (default 25). --ts is epoch milliseconds; omit it for the latest book. The tape window is at most 24 hours, --to-ms exclusive; page while has_more with --cursor <next_cursor> (--limit default 100 on the CLI and MCP, 5000 on REST, at most 50,000).
Output
orderbook: rowsas_of_ts(epoch ms, the full snapshot actually used),side(askorbid),level(1 = best),price(a probability, 0 to 1),size(shares); all asks first, then all bids, each(side, level)once.market-stats: one row:first_msandlast_ms(first and last recorded event, epoch ms),snapshots,total_events,trades,trade_volume(in SHARES, not dollars).tape --event-type price_change:{events, has_more, next_cursor}, oldest first. Each row:ts(Polymarket's time) andlocal_ts(ours),side(buy= the bid side,sell= the ask side),price(the level that changed),size(the new size there; 0 = the level is gone),best_bidandbest_askafter the change, andbids/asks(the changed level as a JSON string).
Reading
- Spread = level 1
ask- level 1bid; mid = their average. Depth = sum ofsizewithin N cents of the best price on each side; dollars at a level =sizexprice. A side can be missing (a one-sided book): then there is no spread. - Check
as_of_tsbefore quoting. A full snapshot is taken now and then, not every moment: asked for 24 h ago on 2026-12-02, the snapshot used was 26 minutes older than--ts. For the book exactly at T, replay theprice_changerows fromas_of_tsto T over it: each row setssizeatpriceon its side. For a quiet or finished marketas_of_tscan be days old. - Spread over time =
best_bid/best_askof theprice_changerows: one row per change, so a busy day is tens of thousands of rows (page through, or take every Nth). These two fields are recorded since 2026-11-05 18:02 UTC; before that, and on row types that do not carry them,0means absent, not a price of 0. For hourly or daily bars of the price itself usevike-candles. --event-type bookreturns the full snapshots in the window (the whole ladder inbids/asks, JSON strings).- The tape window counts OUR receive time (
local_ts);tsis Polymarket's own and can differ by milliseconds. market-stats:first_mssays from when this outcome is recorded.total_events: 0means never recorded, not quiet: re-check the token id. Recorded markets are the most active ones and the up/down series since 2026-07-25, not every Polymarket market.- Prices are probabilities: 0.012 = 1.2 % chance. Sizes are shares; one share pays $1 if the outcome wins.
Errors
that is a condition_id (0x...); this tool takes an outcome token id, ...(exit 1): you passed the market id; take a token id instead. On REST a condition id is not refused:orderbookanswers[]andmarket_statsa row of zeros.orderbook[]: no snapshot at or before--ts(before recording began for this token) or a token never recorded.events window too wide: ...ms requested, max 86400000ms (24h): split the window into days, or for more than a few days take the daily Parquet files (vike-pm-l2-archive, streambook_eventsorl1_quotes).invalid event_type '...' (must be one of book, price_change, trade, tick_size_change, status).- REST: errors are 400
{"error": "..."}, and an unknown parameter is refused (?start=getsdid you mean 'from_ms'). - Exit code 3: the anonymous token's daily limit; tell the user to run
vike-data login, do not retry.
Anti-patterns
- Don't quote a spread without its
as_of_ts. - Don't call a market illiquid from an empty book until
market-statsshows it is recorded. - Don't fetch
bookrows to get best prices:price_changerows already carry them.
Pairs well with
vike-polymarket-tape- the trades that hit this book, with walletsvike-pm-market-diligence- the whole one-market check this book is a part ofvike-pm-l2-archive- whole days of the book as Parquetvike-predictfun-market-detail- the order book of a Predict.fun market
