Hyperliquid L2 Books - Snapshots and Diffs
Maintain Hyperliquid aggregated order books with V3 snapshots, sequenced diffs, and WebSocket alternatives.
An L2 book groups resting liquidity by price. Each level contains price (px), total size (sz), and the number of resting orders (n), without exposing individual order identity.
Access
| Availability | Access | Details |
|---|---|---|
| Live | StreamL2Book and StreamL2BookDiff | Provides typed replacement snapshots for one coin, plus opening snapshots and ordered changes for up to 20 coins. |
| Live | Order Book WebSocket L2 | Provides the live JSON l2Book channel. |
| Archival | S3 Bucket | Raw book records can support custom historical reconstruction when paired with a known state seed. |
Requests and depth
StreamL2Book sends full snapshots for one coin. Omitted n_levels means 20 levels per side, values 1 through 100 select bounded depth, and explicit 0 requests full depth only when the endpoint supports it. An unsupported full-depth request returns FAILED_PRECONDITION.
For both full snapshots and StreamL2BookDiff, n_sig_figs accepts 2, 3, 4, or 5. mantissa is valid only with n_sig_figs set to 5, and its value must be 2 or 5. strict is available only on StreamL2Book and suppresses unchanged snapshots.
Reconstruction behavior
StreamL2Book opens with the current full book, then sends replacement snapshots. StreamL2BookDiff accepts 1-20 coins and opens with one snapshot: true full-book entry per coin. Use that snapshot as the state seed before you apply later diffs. Track seq and prev_seq independently per coin, remove a level when sz is "0.0", and reconnect for new snapshot seeds after a gap or ABORTED.
Both streams are live views with no historical replay. A quiet coin can omit frames, and full-snapshot block_number values can skip when unchanged windows are coalesced.
Sample data
This synthetic V3 opening payload visibly redacts the market identifier:
time: 1785736814057
block_number: 1058646974
diffs: {
coin: "<redacted-market>"
seq: 1
prev_seq: 0
bids: { px: "114250.0" sz: "1.35" n: 4 }
asks: { px: "114251.0" sz: "0.82" n: 3 }
snapshot: true
}Later diff entries contain only changed levels. The complete bid and ask arrays appear again after a reconnect.
Related pages
- Order book WebSocket guide — Build a production L2 client with reconnection handling.
- Best bid and offer — Use a lower-bandwidth top-of-book view.
- L4 books — Inspect individual resting orders instead of aggregated levels.