Skip to content
Alchemy Logo

l4BookUpdates stream

Beta

HyperCore APIs are in beta. Message fields, limits, and behavior may change, including breaking changes. To request access, contact [email protected].

The order-level book: every resting order, then each order that is added, resized, or removed.

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

ParameterTypeRequiredDescription
coinsstring[]NoMarkets to include, up to 200. Omit, or send [], for every market (one unfiltered subscription per stream per connection). Unknown coins stay subscribed and return empty data until the market exists.

{
  "channel": "subscriptionResponse",
  "subscriptionId": "l4_01",
  "data": {
    "type": "l4BookUpdates",
    "coins": [
      "ETH"
    ]
  }
}

The first message (isSnapshot: true) lists every resting order in the subscribed markets as a new diff. Later messages carry the changes in each block:

{
  "seq": 2,
  "channel": "l4BookUpdates",
  "subscriptionId": "l4_01",
  "data": {
    "blockNumber": 1183759644,
    "blockTime": 1791999593590,
    "isSnapshot": false,
    "diffs": [
      {
        "type": "new",
        "coin": "ETH",
        "oid": 574446008493,
        "user": "0x67f7aa8fb95c47e6ea9c517b623e0701cbf9d9ba",
        "side": "B",
        "px": "2436.0",
        "sz": "1.1853",
        "insertBefore": 574446008411
      },
      {
        "type": "update",
        "coin": "ETH",
        "oid": 574446008100,
        "sz": "0.5"
      },
      {
        "type": "remove",
        "coin": "ETH",
        "oid": 574446007990
      }
    ]
  }
}
DiffFieldsMeaning
newcoin, oid, user, side, px, sz, optional insertBeforeA new resting order.
updatecoin, oid, szThe order's remaining size changed, usually from a partial fill.
removecoin, oidThe order left the book (filled or cancelled).

side is B (bid) or A (ask). insertBefore places the new order immediately ahead of that order in the price level's queue; when it's absent, add the order at the back of the queue.

  1. On isSnapshot: true, replace your local orders for the subscribed markets.
  2. Apply new, update, and remove in the order received.
  3. Check that seq increases by one. If it skips, resubscribe and start from the new snapshot.

Summing sz and counting orders at each price gives the same levels as an exact-price l2Book.

An unfiltered l4BookUpdates snapshot covers every resting order on HyperCore and can be tens of megabytes. Size your receive buffers accordingly, or filter by coins.

{"method":"unsubscribe","subscriptionId":"l4_01"}

Book streams have no replay. After a disconnect, or if seq skips, resubscribe; the first message is a fresh snapshot. If you receive a book_reset error, drop local state for the subscription and rebuild from the snapshot that follows. See replay and recovery.

Was this page helpful?