Skip to main content

Credit Cost

1 per coin per minute

Processing

Realtime
  • GoldRush-native. l4BookUpdates is not exposed on wss://api.hyperliquid.xyz/ws. Pointing a client at the public endpoint with this subscription type will fail.
  • Order-level (L4) diffs. Like l4Book, every change is per individual order (user, oid, side, raw_book_diff) plus the order-lifecycle order_statuses for the block — not aggregated price levels.
  • Strictly block-ordered. Diffs are emitted synchronously in monotonic block_height order. This is the difference from l4Book, whose per-block broadcast can deliver adjacent blocks out of order. The l4Book channel is unchanged; l4BookUpdates is the strictly-ordered, sequenced sibling.
  • Diff-only — no inline snapshot. This stream never sends a Snapshot frame; every message is an Updates batch. Seed your local book from the REST l4BookSnapshot info method, then apply diffs on top — see Bootstrapping & gap detection.
  • Sequenced for gap detection. Each per-coin diff carries a monotonic seq and the prev_seq it follows; each batch carries a server epoch and a cursor. This lets a client detect a dropped message or a server reset and re-bootstrap deterministically.
  • Perps only. No spot or prediction-market assets. coin is required — subscribe with a single symbol or an array of symbols; one asset per book.
Note: l4BookUpdates bills a flat rate per subscribed coin per minute, with no BTC premium (unlike l4Book). A multi-coin array bills the sum across its coins.

Endpoint

string
required
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:
string
required
Always "subscribe".
object
required

Example

Unsubscribe

Send the same subscription 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.

Streamed messages

Every message has channel: "l4BookUpdates" 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. Each per-coin entry carries the block’s order_statuses (order lifecycle events) and book_diffs (per-order changes) for that coin, plus its own seq/prev_seq.
The raw_book_diff descriptor is one of:
  • { "new": { "sz": "<size>" } } — a newly resting order.
  • { "update": { "origSz": "<old>", "newSz": "<new>" } } — a resize (e.g. partial fill).
  • "remove" — the order left the book (filled or cancelled).

Bootstrapping & gap detection

l4BookUpdates is diff-only, so you build the order-level book yourself by seeding from a snapshot and applying diffs in order — the same mechanism a reference L4 client uses:
  1. Subscribe to l4BookUpdates for your coin(s) and start buffering the incoming Updates.
  2. Fetch a snapshot for each coin from the REST l4BookSnapshot info method. Note its height, epoch, and per-coin seq.
  3. Discard already-applied diffs. Drop any buffered batch whose block_height is ≤ the snapshot’s height (the snapshot already includes those blocks). Equivalently, per coin, drop any diff whose seq ≤ the snapshot’s seq.
  4. Verify the epoch. Every remaining diff’s epoch must equal the snapshot’s epoch. A different epoch means the stream reset after your snapshot — re-fetch the snapshot and restart.
  5. Apply in order. For each coin, the first diff you apply should have prev_seq == snapshot.seq. For each raw_book_diff, insert (new), resize (update), or delete (remove) the order by oid.
  6. Ongoing gap detection. Per coin, each diff’s prev_seq must equal the last seq you applied for that coin. On a mismatch (a dropped message) or an epoch change (a server reset), re-bootstrap that coin from step 2.
The seq/prev_seq are per coin, tracked within the current epoch. Compare them per coin, not globally across the batch.

Response fields

string
Always "l4BookUpdates".
object
Contains an Updates batch.

l4Book

subscribe to GoldRush’s order-level Hyperliquid book - initial snapshot of every resting order plus per-block diffs with full metadata.

l4BookSnapshot

fetch a full order-level (L4) book snapshot for one coin, with height, epoch, and seq to bootstrap the l4BookUpdates stream.

l2BookDiff2

subscribe to a diff-only L2 order book stream with per-coin sequence numbers and a server epoch for gap detection.
See all Hyperliquid endpoints: Overview hub · WebSocket API reference