vike

Recipe 29 of 30

Label every book event in an archive day with its market's outcome

Download a day's book_events (or trades) file from the archive, fetch the same day's settlements from /settlements/bulk, and join on condition_id; token_id equal to winning_token_id marks the events of the token that won.

Every archive row carries condition_id and token_id, and every settlement row carries the market's winning_token_id. GET /v1/polymarket/archive/url gives the day's file in one call; save that day's winners from /settlements/bulk and join the two in DuckDB, so each event gets token_won true or false, the label a fill or price model trains on. The full parameter list is on Archive file URL.

Quick answer

Ask where one day of full-book events for the family is.

cURL
# where one day of full-book events for every 5-minute BTC market 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"

Example response

Captured from the live API on 2026-10-24 at 17:22 UTC. One day of 5-minute BTC markets is 97.8 million events in 1.65 GB: snapshots, changes, prints and gap markers of both tokens of every market.

Example response
{
  "asset": "btc",
  "bytes": 1653003667,
  "date": "2026-10-23",
  "layout": "family",
  "rows": 97830363,
  "stream": "book_events",
  "tenor": "5m",
  "url": "https://data.vike.io/archive/venue=polymarket/asset=btc/tenor=5m/date=2026-10-23/book_events.parquet",
  "venue": "polymarket"
}

Variations

Save the day's winners. Ask for resolutions up to an hour past midnight, so the markets that close at the end of the day are included.

cURL — winners file
# winners.jsonl: each market's condition id and winning token
curl -s -H "X-API-Key: $VIKE_API_KEY" \
  "https://data.vike.io/v1/polymarket/settlements/bulk?slug_prefix=btc-updown-5m-&from_ms=1792713600000&to_ms=1792803600000&limit=5000" \
  | jq -c '.settlements[] | {condition_id, winning_token_id}' > winners.jsonl

Download the file.

cURL — download
# the day's full-book events, saved locally
curl -s -L -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&redirect=true" \
  -o btc-5m-book_events-2026-10-23.parquet

Label in DuckDB. A market with no winner in the file (not settled yet, or a void) keeps a NULL label rather than false.

DuckDB
COPY (
  SELECT e.*,
         CASE WHEN coalesce(w.winning_token_id, '') = '' THEN NULL
              ELSE e.token_id = w.winning_token_id END AS token_won
  FROM read_parquet('btc-5m-book_events-2026-10-23.parquet') e
  LEFT JOIN read_json_auto('winners.jsonl') w USING (condition_id)
) TO 'book_events_labelled.parquet';

On the free archive sample (the market btc-updown-5m-1792765500, which Down won) this labels all 699,237 events; 1,472 of the 2,623 prints were on the winning token.

Start smaller: the prints only. The trades stream has the same condition_id and token_id columns and is a few megabytes a day for this family.

cURL — trades file
# where the day's prints of every 5-minute BTC market are
curl -H "X-API-Key: $VIKE_API_KEY" \
  "https://data.vike.io/v1/polymarket/archive/url?date=2026-10-23&stream=trades&asset=btc&tenor=5m"

Before you rely on it

The label is the future

token_won is known only after the market resolves. Use it as the target you train on, never as an input, and never let a feature read rows from after the moment it describes. The file holds one UTC day, so a market that spans midnight has events in two files and should be labelled in both. Drop or reset the stretches between gap_start and live_resume before you treat the book as continuous.

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_archive tool answers with the link, at 1 credit a call. The join runs in your DuckDB.

Ask your agent
Give me the download link for the Polymarket 5-minute BTC book_events file of 2026-10-23, with its size
Example response
{  "asset": "btc",  "bytes": 1653003667,  "date": "2026-10-23",  "layout": "family",  "rows": 97830363,  "stream": "book_events",  "tenor": "5m",  "url": "https://data.vike.io/archive/venue=polymarket/asset=btc/tenor=5m/date=2026-10-23/book_events.parquet",  "venue": "polymarket"}