Streams referenceQuickNode-compatible

L4 Order Book

The full order-by-order book: every resting order with its owner.

Every individual resting order, attributed to its wallet. Starts with a complete book snapshot, then per-block diffs. This is the microstructure surface: queue position, order ownership, and full reconstruction at any block.

Method
hyperliquid.OrderBookStreaming/StreamL4Book
Endpoint
stream.hyperliquidrpc.com:443 · gRPC over TLS (HTTP/2)
Auth
API key in x-api-key metadata
Volume
High volume on liquid markets. This is the full order flow behind 725M+ order updates/day, so budget bandwidth accordingly or filter to specific coins.

When to use it

The L4 book is the microstructure surface: every resting order, attributed to its wallet. Use it when aggregated levels are not enough: queue-position models, toxicity and spoofing detection, tracking which market makers are present at which prices, or reconstructing the exact book your strategy would have seen at any block.

It is strictly more information than L2 at strictly more cost: snapshots are large and liquid markets churn constantly. If you only price against depth, stay on the L2 book and keep your bandwidth bill small.

Method

// stream.hyperliquidrpc.com:443 — gRPC over TLS (HTTP/2)// auth: API key in x-api-key metadata · server reflection enabledpackage hyperliquid; service OrderBookStreaming {  // Complete order-by-order snapshot first, then per-block diffs.  rpc StreamL4Book (L4BookRequest) returns (stream L4BookUpdate);}

Wire-compatible with QuickNode's order-book proto. The first message is the complete book for the coin; every subsequent message is the set of order-level changes for one block.

Subscribe

# Streams JSON-encoded messages until you disconnect.grpcurl -H 'x-api-key: YOUR_KEY' \  -max-msg-sz 268435456 \  -d '{"coin":"BTC"}' \  stream.hyperliquidrpc.com:443 \  hyperliquid.OrderBookStreaming/StreamL4Book

Message fields

FieldTypeDescription
oiduint64Order id of the resting order.
userstringOwner's wallet address.
coinstringMarket symbol.
sidestringB (bid) or A (ask).
pxstringLimit price.Byte-exact decimal string.
szstringRemaining size.Byte-exact decimal string.
diffs[].typeenumNEW / UPDATE / REMOVE per-block change.

Fields typed string that carry numbers are byte-exact decimal strings, verbatim from the node. Compare and store them as strings or arbitrary-precision decimals. Never parseFloat a price you intend to reconcile.

Server-side filters

  • coin: required, one market per subscription
  • replay from a block height

Filters are applied on the server, so filtered-out messages never leave our edge. You only pay for what you subscribe to. Request shapes for every stream family are on Filtering; backfill semantics on Replay & backfill.

Semantics & gotchas

Snapshot + diffs: the first message is the complete order-by-order book; each block then delivers the set of order-level changes. Full snapshots can be large; set max receive size ≥256 MB.

  • Apply diffs in block order, against the snapshot. NEW inserts an order, UPDATE replaces its remaining size, REMOVE deletes it by oid. Key your local state on oid and the book stays exact.
  • One coin per subscription. Like the L2 book, the request takes a single coin. Subscribe per market and budget bandwidth for the liquid ones.
  • On reconnect, resync from a fresh snapshot. A new subscription always begins with a complete snapshot, so the cheapest recovery from any gap is to resubscribe and replace local state. For gap-free history, replay from a height instead. See Replay & backfill.
  • This is the firehose behind 725M+ order updates a day. Liquid markets produce sustained high-rate diffs. Consume on a dedicated thread/task and avoid per-message allocations in hot paths.

Sample message

{  "coin": "BTC",  "block_height": 612408134,  "is_snapshot": false,  "diffs": [    {      "type": "NEW",      "order": {        "oid": 91834221299,        "user": "0x2f8a91be6cda04417e3c50f1a7b9d20c1e664b07",        "side": "A",        "px": "67018.0",        "sz": "0.75000"      }    },    { "type": "REMOVE", "oid": 91834219841 }  ]}

High volume on liquid markets. This is the full order flow behind 725M+ order updates/day, so budget bandwidth accordingly or filter to specific coins.

Recipes

Maintain a local order-by-order book

Hold a dict keyed by oid; apply each diff in the order received. Sorting bids and asks by px on demand reproduces the exact ladder, with owners, at every block.

book = {}  # oid -> order for msg in stub.StreamL4Book(request, metadata=meta):    if msg.is_snapshot:        book = {o.oid: o for o in msg.orders}        continue    for d in msg.diffs:        if d.type == "REMOVE":            book.pop(d.oid, None)        else:  # NEW / UPDATE            book[d.order.oid] = d.order

Estimate your queue position

At a price level, size resting ahead of your order is the sum of sz for orders at the same px that entered the book before yours. Track insertion order as diffs arrive and you get a live queue-position estimate per oid.

Watch a market maker's quotes

Every order carries its owner's wallet. Filter your local book by user to see one firm's live quote set: widths, sizes, and how fast they re-quote after trades.

MAKER = "0x2f8a91be6cda04417e3c50f1a7b9d20c1e664b07" quotes = [o for o in book.values() if o.user == MAKER]

Related