TheDocumentation Index
Fetch the complete documentation index at: https://goldrush.dev/docs/llms.txt
Use this file to discover all available pages before exploring further.
l2BookDiff channel on wss://hypercore.goldrushdata.com/ws?key=<GOLDRUSH_API_KEY> is a GoldRush-exclusive stream - it has no equivalent on wss://api.hyperliquid.xyz/ws. After subscribing, the server emits one Snapshot per subscribed coin, then per-block Updates carrying only the price levels that changed. The shape per level is the same {px, sz, n} you already get from l2Book, so book-state code only needs to learn how to apply diffs - and coin accepts a single asset, a list, or can be omitted to stream every asset on one subscription. For the raw subscription shape see the l2BookDiff reference; for the connection model see the WebSocket API overview.
What you get
- Snapshot + diff transport. One full
Snapshotper subscribed coin on subscribe, then per-blockUpdatescontaining only the levels that changed. Apply diffs to local state. - Aggregated
{px, sz, n}shape. Identical tol2Booklevels - reuse your existing aggregated-book types and just add a level-apply function. - Multi-coin / wildcard friendly.
coinaccepts a single asset, an array of assets, or can be omitted to stream every asset on one subscription. Whencoinis omitted,marketTypesdefaults to["perp"]— pass["spot"],["outcome"], a mix, or["*"]to opt into spot, outcome, and future market types.l4Bookis one-coin-per-subscription;l2Bookrequires per-asset fan-out on the public feed. - Bandwidth proportional to change. Quiet markets cost almost nothing; only the levels that actually moved arrive over the wire, instead of a full re-snapshot every tick.
- GoldRush-exclusive. Public Hyperliquid has no L2-diff transport -
l2Bookis full-snapshot only.
Subscribe and maintain book state
The pattern below keeps aMap<coin, { bids: Map<px, Level>, asks: Map<px, Level> }>. Each Snapshot seeds the per-coin entry; each book_diff inside Updates either deletes a level (when sz === "0") or replaces it with the new {sz, n}.
Patterns
Single coin, list, or wildcard
All three subscription shapes share the same handler - only the payload sent atsubscribe time changes. Use whichever matches your coverage requirements.
TypeScript
Snapshot per live coin before diffs begin, so the books map fills in over the first few messages rather than all at once. marketTypes is only valid when coin is omitted; it defaults to ["perp"], so spot and outcome markets require explicit opt-in. A second subscribe with a different marketTypes value replaces the previous filter rather than coexisting with it.
Reconstruct a top-of-book stream
After each diff is applied, the best bid is the highestpx in book.bids and the best ask is the lowest px in book.asks. Emit only when the top level changes to avoid noise.
TypeScript
px or improves on it.
Compare against l2Book
l2BookDiff levels carry the same {px, sz, n} shape as l2Book, so any code that consumes l2Book snapshots can consume l2BookDiff state once you maintain the per-coin map. The difference is transport - l2Book re-sends the full book on every tick, while l2BookDiff ships only what changed. For the same coin in both modes the book state will agree at every block boundary; pick the diff variant when wide multi-asset coverage or quiet markets make full-snapshot bandwidth wasteful.
Handling reconnects
On reconnect, resend the samesubscribe payload. The first messages back are fresh Snapshots - one per coin in scope - so drop your local books map for the affected coins and re-seed from those snapshots. Do not attempt to replay missed Updates - the snapshot is authoritative and supersedes anything you held before the disconnect.
TypeScript
Related
l2BookDiffAPI reference - full subscription, snapshot, and update schema.l2Bookreference - full-snapshot transport when diff replay isn’t desirable.l4Bookreference - order-level stream withuser,oid,cloid,tif, and trigger metadata.- WebSocket API overview - endpoint URL, auth, and limits.