New to Hyperliquid’s architecture? Read
HyperCore vs. HyperEVM
first — this guide covers the HyperCore side (order book data), not the
EVM JSON-RPC side.
1. Connect
Open a WebSocket to Uniblock’s GoldRush endpoint. Authenticate with theX-API-KEY header (recommended) or an apiKey query parameter.
2. Subscribe to the order book
Send asubscribe message once the connection is open. The example below
subscribes to l2BookDiff — lightweight per-block order book diffs — for a
single asset.
- Pass a single asset (
"HYPE") or an array (["HYPE", "BTC"]) ascoin. - Omit
cointo stream all assets — but note the wildcard stream is billed at a much higher per-minute rate.
3. Handle snapshot and diff messages
Forl2BookDiff, the first message per coin is a full Snapshot; subsequent
messages are per-block Updates containing only the changed levels.
px
with the new sz/n, and delete the level when sz is "0".
4. Unsubscribe
Stop a stream by sending anunsubscribe message with the exact same
subscription body you subscribed with. Billing for that subscription stops as
soon as it’s removed.
Other subscription types
l2BookDiff is one of several HyperCore streams available on the same
connection. Swap the type (and, for account streams, follow GoldRush’s
per-type payload) to subscribe to:
l2Book— full L2 order book snapshots and updates.l4Book— full per-order (L4) book.userFills,orderUpdates,liquidationFills,allFills,builderFills,userNonFundingLedgerUpdates— account and venue event streams.
Best practices
- Keep-alive: send a ping every 30–60 seconds to avoid idle timeouts.
- Reconnect with backoff: on disconnect, re-open and re-send your subscriptions using exponential backoff.
- Scope your subscriptions: subscribe per
coininstead of the wildcard stream when you only need a handful of assets — it’s dramatically cheaper.