Quick example
Node.js
Commands
Every command carries anid you choose; the reply echoes it.
Subscribe to a series, not a window, to follow it automatically. With
series_tickers: ["sol-15m"], each new window’s window_lifecycle event and first orderbook_snapshot arrive on the same subscription — no resubscribing every 15 minutes. You can pass up to 100 tickers per command.
Channels
A channel is what you subscribe to. Each data message it sends carries its owntype, which is the message’s name and is not always the channel’s: prices sends price, user_orders sends user_order, market_positions sends market_position, and orderbook_delta sends an orderbook_snapshot first. Switch on type (or on sid), never on the channel name.
With an API key you also get three private channels for your own account — see Your account below.
Prices
AAPL), crypto (X:BTCUSD) or a pre-IPO company’s implied valuation (P:OPENAI, P:ANTH — the series’ underlying with a P: prefix), upper case, up to 64 per command. t_ms is when the price printed at its source; ts_ms is when the server sent it. These are the same prices windows open and settle on.
Your account (private channels)
Connect with your API key in the handshake and three more channels open — your own orders, fills and positions, pushed the moment they change. No polling.Node.js
401 with the reason, the same messages as REST). Without a key the connection works as before, with the public channels only.
They cover your whole account; add
market_tickers to narrow them. The channel names are plural where a message is one item: you subscribe to user_orders and receive user_order messages, one per order. user_order carries the same order object as REST, with client_order_id on orders you placed through the API.
Cancel on disconnect
Turn it on for a connection and, if that connection drops for any reason — your program crashes, your network fails, a heartbeat is missed, or we restart the server — every order your account has resting through the API is cancelled. Your quotes never sit on the book while you can’t see it."enabled": false to turn it off. It applies to the account, so with two connections that both enable it, either one dropping cancels everything. After reconnecting, read GET /portfolio/orders (or subscribe to user_orders) before quoting again.
Sequence numbers and recovery
Every data message has the envelope{ type, sid, seq, ts_ms, msg }. seq starts at 1 and goes up by exactly 1 per message on that subscription.
- If
seqjumps, you missed messages. Sendupdate_subscriptionwithaction: "get_snapshot"(or resubscribe) and drop your local books until fresh snapshots arrive. - Snapshots carry the whole book; deltas carry one level. A delta means: the contracts at
priceonoutcome’s bid side change bydelta. A level that reaches 0 is removed.
Checksums
Everyorderbook_snapshot and orderbook_delta carries the checksum of the book after it is applied. Compute it on your side after each message; if it doesn’t match, your copy is wrong — request a snapshot.
- Take each side’s levels best first (highest price first) and keep the top 10.
- Write each level as
price:count, exactly as sent on the wire:0.55:10. - Join a side’s levels with
,, prefix them withup:anddown:, and join the two sides with|:up:0.55:10,0.54:3|down:0.44:7(an empty side is justup:ordown:). - The checksum is the CRC-32 (the zlib / PNG one) of that string’s UTF-8 bytes, as an unsigned 32-bit integer.
Limits
The server pings every 10 seconds; standard websocket clients answer automatically. A connection that stops answering is closed. Flooding commands closes the connection with code
1008, and a message over 64 KB with 1009. See Errors for the numbered error replies.