Skip to main content

Hyperliquid WebSocket API

Critical Rules

  1. WebSocket URL: wss://hypercore.goldrushdata.com/ws?key=<GOLDRUSH_API_KEY> (note: hypercore, not hyperliquid; auth is a ?key= query parameter, not an Authorization header).
  2. Wire-compatible with wss://api.hyperliquid.xyz/ws for shared subscription types (e.g. l2Book).
  3. No 1000-subscription-per-IP cap. Multiplex many subscriptions on one connection.
  4. l2Book - aggregated price-level snapshots {px, sz, n}. coin is optional - omit it to stream every asset over a single subscription. When coin is omitted, marketTypes defaults to ["perp"] (perps only); pass ["spot"], ["outcome"], a mix, or ["*"] to opt into spot, outcome, and any future market types.
  5. l2BookDiff - GoldRush-native L2 diff transport. Same aggregated {px, sz, n} shape as l2Book, but emits one Snapshot per subscribed coin and then per-block Updates carrying only changed levels. coin accepts a single asset, an array of assets, or can be omitted for wildcard (same marketTypes default - perps only - applies when coin is omitted). Treat sz: "0" (with n: 0) as level removal. Not available on the public Hyperliquid WebSocket.
  6. l4Book - GoldRush-native order-level stream with user, oid, cloid, tif, and trigger metadata per order. coin is required. Emits a single Snapshot on subscribe, then per-block Updates (order_statuses + book_diffs). Not available on the public Hyperliquid WebSocket.

Available Subscriptions

Subscribe / Unsubscribe Pattern

When to use which channel


The GoldRush Hyperliquid WebSocket API is a drop-in replacement for wss://api.hyperliquid.xyz/ws. For the channels GoldRush supports, subscription payloads, channel names, and message shapes are byte-for-byte identical to the public Hyperliquid feed. The only difference is the connection URL - authentication is a required key query parameter, so no header changes are needed in your client.

Endpoint

Your GoldRush API key. Passed as a query parameter at connection time.
Warning: The connection URL - including the key - is visible to any client that opens the socket. Do not ship your API key (cqt_…) to a browser or mobile app. For client-side use, mint a short-lived Ephemeral Key on your backend and pass that as key=gr_ek_… instead. It’s scoped to your API key, expires in 30 minutes, and is safe to embed. See Recipe B: browser WebSocket with auto-refresh.

Comparison with the public Hyperliquid WebSocket

Available subscriptions

Order book

Stream the Hyperliquid order book in real time - three channels, from aggregated L2 snapshots to full order-level (L4) detail. Omit coin on l2Book or l2BookDiff to stream every asset on a single subscription, which the public WebSocket’s 1000-subscription-per-IP cap makes impractical.

Wallet activity

Note: Looking for candle, trades, bbo, or allMids? These public Hyperliquid market-data channels aren’t mirrored on the GoldRush WebSocket - use the GoldRush equivalents instead:
  • OHLCV candles - the Info API candleSnapshot endpoint for historical candles, or the real-time HIP-3 and HIP-4 OHLCV recipes for candles across every HIP-3/HIP-4 market.
  • Trade tape - allFills streams every fill on HyperCore (the global trade tape); userFills narrows it to specific wallets.
  • Best bid/offer and mids - derive top-of-book from l2Book, or read mark and mid prices for the full universe from metaAndAssetCtxs.

Limits

No 1000-subscription-per-IP cap. On l2Book and l2BookDiff, filter parameters are optional - omit coin to stream the full L2 book across every asset on a single subscription. The wildcard defaults to perps only (marketTypes: ["perp"]); pass ["spot"], ["outcome"], a mix, or ["*"] to opt into spot, outcome, and future market types. l2BookDiff additionally accepts an array of coin symbols for a fixed multi-asset subscription. l4Book requires coin and is one-asset-per-subscription. See Limits & Connections for details.

Billing

Subscriptions bill per minute, in whole minutes, with a minimum of one full minute per subscription. There is no proration: a subscription that lives 200 milliseconds costs the same as one that lives 60 seconds, and every reconnect starts a new subscription that pays the minimum again. See Billing for the per-minute rates, the ceil rounding table, and worked examples.
Moving from the public Hyperliquid WebSocket to GoldRush is one change:
  1. URL - replace wss://api.hyperliquid.xyz/ws with wss://hypercore.goldrushdata.com/ws?key=.
That’s it. Subscription payloads, channel names, and the streamed message shape are byte-for-byte identical. Authentication is a required key query parameter, so no header swap is needed in your client.

Side-by-side

wscat

Public Hyperliquid
GoldRush

JavaScript / TypeScript

Public Hyperliquid
GoldRush

Python

Public Hyperliquid
GoldRush

Behavioral notes

Things to be aware of when you cut over.

Stream payloads are byte-equal, modulo live drift

The channel name and data shape match Hyperliquid byte-for-byte - same keys, same nesting, same value types. Numeric fields update independently on each side, so a price level may differ by tens of milliseconds, but the schema is identical.

Auth errors close the connection

A missing or invalid key query param returns HTTP 401 on the upgrade handshake, so the WebSocket never opens. Public Hyperliquid has no auth and never rejects the handshake.

Filter parameters are optional on GoldRush

Parameters that the public Hyperliquid WebSocket requires (e.g. coin on l2Book) are optional on GoldRush. Omit them to stream the entire channel on a single subscription instead of fanning out one subscription per asset. See Limits.

Existing SDKs work after a wsUrl override

Most popular Hyperliquid SDKs accept a WebSocket base URL override - point them at wss://hypercore.goldrushdata.com/ws?key= and the rest of the SDK works unchanged. See SDK compatibility for the override snippets.

Authentication

The WebSocket API uses your standard GoldRush API key, passed as a key query parameter at connection time. The same key works against the Foundational API and the Info API. If you don’t have one yet, sign up here. Never hardcode keys in source. Use environment variables or a secrets manager.

What you gain

  • No subscription cap. No 1000-subscription-per-IP limit; multiplex hundreds of subscriptions on a single connection.
  • Wildcard subscriptions. Omit filter parameters to stream the entire channel - e.g. the full L2 order book across every asset on one subscription.
  • One key for everything Hyperliquid. The same API key unlocks the Info API and HyperEVM via the Foundational API.

The most popular Hyperliquid SDKs work against the GoldRush WebSocket API after a one-line URL override. Authentication is a key query parameter on the connection URL - no header injection is needed.

JavaScript / TypeScript: nomeida/hyperliquid

Install

npm
yarn

Configure

Note: If your SDK version doesn’t expose a wsUrl option, instantiate the WebSocket client manually and pass it to the SDK, or patch the constant the SDK uses. See the override fallback below.

Manual WebSocket fallback

When the SDK doesn’t expose a wsUrl knob, bypass it and drive the raw socket yourself:

Python: hyperliquid-dex/hyperliquid-python-sdk

Install

Configure

Tip: The SDK’s Info class manages both REST and WebSocket. If you only need WebSocket, you can skip the session.headers.update(...) line. If you only need REST, pass skip_ws=True instead.

Verification

After cutover, confirm everything is wired correctly:
  1. Diff a known subscription - subscribe to l2Book for the same coin against both endpoints; the streamed channel and data shape (keys, nesting, types) should match exactly.
  2. Confirm auth - remove the key query parameter and confirm the WebSocket upgrade fails with HTTP 401. If the socket opens, your request isn’t reaching GoldRush.
  3. Confirm wildcard - subscribe to l2Book without a coin and confirm you receive book snapshots for multiple assets. This call would be rejected on the public Hyperliquid WebSocket.

Other SDKs

The pattern is the same for any WebSocket client: override the connection URL to wss://hypercore.goldrushdata.com/ws?key=. If you run into a specific SDK that doesn’t expose a URL override, email us - we’ll publish a recipe.

Hyperliquid WebSocket rate limits

The public Hyperliquid WebSocket (wss://api.hyperliquid.xyz/ws) caps each IP at 1000 active subscriptions, and most channels require one subscription per asset - so tracking the full market means fanning out hundreds of subscriptions and risking the cap. The GoldRush Hyperliquid WebSocket API removes that cap. It’s a drop-in replacement with no per-IP, per-key, or per-connection subscription limit, plus wildcard subscriptions that stream an entire channel over a single subscription.

No subscription cap

With no subscription limit, you can:
  • Open as many concurrent subscriptions as your client supports.
  • Multiplex hundreds of l2Book subscriptions on a single connection.
  • Track every active wallet, market, and asset from one process.

Wildcard subscriptions

Filter parameters that the public Hyperliquid WebSocket requires are optional on GoldRush. Omit them to stream the entire channel on one subscription instead of fanning out one subscription per asset. So a single connection can stream Hyperliquid’s full live book state without any client-side fan-out logic.

How streaming works

Messages are pushed directly from a live Hyperliquid ingestion pipeline - no polling, no cache delay. Latency from upstream Hyperliquid event to your client is dominated by network round-trip from our Tokyo nodes.

Billing

Subscriptions on this WebSocket are billed per minute, in whole minutes. There is no proration and there is no partial minute. Every channel bills on that basis; what differs is the unit being counted. Order-book channels (l2Book, l2BookDiff, l4Book, l4BookUpdates, trades) bill per coin. Wallet-activity channels bill a flat rate per channel, whatever the address count.
Warning: The minimum charge is one full minute per subscription. A subscription that lives for 200 milliseconds costs exactly the same as one that lives for 60 seconds. If your client reconnects often, read Every reconnect costs a new first minute.

The first minute is charged up front

The moment the server accepts your subscribe message, it charges one full minute at the channel’s per-minute rate. This happens before the first frame reaches you, so subscribing and disconnecting immediately does not avoid the charge. This is deliberate. Without it, a client could grab a snapshot for a fraction of a credit and drop the connection, which is a far cheaper way to poll the book than the REST endpoints it would otherwise use.

After that, every started minute is a full minute

Once the first minute is paid, the total you owe is ceil(seconds_subscribed / 60), counted from the instant you subscribed: Any second past a full minute starts the next billable minute. Usage never accrues a fractional minute, so you can always compute a subscription’s cost as ceil(seconds / 60) x rate.

Per-minute rates

A wildcard subscription is billed as one subscription at the flat wildcard rate, no matter how many assets it streams. So the wildcard pays for itself once you are tracking enough coins to match its rate: 100 coins on l2Book (100 x 0.5 = 50) and 77 coins on l2BookDiff (77 x 0.13 = 10.01). Below that, per-coin subscriptions cost less. l4Book has no wildcard; coin is required. l4BookUpdates and trades are per-coin with no wildcard and no BTC premium.

Wallet-activity channels bill a flat per-channel rate

userFills, allFills, liquidationFills, orderUpdates, userNonFundingLedgerUpdates, and builderFills bill on the same whole-minute basis, but at a flat rate per channel, not per coin: The rate does not scale with the number of addresses you track: one userFills subscription covering 10 addresses or 1,000 addresses is the same 1 credit per minute. Two consequences:
  • One billable subscription per (connection, channel). Adding or removing addresses on a channel you are already subscribed to does not open a new billable subscription.
  • Up to 1,000 addresses per connection, per channel. To track more, open additional connections. Each one bills its own 1 credit per minute per channel.

What counts as one subscription

On the order-book channels, a subscription is identified by the channel plus the exact coin field you sent, on one WebSocket session. Three consequences follow:
  • Re-sending an identical subscribe on a live session is free. It is deduplicated, produces no extra data, and adds no charge.
  • An array subscription is one subscription, not N. {"type": "l2BookDiff", "coin": ["BTC", "ETH", "SOL"]} is a single billable subscription charged at the sum of its coins’ rates: 3 x 0.13 = 0.39 credits per minute.
  • Overlapping subscriptions each bill. Holding coin: ["BTC", "ETH"] and coin: "BTC" at the same time gives you two independent streams, both delivering BTC frames, and you pay for both.
On the wallet-activity channels there is no coin field, so the unit is the channel per connection and the address list never changes it. Everything below applies to both families.

Every reconnect costs a new first minute

A new WebSocket session is a new subscription, even if you send byte-identical subscribe messages. So every reconnect pays the one-minute minimum again. This matters most when a connection is flapping. A client that retries every second, holding 50 l2BookDiff coin subscriptions, bills 50 minutes per retry. Sixty retries in a minute bills 3,000 subscription-minutes for 60 seconds of wall-clock time. Two things protect you:
  • Back off exponentially. Start around 1 second and cap at 30 seconds, as in the reconnect sketch below. That bounds a flapping client to roughly 2 reconnects per minute instead of 60.
  • Prefer one long-lived connection. Multiplex every subscription onto it rather than opening and closing sockets per query.

unsubscribe must repeat the exact shape you subscribed with

An unsubscribe only matches a subscription whose coin field is exactly the one you sent on subscribe.
The second message is a silent no-op. Hyperliquid replies Already unsubscribed, the array keeps streaming both coins, and it keeps billing at the full array rate. To drop one coin out of a multi-coin subscription, unsubscribe with the exact array shape and then subscribe again with the subset you want.

Worked example: snapshot-only across 168 coins

Subscribing to l4Book on 168 coins, reading the opening snapshot, and disconnecting after 400 milliseconds bills the full one-minute minimum on all 168: Staying connected for a full 60 seconds costs the same 561 credits. Staying for 61 seconds costs 1,122. Disconnecting and repeating the same snapshot sweep ten times costs 5,610.

Connection management

You’re not rate-limited, but a few client-side defaults are worth tuning.

Reconnect sketch

TypeScript
Python

Watch out for client-side limits

GoldRush has no caps, but the rest of your stack might:
  • OS file descriptor limits - if you’re opening many connections in parallel, raise ulimit -n.
  • Reverse proxy idle timeouts - if you’re terminating WS through nginx, HAProxy, or a cloud load balancer, set the idle timeout above your heartbeat interval (typically 60 seconds minimum).
  • Browser concurrency - browsers limit WebSocket connections per origin; one connection multiplexing many subscriptions is always preferable to many connections.

Network and TLS

  • HTTP/1.1 Upgrade to WSS is supported (standard WebSocket handshake).
  • TLS 1.2+ required.
  • Compression (permessage-deflate) is negotiated when offered by the client.

Need higher guarantees?

Enterprise SLA, dedicated capacity, regional pinning, and on-prem options are all available. Email sales.

WebSocket API Reference

allFills | Hyperliquid WebSocket API

Credit Cost: 1 per minute Processing: Realtime
Tip: Estimate your monthly cost for this API using the Pricing Calculator.
Note: - GoldRush-native: No wss://api.hyperliquid.xyz/ws equivalent.
  • Filters coin and aggregateByTime are both optional. Omit coin to stream every market.
  • Live-only: No historical snapshot on subscribe. For windowed history, use the Info API userFillsByTime.
  • Same per-fill shape as userFills; channel name in messages is allFills.
Subscribe once and receive every fill on HyperCore as it executes, batched per block as [address, fill] tuples. Optional coin filter narrows the stream to a single market; aggregateByTime merges partial fills of the same order in a block.

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

wscat
TypeScript
Python

Unsubscribe

Send the same subscription body with method: "unsubscribe":
Note: Unsubscribe matches subscriptions by exact body. A subscription created with {"type": "allFills", "coin": "BTC"} is a different subscription from a wildcard {"type": "allFills"} - they must be unsubscribed independently.

Streamed message

Each push has channel: "allFills" and a fills array of [address, fill] tuples - every fill from the same HyperCore block that matches the optional coin filter, with the executing wallet as the first element of each tuple.

builderFills

stream live attributed fills for one or more builder addresses in real time.

liquidationFills

stream a global, market-wide feed of every liquidation fill on HyperCore.

userFills

stream real-time trade fills for one or more wallets as they execute on HyperCore.

builderLiquidations

subscribe to real-time liquidation fills of your users. See all Hyperliquid endpoints: Overview hub · WebSocket API reference Last reviewed: 2026-06-19

builderFills | Hyperliquid WebSocket API

Credit Cost: 1 per minute Processing: Realtime
Tip: Estimate your monthly cost for this API using the Pricing Calculator.
Note: - GoldRush-native: No wss://api.hyperliquid.xyz/ws equivalent.
  • Pass builder (string) for a single builder or addresses (string[]) for many. aggregateByTime optional.
  • Live-only: No historical snapshot on subscribe. For windowed history, use the Info API builderFillsByTime.
  • Same per-fill shape as userFills, plus builder and builderFee on every entry; channel name in messages is builderFills.
Subscribe to one builder address (builder) or many (addresses) and receive every fill routed through those builders as they execute, batched per block as [address, fill] tuples. Each fill carries the matched builder address and the corresponding builderFee.

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. Provide either builder (single address) or addresses (array of addresses).

Example

wscat
TypeScript
Python

Unsubscribe

Send the same subscription body with method: "unsubscribe":
Note: Unsubscribe matches subscriptions by exact body. A subscription created with builder: "0xAAA" is a different subscription from one created with addresses: ["0xAAA"], even if they target the same builder. To narrow a multi-builder set, unsubscribe the original list in full, then resubscribe with the smaller list.

Streamed message

Each push has channel: "builderFills" and a fills array of [address, fill] tuples. The first element of each tuple is the trader who executed the fill; the fill object carries the trade details, including the builder it was routed through and the builderFee earned.

Errors

A missing or malformed builder/addresses field returns an error message on the same channel:

builderLiquidations

subscribe to real-time liquidation fills of your users.

allFills

stream every fill on HyperCore in real time for global market analytics and cross-wallet order-flow monitoring.

liquidationFills

stream a global, market-wide feed of every liquidation fill on HyperCore.

userFills

stream real-time trade fills for one or more wallets as they execute on HyperCore. See all Hyperliquid endpoints: Overview hub · WebSocket API reference Last reviewed: 2026-06-19

builderLiquidations | Hyperliquid WebSocket API

Credit Cost: 1 per minute Processing: Realtime
Tip: Estimate your monthly cost for this API using the Pricing Calculator.
Note: - GoldRush-native. builderLiquidations is not exposed on wss://api.hyperliquid.xyz/ws. Pointing a client at the public endpoint with this subscription type will fail.
  • TWAP fills do not carry builder codes. If a user’s last fill before liquidation was a TWAP fill, no builder liquidation notification will be sent.

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. builder is required.

Example

wscat
TypeScript
Python

Unsubscribe

Send the same subscription body with method: "unsubscribe":

Streamed message

Each push keeps the upstream wire shape: type: "builderLiquidations" and a liquidations array of [address, fill] tuples - it is not normalized to the channel/fills shape used by the sibling channels. The address (and mirrored user field) is the wallet whose position was liquidated; liquidation.liquidatedUser repeats it, and builder is the attributed builder code.
Note: TWAP-preceded liquidations are omitted. TWAP fills do not carry builder codes, so if a user’s last fill before liquidation was a TWAP slice, GoldRush cannot attribute the liquidation to a builder and no entry is emitted on this stream. Use the global liquidationFills stream if you need every liquidation regardless of builder attribution.

Errors

A missing or malformed builder field returns an error message:

builderFills

stream live attributed fills for one or more builder addresses in real time.

allFills

stream every fill on HyperCore in real time for global market analytics and cross-wallet order-flow monitoring.

liquidationFills

stream a global, market-wide feed of every liquidation fill on HyperCore.

userFills

stream real-time trade fills for one or more wallets as they execute on HyperCore. See all Hyperliquid endpoints: Overview hub · WebSocket API reference Last reviewed: 2026-07-28

l2BookDiff | Hyperliquid WebSocket API

Credit Cost: 0.1 per coin per minute Processing: Realtime
Tip: Estimate your monthly cost for this API using the Pricing Calculator.
Note: - GoldRush-native. l2BookDiff is not exposed on wss://api.hyperliquid.xyz/ws. Pointing a client at the public endpoint with this subscription type will fail.
  • Snapshot, then diffs. The first message is always a Snapshot; every message thereafter is an Updates. Clients must seed local book state from the snapshot and apply diffs from there. On reconnect, drop local state and re-seed from the next snapshot.
  • coin is optional. Omit it to stream the entire L2 order book across every asset on a single subscription.
  • When coin is omitted, the optional marketTypes filter selects which market families to include. It defaults to ["perp"] only.
  • Pass "marketTypes": ["spot"], or "marketTypes":["outcome"], or a mix (e.g. "marketTypes": ["perp","spot"]), or use the wildcard "marketTypes": ["*"] to opt into spot, perps, outcome, and any future market types.
  • No 1000-subscription-per-IP cap - multiplex hundreds of l2BookDiff subscriptions on a single connection.
  • For OHLCV candles instead of raw book state, use the Streaming API OHLCV streams.
Note: When coin is omitted, a credit rate of 10 credits per minute subscribed is applied.

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

Pick the subscription shape that matches the coverage you want. Every subscription starts with one Snapshot per coin in scope, then per-block Updates carrying only changed levels:
wscat
TypeScript
Python

Unsubscribe

Send the same subscription body with method: "unsubscribe":
Note: Unsubscribe matches subscriptions by exact body. A subscription created with coin: ["BTC", "ETH"] is a different subscription from one created with coin: "BTC" or coin: "ETH".
You cannot unsubscribe a partial set of coins from an existing multi-coin subscription. To narrow the set, unsubscribe the original coin array in full, then resubscribe with the smaller list:

Streamed messages

Every message has channel: "l2BookDiff". The data payload contains exactly one of two variants: a Snapshot (emitted once per subscribed coin, immediately after subscribe) or an Updates (emitted on each subsequent HyperCore block where the book for at least one subscribed coin changed).

Initial snapshot

After subscribe, the server emits one Snapshot message per coin currently in scope. For a single-coin subscription that is one message; for a list or wildcard subscription that is one message per asset. Each entry in levels[0] (bids) and levels[1] (asks) is an aggregated price level, sorted best-first.

Incremental updates

Subsequent messages carry only the levels that changed since the previous block, grouped by coin. A level entry with sz: "0" and n: 0 means the level at that price has been removed; any other entry replaces the current state at that px with the new {sz, n}.

Response fields

l2Book

subscribe to real-time L2 order book snapshots for all Hyperliquid assets over WebSocket.

l2BookDiff2

subscribe to a diff-only L2 order book stream with per-coin sequence numbers and a server epoch for gap detection.

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. See all Hyperliquid endpoints: Overview hub · WebSocket API reference Last reviewed: 2026-06-16

l2BookDiff2 | Hyperliquid WebSocket API

Processing: Realtime
Note: - GoldRush-native. l2BookDiff2 is not exposed on wss://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 a Snapshot frame. Every message is an Updates batch. Seed your local book from the REST l2BookDiffSnapshot info method, then apply diffs on top — see Bootstrapping & gap detection below.
  • 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.
  • coin is optional. Omit it to stream every asset on a single subscription; use marketTypes to 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

wscat
TypeScript
Python

Unsubscribe

Send the same subscription body with method: "unsubscribe":
Note: 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: "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.
Each entry in 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:
  1. Subscribe to l2BookDiff2 for your coin(s) and start buffering the incoming Updates.
  2. Fetch a snapshot for each coin from the REST l2BookDiffSnapshot 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). You may equivalently discard per coin by seq - drop any diff whose seq ≤ the snapshot’s seq - for the tightest alignment.
  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 level, upsert {px, sz, n}, or remove the price when sz is "0".
  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.
Tip: The seq/prev_seq are per coin, tracked within the current epoch. Compare them per coin, not globally across the batch.

Response fields

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. See all Hyperliquid endpoints: Overview hub · WebSocket API reference

l2Book | Hyperliquid WebSocket API

Credit Cost: 0.5 per coin per minute Processing: Realtime
Tip: Estimate your monthly cost for this API using the Pricing Calculator.
Note: - Wire-compatible with wss://api.hyperliquid.xyz/ws l2Book subscriptions - same channel name, same levels shape.
  • coin is optional on GoldRush. Omit it to stream the entire L2 order book across every asset on a single subscription. The public Hyperliquid API requires coin and locks each subscription to one asset at a time.
  • When coin is omitted, the optional marketTypes filter selects which market families to include. It defaults to ["perp"] only.
  • Pass "marketTypes": ["spot"], or "marketTypes":["outcome"], or a mix (e.g. "marketTypes": ["perp","spot"]), or use the wildcard "marketTypes": ["*"] to opt into spot, perps, outcome, and any future market types.
  • No 1000-subscription-per-IP cap - multiplex hundreds of l2Book subscriptions on a single connection.
  • For OHLCV candles instead of raw book state, use the Streaming API OHLCV streams.
Note: When coin is omitted, a credit rate of 50 credits per minute subscribed is applied.

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

Pick the subscription shape that matches the coverage you want:
wscat
TypeScript
Python

Unsubscribe

Send the same subscription body with method: "unsubscribe":
Note: Unsubscribe matches subscriptions by exact body. A subscription created with coin: ["BTC", "ETH"] is a different subscription from one created with coin: "BTC" or coin: "ETH".
You cannot unsubscribe a partial set of coins from an existing multi-coin subscription. To narrow the set, unsubscribe the original coin array in full, then resubscribe with the smaller list:

Streamed message

Each message has channel: "l2Book" and a data payload with the current book snapshot for the subscribed coin.

l2BookDiff

subscribe to real-time L2 order book (initial snapshot + diffs) for all Hyperliquid assets over WebSocket.

l2BookDiff2

subscribe to a diff-only L2 order book stream with per-coin sequence numbers and a server epoch for gap detection.

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. See all Hyperliquid endpoints: Overview hub · WebSocket API reference Last reviewed: 2026-07-28

l4BookUpdates | Hyperliquid WebSocket API

Credit Cost: 1 per coin per minute Processing: Realtime
Note: - 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

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

wscat
TypeScript
Python

Unsubscribe

Send the same subscription body with method: "unsubscribe":
Note: 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": "" } } — a newly resting order.
  • { "update": { "origSz": "", "newSz": "" } } — 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.
Tip: The seq/prev_seq are per coin, tracked within the current epoch. Compare them per coin, not globally across the batch.

Response fields

l4Book

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

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.

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

l4Book | Hyperliquid WebSocket API

Credit Cost: 3 per coin per minute (except BTC which is 60 per minute) Processing: Realtime
Tip: Estimate your monthly cost for this API using the Pricing Calculator.
Note: - GoldRush-native. l4Book is not exposed on wss://api.hyperliquid.xyz/ws. Pointing a client at the public endpoint with this subscription type will fail.
  • Perps only. No spot assets.
  • coin is required. Unlike l2Book and l2BookDiff, you cannot omit coin to stream every asset. Open one subscription per asset.
  • Snapshot, then diffs. The first message is always a Snapshot; every message thereafter is an Updates. Clients must seed local book state from the snapshot and apply diffs from there. On reconnect, drop local state and re-seed from the next snapshot.
  • Per-order detail. Each entry exposes user, oid, cloid, tif, and trigger metadata - enabling queue-position reconstruction, per-trader flow attribution, and microstructure analytics that are not possible with l2Book.
  • See the L4 Order Book recipe for patterns to maintain book state, attribute flow by user, or reconstruct aggregated price levels.
Note: When "coin":"BTC" is used, a credit rate of 60 credits per minute subscribed is applied.

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

wscat
TypeScript
Python

Unsubscribe

Send the same subscription body with method: "unsubscribe":

Streamed messages

Every message has channel: "l4Book". The data payload contains exactly one of two variants: a Snapshot (emitted once, immediately after subscribe) or an Updates (emitted on each subsequent HyperCore block where the book for coin changed).

Initial snapshot

The first message after subscribe carries the full resting book at the current block. Each entry in levels[0] (bids) and levels[1] (asks) is an individual order - not an aggregated price level.

Incremental updates

Subsequent messages carry only what changed since the previous block. order_statuses describes order lifecycle events (open, etc.); book_diffs carries the corresponding price-level changes.

Response fields

Order object

The Order type appears inside Snapshot.levels[*][*] and Updates.order_statuses[*].order.

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.

l2BookDiff2

subscribe to a diff-only L2 order book stream with per-coin sequence numbers and a server epoch for gap detection.

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. See all Hyperliquid endpoints: Overview hub · WebSocket API reference Last reviewed: 2026-06-24

liquidationFills | Hyperliquid WebSocket API

Credit Cost: 1 per minute Processing: Realtime
Tip: Estimate your monthly cost for this API using the Pricing Calculator.
Note: - GoldRush-native: No wss://api.hyperliquid.xyz/ws equivalent. The public WebSocket exposes per-wallet fills only; detecting liquidations there would require subscribing to every wallet and filtering.
  • Global stream: Every liquidation fill on HyperCore, across every wallet, on a single subscription. No addresses filter is accepted.
  • Every fill in this stream carries a non-null liquidation object. The rest of the payload mirrors userFills.
  • Live-only: No historical snapshot on subscribe. For historical liquidations, query the Streaming API HypercoreLedgerEvent type.
Subscribe with no addresses filter to receive every liquidation fill on HyperCore across every wallet, in real time. Same payload shape as userFills, with the liquidation object populated (with liquidatedUser, markPx, method) on every entry.

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

wscat
TypeScript
Python

Unsubscribe

Send the same subscription body with method: "unsubscribe":

Streamed message

Each push has channel: "liquidationFills" and a fills array of [address, fill] tuples. The address is the wallet whose order was filled (i.e. the liquidator’s counterparty); liquidation.liquidatedUser is the wallet whose position was liquidated.

allFills

stream every fill on HyperCore in real time for global market analytics and cross-wallet order-flow monitoring.

builderFills

stream live attributed fills for one or more builder addresses in real time.

userFills

stream real-time trade fills for one or more wallets as they execute on HyperCore.

builderLiquidations

subscribe to real-time liquidation fills of your users. See all Hyperliquid endpoints: Overview hub · WebSocket API reference Last reviewed: 2026-06-16

orderUpdates | Hyperliquid WebSocket API

Credit Cost: 1 per minute Processing: Realtime
Tip: Estimate your monthly cost for this API using the Pricing Calculator.
Note: - Wire-compatible with wss://api.hyperliquid.xyz/ws orderUpdates subscription - same channel name, same per-update shape.
  • Up to 1,000 wallet addresses per subscription. Use addresses (string[]); aliases user(string) and users (string[]) are also accepted.
  • Messages are batched per HyperCore block; each push carries one or more updates entries, each with its own user field. Subscribe many wallets and receive one push per block containing every matching wallet’s events.
  • Live-only — no historical snapshot of resting orders on subscribe. For the current resting-order set, use the Info API  frontendOpenOrders. For historical fills, use userFillsByTime.
  • No 1,000-subscription-per-IP cap. Multiplex many orderUpdates subscriptions on a single connection.
Subscribe to one or more wallets and receive their live order status updates the moment they change when an order is placed, filled, canceled, or rejected. The server batches one push per HyperCore block, carrying every matching update as an updates array of objects, each tagged with the originating user. Supports up to 1,000 wallet addresses per subscription.

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

wscat
TypeScript
Python

Unsubscribe

Send the same subscription body with method: "unsubscribe":
Note: Unsubscribe matches subscriptions by exact body. A subscription created with addresses: ["0xAAA", "0xBBB"] is a different subscription from two single-address subscriptions. To narrow the set, unsubscribe the original list in full, then resubscribe with the smaller list.

Streamed message

Each push has channel: "orderUpdates" and an updates array of objects - every order lifecycle event from the same HyperCore block that matches any subscribed wallet. Each entry is self-tagged with the originating user.

userNonFundingLedgerUpdates

stream real-time non-funding ledger events (deposits, withdrawals, vault and staking activity) for one or more…

userFills

stream real-time trade fills for one or more wallets as they execute on HyperCore.

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. See all Hyperliquid endpoints: Overview hub · WebSocket API reference Last reviewed: 2026-06-18

userFills | Hyperliquid WebSocket API

Credit Cost: 1 per minute Processing: Realtime
Tip: Estimate your monthly cost for this API using the Pricing Calculator.
Note: - Wire-compatible with wss://api.hyperliquid.xyz/ws userFills subscription - same channel name, same per-fill shape.
  • Up to 1,000 wallet addresses per subscription. Use addresses (string[]); aliases user(string) and users (string[]) are also accepted.
  • Messages are batched per HyperCore block as [address, fill] tuples; subscribe many wallets, receive one push per block per wallet that had activity.
  • Live-only - no historical snapshot on subscribe. For windowed history, use the Info API userFillsByTime.
  • No 1,000-subscription-per-IP cap. Multiplex many userFills subscriptions on a single connection.
Subscribe to one or more wallets and receive their live trade fills the moment they execute. The server batches one push per HyperCore block, carrying every matching fill as [address, fill] tuples. Supports up to 1,000 wallet addresses per subscription.

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

wscat
TypeScript
Python

Unsubscribe

Send the same subscription body with method: "unsubscribe":
Note: Unsubscribe matches subscriptions by exact body. A subscription created with addresses: ["0xAAA", "0xBBB"] is a different subscription from two single-address subscriptions. To narrow the set, unsubscribe the original list in full, then resubscribe with the smaller list.

Streamed message

Each push has channel: "userFills" and a fills array of [address, fill] tuples - all fills from the same HyperCore block that match any subscribed wallet.

userNonFundingLedgerUpdates

stream real-time non-funding ledger events (deposits, withdrawals, vault and staking activity) for one or more…

allFills

stream every fill on HyperCore in real time for global market analytics and cross-wallet order-flow monitoring.

builderFills

stream live attributed fills for one or more builder addresses in real time.

liquidationFills

stream a global, market-wide feed of every liquidation fill on HyperCore.

builderLiquidations

subscribe to real-time liquidation fills of your users.

orderUpdates

stream real-time order lifecycle events (placements, fills, cancels, and rejections) for one or more wallets on HyperCore. See all Hyperliquid endpoints: Overview hub · WebSocket API reference Last reviewed: 2026-06-16

userNonFundingLedgerUpdates | Hyperliquid WebSocket API

Credit Cost: 1 per minute Processing: Realtime
Tip: Estimate your monthly cost for this API using the Pricing Calculator.
Note: - Wire-compatible with wss://api.hyperliquid.xyz/ws userNonFundingLedgerUpdatessubscription - same channel name, same delta shape per event.
  • Up to 1,000 wallet addresses per subscription. Use addresses (string[]); aliases user(string) and users (string[]) are also accepted.
  • Covers everything that moves USDC or token balances except funding payments - deposits, withdrawals, transfers, liquidations, vault actions, staking, rewards.
  • Live-only: isSnapshot is always false on this transport. For windowed history, use the Info API userNonFundingLedgerUpdates.
Subscribe to one or more wallets and receive every non-funding ledger event in real time: deposits, withdrawals, transfers, liquidations, vault deposits/withdrawals, staking, rewards, and more. Each push carries a list of {time, hash, delta} entries where delta.type identifies the event class and the remaining delta fields are type-specific. Supports up to 1,000 wallet addresses per subscription.

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

wscat
TypeScript
Python

Unsubscribe

Send the same subscription body with method: "unsubscribe":
Note: Unsubscribe matches subscriptions by exact body. To narrow the wallet set, unsubscribe the original addresses list in full, then resubscribe with the smaller list.

Streamed message

Each push has channel: "userNonFundingLedgerUpdates" and a data object keyed to a single wallet. Multi-wallet subscriptions receive one push per affected wallet.

Delta types

delta.type is one of: The remaining keys on delta vary by type and follow the public Hyperliquid info API userNonFundingLedgerUpdates payload. Common fields include amount (decimal string), usdcValue (decimal string), coin (string), destination / source (address strings), and nativeTokenFee (decimal string).

userFills

stream real-time trade fills for one or more wallets as they execute on HyperCore.

orderUpdates

stream real-time order lifecycle events (placements, fills, cancels, and rejections) for one or more wallets on HyperCore.

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. See all Hyperliquid endpoints: Overview hub · WebSocket API reference Last reviewed: 2026-06-17

Recipes

The l2Book channel on wss://hypercore.goldrushdata.com/ws?key= is wire-equal to the public Hyperliquid feed but with coin made optional and the per-IP subscription cap removed. This recipe shows how to turn that stream into common trading and analytics building blocks. For the raw subscription shape see the l2Book reference; for the connection model see the WebSocket API overview.

What you get

  • Complete snapshots, not diffs. Every l2Book message contains the current time, coin, and a full [bids, asks] tuple in best-first order, with px / sz / n per level. Consume each message in isolation - no sequence numbers to track, no diff replay buffer, no REST snapshot to bootstrap.
  • Self-healing on packet loss. Drop a message, reconnect mid-session, or restart your process - the next message arrives with the full book state, so your in-memory view is correct on the very next tick.
  • Upstream-compatible aggregation knobs. nSigFigs accepts 2, 3, 4, 5, or null (full precision). mantissa accepts 1, 2, or 5, and is only valid when nSigFigs is 5.
  • Wildcard coverage. Omit coin to stream every asset’s book over a single subscription, instead of fanning out one subscription per asset. The wildcard defaults to perps only (marketTypes: ["perp"]); pass ["spot"], ["outcome"], a mix, or ["*"] to opt into spot, outcome, and future market types.

Subscribe and hold book state

The pattern below keeps a Map in memory. Each incoming message replaces the entry for its coin, so the map is always current and never needs reconciliation.
TypeScript
Python

Patterns

Top-of-book tracker

Read bids[0] and asks[0] directly from each message. The spread is Number(asks[0].px) - Number(bids[0].px). No state required - every message is self-contained, so a single-line transformation gives you a live ticker.

Depth-weighted mid quote

Sum px * sz across the first K levels on each side, then average. This produces a fair-value mid that’s robust to thin top-of-book liquidity, and is useful as a hedging or pricing reference.
TypeScript

Slippage / impact estimator

Walk levels on the relevant side until cumulative sz covers the requested notional. Return the size-weighted average fill price - the difference vs the top-of-book is your expected slippage.
TypeScript

Liquidity heatmap

On each message, append [time, coin, side, px, sz] rows to your time-series store (Clickhouse, TimescaleDB, Parquet). Because every message is a complete snapshot of the top levels, the heatmap rebuilds correctly from any contiguous slice of history - you don’t need a separate “initial book” record to seed the visualisation.

Handling reconnects

Reconnect logic is a one-liner: open a new socket and resend the same subscribe payload. The first message after subscribe is a full book snapshot, so your books map is correct on the next tick - there’s nothing to replay, nothing to buffer, and no sequence numbers to reconcile against a separately-fetched REST snapshot.
TypeScript
  • l2Book API reference - full subscription and message schema.
  • WebSocket API overview - endpoint URL, auth, and limits.
  • clearinghouseState - pair the live book with per-account position and margin state.
  • HIP-3 markets OHLCV recipe - candles instead of raw book state.

The l2BookDiff channel on wss://hypercore.goldrushdata.com/ws?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 Snapshot per subscribed coin on subscribe, then per-block Updates containing only the levels that changed. Apply diffs to local state.
  • Aggregated {px, sz, n} shape. Identical to l2Book levels - reuse your existing aggregated-book types and just add a level-apply function.
  • Multi-coin / wildcard friendly. coin accepts a single asset, an array of assets, or can be omitted to stream every asset on one subscription. When coin is omitted, marketTypes defaults to ["perp"] - pass ["spot"], ["outcome"], a mix, or ["*"] to opt into spot, outcome, and future market types. l4Book is one-coin-per-subscription; l2Book requires 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 - l2Book is full-snapshot only.

Subscribe and maintain book state

The pattern below keeps a Map, asks: Map }>. 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}.
TypeScript
Python

Patterns

Single coin, list, or wildcard

All three subscription shapes share the same handler - only the payload sent at subscribe time changes. Use whichever matches your coverage requirements.
TypeScript
A list or wildcard subscription receives one 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 highest px 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
  • l2BookDiff API reference - full subscription, snapshot, and update schema.
  • l2Book reference - full-snapshot transport when diff replay isn’t desirable.
  • l4Book reference - order-level stream with user, oid, cloid, tif, and trigger metadata.
  • WebSocket API overview - endpoint URL, auth, and limits.

The l4Book channel on wss://hypercore.goldrushdata.com/ws?key= is a GoldRush-exclusive stream - it has no equivalent on wss://api.hyperliquid.xyz/ws. After subscribing, the server sends a single Snapshot of every resting order, then per-block Updates carrying lifecycle events and per-order book changes. Each order arrives with its user, oid, cloid, tif, and trigger metadata, so you can reconstruct queue position and price-time priority, attribute flow to specific wallets, and run microstructure analytics that l2Book’s aggregated {px, sz, n} view hides. For the raw subscription shape see the l4Book reference; for the connection model see the WebSocket API overview.

What you get

  • Per-order visibility. Every level in the snapshot is an individual order keyed by oid, with user, cloid, tif, orderType, and trigger metadata attached. l2Book only exposes {px, sz, n} per price level.
  • Snapshot + diff transport. One full Snapshot on subscribe, then per-block Updates containing order_statuses (lifecycle events) and book_diffs (per-order changes). Apply diffs to local state.
  • Per-block cadence. Updates fire on each HyperCore block where the book for the subscribed coin changed. The time and block_height fields anchor each message to a specific block.
  • GoldRush-exclusive. Not available on the public Hyperliquid WebSocket - this stream surfaces user attribution and per-order metadata the public feed never exposes.
  • One coin per subscription. Unlike l2Book, coin is required. To cover multiple assets, open one l4Book subscription per asset on the same connection.

Subscribe and maintain book state

The pattern below keeps a Map per coin. The snapshot seeds the map; each Updates message applies book_diffs against it. Reconnects drop the map and re-seed from the next snapshot.
TypeScript
Python

Patterns

Track individual orders by oid

oid is the Hyperliquid order id, stable for the lifetime of the order - use it as the primary key in your local map. cloid is the client-supplied id (may be null); index on it when you need to correlate fills back to a specific trading bot’s instructions.

Per-user flow attribution

Every order entry carries user. Group orders by wallet to surface market-maker behavior, identify spoofing patterns, or build a per-trader heatmap of resting size. Pair this with clearinghouseState for per-user position and margin context.
TypeScript

Reconstruct aggregated price levels

If a downstream consumer expects an l2Book-style aggregated view, sum sz across all orders sharing a limitPx on the same side. Going the other way isn’t possible - l2Book collapses the per-order detail you’d lose.
TypeScript

Handling reconnects

On reconnect, resend the same subscribe payload. The first message back is always a fresh Snapshot - drop your local orders map and re-seed from it. Do not attempt to replay missed Updates - the snapshot is authoritative and supersedes anything you held before the disconnect. Back off exponentially between attempts. A reconnect opens a new session, and a new session is a new subscription that re-pays the one-minute minimum, so a fixed one-second retry against a flapping connection bills a minute of l4Book every second.
TypeScript

Billing

l4Book bills per coin, per minute, in whole minutes. There is no proration and no partial minute.
Warning: The minimum charge is one full minute. Sending subscribe charges the first minute immediately, before the Snapshot is delivered. Subscribing, reading the snapshot, and disconnecting 400 ms later still costs a full minute per coin.
After the first minute, the total is ceil(seconds_subscribed / 60) counted from the moment you subscribed. 60 seconds bills 1 minute; 61 seconds bills 2. Because coin is required, every coin you track is its own billable subscription. A snapshot-only sweep across 168 coins costs 60 + (167 x 3) = 561 credits whether the connection lives 400 milliseconds or a full 60 seconds. Repeating that sweep ten times costs ten times as much. For the rest of the model - what counts as one subscription, why reconnects are not free, and the unsubscribe shape-matching rule - see Billing on the rate limits page. The same rules apply to every order-book channel, and the whole-minute rounding applies to the wallet-activity channels too.
  • l4Book API reference - full subscription, snapshot, and update schema.
  • l2Book reference - aggregated price-level snapshots when per-order detail isn’t needed.
  • WebSocket API overview - endpoint URL, auth, and limits.
  • Billing - the whole-minute model shared by every WebSocket channel.
  • clearinghouseState - pair per-user resting orders with position and margin state.