Processing
Realtime
- GoldRush-native.
l2BookDiff2is not exposed onwss://api.hyperliquid.xyz/ws. Pointing a client at the public endpoint with this subscription type will fail. - Diff-only — no inline snapshot. Unlike
l2BookDiff, this stream never sends aSnapshotframe. Every message is anUpdatesbatch. Seed your local book from the RESTl2BookDiffSnapshotinfo method, then apply diffs on top — see Bootstrapping & gap detection below. - Sequenced for gap detection. Each per-coin diff carries a monotonic
seqand theprev_seqit follows; each batch carries a serverepochand acursor. This lets a client detect a dropped message or a server reset and re-bootstrap deterministically. coinis optional. Omit it to stream every asset on a single subscription; usemarketTypesto choose which market families are included (defaults to["perp"]).
Endpoint
Your GoldRush API key. Passed as a query parameter at connection time - no
Authorization header is used.Subscribe
Send this JSON message after the connection is established:Example
Unsubscribe
Send the samesubscription body with method: "unsubscribe":
Unsubscribe matches subscriptions by exact body. A subscription created with
coin: ["BTC", "ETH"] is a different subscription from one created with coin: "BTC". To narrow a multi-coin set, unsubscribe the original coin array in full, then resubscribe with the smaller list.Book depth
l2BookDiff2 carries the complete order book: every resting price level on both sides, with no cap on the number of levels per side. Prices are at full precision. There are no nLevels, nSigFigs or mantissa parameters, so levels are never rounded or bucketed. Each level is one exact price, with sz the total size and n the number of orders resting at that price. For individual orders, use l4Book.
Streamed messages
Every message haschannel: "l2BookDiff2" and a data payload containing an Updates batch (this stream never emits a Snapshot). An Updates batch is emitted on each HyperCore block where the book for at least one subscribed coin changed.
levels[0] (bids) and levels[1] (asks) replaces the current state at its px. A level with sz: "0" and n: 0 means the level at that price has been removed.
Bootstrapping & gap detection
l2BookDiff2 gives you diffs only, so you build the book yourself by seeding from a snapshot and applying diffs in order:
- Subscribe to
l2BookDiff2for your coin(s) and start buffering the incomingUpdates. - Fetch a snapshot for each coin from the REST
l2BookDiffSnapshotinfo method. Note itsheight,epoch, and per-coinseq. - Discard already-applied diffs. Drop any buffered batch whose
block_heightis ≤ the snapshot’sheight(the snapshot already includes those blocks). You may equivalently discard per coin byseq- drop any diff whoseseq≤ the snapshot’sseq- for the tightest alignment. - Verify the epoch. Every remaining diff’s
epochmust equal the snapshot’sepoch. A differentepochmeans the stream reset after your snapshot - re-fetch the snapshot and restart. - Apply in order. For each coin, the first diff you apply should have
prev_seq == snapshot.seq. For each level, upsert{px, sz, n}, or remove the price whenszis"0". - Ongoing gap detection. Per coin, each diff’s
prev_seqmust equal the lastseqyou applied for that coin. On a mismatch (a dropped message) or anepochchange (a server reset), re-bootstrap that coin from step 2.
Response fields
Related endpoints
l2Book
subscribe to real-time L2 order book snapshots for all Hyperliquid assets over WebSocket.
l2BookDiff
subscribe to real-time L2 order book (initial snapshot + diffs) for all Hyperliquid assets over WebSocket.
l4Book
subscribe to GoldRush’s order-level Hyperliquid book - initial snapshot of every resting order plus per-block diffs with full metadata.
l4BookUpdates
subscribe to a strictly-ordered, diff-only order-level (L4) book stream with per-coin sequence numbers and a server epoch for gap detection.
/info and /ws APIs at hypercore.goldrushdata.com, with no rate limits and every fill, order, trade, funding and ledger event retained from the start of HyperCore coverage.