market.orderbook for a public,
market-scoped book with an initial snapshot and subsequent price-level changes.
It is live on Development for spot and perpetual markets. Check subscription
acceptance and source availability before using it on another environment.
market.book continues to send complete
snapshots.
Subscribe and replace the book
SendmarketId in the subscribe envelope
and omit fromSequence. No authentication is required. Wait for the accepted
frame with your requestId; its limit is 50 levels per side and its
nextSequence identifies the first expected data frame. That sequence need not
start at 1.
The first data frame has payload.type: "snapshot". Replace both sides of your
local book with its levels and hold its nonce. If the market has no book read
yet, wait for this first snapshot before displaying a current book.
Each [price, amount] pair is in human units. Preserve the corresponding exact
priceAtoms and sizeAtoms strings from payload.info.bids and
payload.info.asks for book maintenance and checksum validation. Use the market’s
price and quantity scales when converting units.
Apply deltas in order
For each data frame, check its channel and market identity and require the next expected envelopesequence. Advance that expectation by one after accepting the
frame. This is the stream sequence, separate from payload.nonce, which identifies
the engine book state and can skip values.
For a delta, require previousNonce to equal the nonce of the book you hold.
Apply only the listed levels: insert or replace the absolute size at each price;
remove a level when its amount is 0. Do not add the amount to the old size. Sort
bids by descending price and asks by ascending price, and retain the accepted
limit per side. After validating the resulting book’s checksum, hold the new
nonce.
A later snapshot replaces both sides again and has previousNonce: null. When
the book does not change, a freshness snapshot is published about every 30 seconds.
An engine reset can produce a snapshot with a lower nonce; replace your book
and hold that lower value. Updates otherwise arrive about once a second per
market. The payload’s timestamp and datetime describe publication time.
Validate the checksum
Validatepayload.checksum against the entire book after applying the frame,
including levels unchanged by a delta:
- Use the exact atom strings from
info, never rounded JSON numbers or display decimals. Order bids best first and asks best first. - Interleave bid 1, ask 1, bid 2, ask 2, and so on. At each depth, skip a side that has no level.
- For each level, append
priceAtoms:sizeAtoms, and join the level strings with:. Add no spaces, separators at the ends, or JSON syntax. - Compute IEEE CRC32 over the UTF-8 bytes and compare the result as an unsigned
32-bit integer with
checksum. An empty book uses the empty string.
readModelDigest is a
separate field and is not a replacement for this check.
Drop stale state and subscribe again
If the envelope sequence has a gap, a delta’spreviousNonce does not match your
held nonce, or the checksum differs, stop applying updates and mark the book
stale. Discard its levels and continuity state. Unsubscribe from the affected
stream, then subscribe again without fromSequence and wait for a new accepted
frame and snapshot. Use the same fresh-subscription path after reconnecting.
This channel keeps no replay history: any fromSequence request answers
resync_required, even if the requested sequence is recent. Do not retry that
resume. A refused resume leaves an existing subscription for the same market on
the same socket active. If you are recovering stale state, still replace that
subscription with a fresh one; do not treat a refusal as evidence that your local
book is current.