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
Live update (updatedPrices is an array; there is no top-level marketAddress):
system acknowledgement; blockNumber is 0 and updatedPrices is a single object):
yesPrice and noPrice are JSON numbers between 0 and 1. On live frames read the market from updatedPrices[i].marketAddress.
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.
Live frames may also carry a
side field on each level.
price and size are JSON numbers; coerce defensively to preserve decimal precision. size is in raw 6-decimal units on the initial snapshot and on every later frame, so divide by 1e6 to get shares; price is not scaled. For a one-shot snapshot, use GET /markets/{slug}/orderbook, which returns the same shape and units, except that REST sends minSize and maxSpread as decimal strings. Accept either form. 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