l2Book
Stream real-time L2 orderbook snapshots per coin.
Stream L2 orderbook snapshots at configurable depth. Sent every block (~70ms blocks). Supports optional price aggregation via significant figures and mantissa parameters.
For single-coin subscriptions, data is a single snapshot object. For multi-coin subscriptions, data is an array of snapshot objects batched per block.
Choosing the right orderbook stream
l2Book (raw)
~5ms after L4
Stateless consumers β every message is a complete snapshot
l2Book (aggregated)
~15ms after L4
Display/charting β slightly slower than raw because of aggregations
Subscribe
{
"method": "subscribe",
"subscription": {
"type": "l2Book",
"coins": ["ETH", "BTC"]
}
}Parameters:
coins
string[]
No
Coins to subscribe to. Omit for all markets (requires permission).
nSigFigs
number
No
Aggregate price levels to N significant figures (2-5). Bids round down, asks round up.
mantissa
number
No
Snap to mantissa step (2 or 5). Only valid when nSigFigs=5.
nLevels
number
No
Number of levels per side: 1 (BBO), 10, or 20 (default).
marketTypes
string[]
No
All-markets only. Filters delivery by market type β see All-markets filter. Rejected if combined with coins.
All-markets filter
When coins is omitted, the optional marketTypes field restricts the firehose to specific market types. Each entry is "perp", "spot", "outcome", or the wildcard "*" (alone) for "every type the server currently tracks":
Omitting marketTypes defaults to ["perp"] β outcome and spot markets do not appear unless you opt in. The default never grows; new market types must be added to your marketTypes array explicitly. Pass ["*"] to auto-opt-in to future types.
A second subscribe with a different marketTypes value replaces the previous filter rather than coexisting with it.
Aggregation example:
With nSigFigs=5, mantissa=2, prices are rounded to 5 significant figures then snapped to the nearest multiple of 2 at the last digit. Bids round down, asks round up. For example, bid 70325 becomes 70324, ask 70325 becomes 70326.
Unsubscribe
Update data format
For single-coin subscriptions, data is a single snapshot object (with coin, time, levels). For multi-coin or all-markets subscriptions, data is an array of snapshot objects batched per block.
When the subscription includes aggregation parameters, the response includes nSigFigs and (if applicable) mantissa so clients can distinguish messages from multiple concurrent l2Book subscriptions at different aggregation levels.
Single-coin subscription (raw):
Single-coin subscription (aggregated, nSigFigs=5, mantissa=2):
Multi-coin subscription:
Field reference
Envelope fields (on every message):
seq
number
Per-subscription sequence number
cursor
string
Always "0" β l2Book is stateless (every message is a complete snapshot, no replay)
nSigFigs
number
Present only on aggregated subscriptions. Echoes the nSigFigs value from the subscribe request.
mantissa
number
Present only when the subscribe request included mantissa. Echoes the value.
Per-coin data fields (each item in data):
coin
string
Market symbol (e.g., "ETH", "BTC")
time
number
Block timestamp (milliseconds since epoch)
levels
array
Tuple of [bids, asks]. Bids sorted descending, asks ascending.
levels[][].px
string
Price as decimal string
levels[][].sz
string
Total size at this price level as decimal string
levels[][].n
number
Number of orders at this price level
Examples
Common errors
Too many coins- Reduce number of coins or upgrade tierSubscribing to all markets requires permission- Needsws:l2BookAlladd-onInvalid nSigFigs value- Must be 2, 3, 4, or 5Invalid mantissa value- Must be 2 or 5, only valid withnSigFigs=5Invalid nLevels value- Must be 1, 10, or 20Rate limit exceeded- Reduce subscription frequency
Last updated