l4BookUpdates

Stream real-time L4 orderbook updates per block.

💧 New endpoint - this endpoint is not a part of original Hyperliquid API and is added by us for builder convenience.

Subscribe

{
    "method": "subscribe",
    "subscription": {
        "type": "l4BookUpdates",
        "coins": ["ETH", "BTC"]
    }
}

Parameters:

Parameter
Type
Required
Description

coins

string[]

No

Coins to subscribe to. Omit for all markets (needs l4BookUpdatesAll add-on).

marketTypes

string[]

No

All-markets only. Filters delivery by market type — see All-markets filter. Rejected if combined with coins.

All-markets filter

When coins is omitted, the optional marketTypes field restricts the firehose to specific market types. Each entry is "perp", "spot", "outcome", or the wildcard "*" (alone) for "every type the server currently tracks":

{
    "method": "subscribe",
    "subscription": {
        "type": "l4BookUpdates",
        "marketTypes": ["perp", "outcome"]
    }
}

Omitting marketTypes defaults to ["perp"] — outcome and spot markets do not appear unless you opt in. The default never grows; new market types must be added to your marketTypes array explicitly. Pass ["*"] to auto-opt-in to future types.

A second subscribe with a different marketTypes value replaces the previous filter rather than coexisting with it.

Unsubscribe

Update data format

Updates are streamed per-block with order changes for subscribed markets:

Diff types

Type
Description
Fields

new

New order placed

coin, oid, user, side, px, sz

update

Order size changed (partial fill)

coin, oid, sz

remove

Order removed (filled/cancelled)

coin, oid

Field definitions

Field
Type
Description

height

int

Block height

timestamp

int

Block timestamp (ms since epoch)

coin

string

Market symbol (e.g., "ETH", "BTC")

oid

int

Unique order ID

user

string

User address (0x...)

side

string

"B" = bid, "A" = ask

px

string

Price as decimal string

sz

string

Size as decimal string

Examples

Common errors

  1. Too many coins - Reduce number of coins or upgrade tier

  2. Subscribing to all markets requires permission - Needs add-on for all books

  3. Rate limit exceeded - Reduce subscription frequency

  4. Authentication failed - Check API key

Last updated