subscribe_market_prices, and the newPriceData and orderbookUpdate payloads that subscription delivers.
Subscribing to market data
Subscribe to price and orderbook updates by emittingsubscribe_market_prices:
Initial snapshot
Right after thesystem acknowledgement, the server emits one orderbookUpdate per CLOB slug in your subscription with the full current book. This happens on every subscribe_market_prices call, including a re-subscribe over a live connection, and it covers every slug in the new set, not only the ones you added. A market with no resting orders still gets its snapshot: bids and asks are empty arrays and midpoint is 0.5.
The snapshot carries the same orderbook object as GET /markets/{slug}/orderbook minus lastTradePrice, so you can seed local state from the socket alone.
Two cases do not produce a snapshot:
- A slug that does not resolve to a market. It is listed in the acknowledgement’s
marketsarray and joined, but no book is sent. - A resolved market. It is dropped from
marketsand nothing is sent. If every requested slug is resolved you get anerrorevent instead.
version to discard any live frame that arrives with a lower value (see orderbookUpdate).
AMM addresses receive an initial newPriceData the same way, with blockNumber set to 0, when a price is available.
Event payloads
newPriceData
Looking for individual events?
orderbookUpdate is market-wide state, not an event feed. For discrete events:- Your own orders, in real time —
subscribe_order_events. One event per lifecycle change, authenticated, and it only ever carries your own orders. - Every mined trade in a market — Get Market Events. Public, newest first, paginated. Cached, so not real time, and mined trades only: no placements or cancellations.
orderbookUpdate
Emitted for CLOB markets when the book changes (new bids/asks, removals, or fills). orderbook carries the full updated book. Each side is a sorted array of price levels.
Updates are coalesced: several changes in quick succession arrive as a single message, so on a busy market one frame can represent several fills. Each message is the resulting book, not a list of what changed, so replace your local copy with what arrives rather than diffing consecutive messages or counting frames as events.
price and size are JSON numbers; coerce defensively to preserve decimal precision. For a one-shot snapshot, use GET /markets/{slug}/orderbook, which returns the same shape. You also receive this message once per CLOB slug immediately after subscribe_market_prices, carrying the current book (see Initial snapshot).Related
- WebSocket overview: connection details, handshake authentication, and the full event reference