l2BookDiffSnapshot
Get L2 orderbook snapshot for bootstrapping the l2BookDiff WebSocket stream.
Overview
The l2BookDiffSnapshot endpoint returns full-depth L2 orderbook snapshots with height, epoch, and seq fields. This is the bootstrap endpoint for clients using the l2BookDiff WebSocket stream β fetch a snapshot here, then apply incremental diffs from the WebSocket to maintain a local orderbook.
Key details:
Full-depth snapshots (all price levels)
Includes
height,epoch, andseqfor diff stream synchronizationReturns msgpack β zstd-compressed only when the request sends
Accept-Encoding: zstd, otherwise uncompressed
Request
Endpoint: POST /info
Single coin:
{
"type": "l2BookDiffSnapshot",
"coin": "ETH"
}Multiple coins:
{
"type": "l2BookDiffSnapshot",
"coins": ["ETH", "BTC"]
}All markets, perps only (default):
All markets, perps + outcomes:
Parameters:
coin
string
No
Single coin to fetch.
coins
string[]
No
Multiple coins to fetch.
marketTypes
string[]
No
All-markets only. Each entry is "perp", "spot", "outcome", or the wildcard "*" (alone) for every type the server currently tracks. Omit for ["perp"] (default). Rejected if combined with coin / coins.
Omit both coin and coins to fetch all markets. Always returns full-depth snapshots.
Response
Headers:
Content-Type: application/octet-streamContent-Encoding: zstdβ only when the request sendsAccept-Encoding: zstd. Without it, the body is uncompressed msgpack. (Onlyzstdis supported;gzipis ignored.)
Format: msgpack L2BookSnapshot. Each snapshot is encoded as a positional array (not a keyed map), always with this exact field order and length:
All six elements are always present (epoch and seq are never omitted β seq is 0 only if the coin has had no diff this epoch). Shown as JSON for readability:
Field reference
coin
string
Market symbol
time
number
Block timestamp (milliseconds since epoch)
levels
array
Tuple of [bids, asks]. Bids descending, asks ascending.
levels[][].px
string
Price as decimal string
levels[][].sz
string
Total size at this price level
levels[][].n
number
Number of orders at this level
height
number
Block height of this snapshot β use this to align with the l2BookDiff stream.
epoch
string
Server epoch (UUID) β must match epoch in l2BookDiff messages. A different epoch means the snapshot is stale; re-fetch.
seq
number
Per-coin sequence number as of this snapshot. Always present (0 if the coin has had no diff this epoch). Matches the per-coin seq in the l2BookDiff stream β the first diff you apply for the coin should have prev_seq == seq.
Bootstrapping the diff stream
Align on height β it is always present and is shared by this snapshot and every l2BookDiff batch. The snapshot already includes the diffs up to and including its own height (it is taken after that block is applied), so discard any diff at or below it.
Don't align on the diff stream's top-level
seq; that is a per-connection message counter, unrelated to this snapshot. Seel2BookDiffβ Sequencing and gap detection.
Subscribe to
l2BookDifffor your coin(s) β start buffering messages.Fetch this snapshot β note
height,epoch, and the per-coinseq.Discard already-applied diffs: drop any buffered batch whose
data.height <= snapshot.height.Verify
epoch: every remaining diff'sepochmust equal the snapshot'sepoch. A differentepochmeans the server restarted after the snapshot β re-fetch and restart.Apply the remaining batches in
heightorder. The first diff you apply for each coin should haveprev_seq == snapshot.seq(the per-coinseq).Ongoing gap detection: per coin, check
prev_seqcontinuity against the lastseqyou applied (seel2BookDiffβ Sequencing and gap detection). On a gap orepochchange, re-fetch this snapshot.
Common errors
400: Invalid
coin/coinsparameter403: Permission denied - check API key
404: No snapshot available yet
429: Rate limit exceeded
Last updated