Skip to content
Alchemy Logo

l2Book stream

Beta

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

Aggregated price levels for each market: a complete window of the top of the book, sent whenever it changes.

{
  "method": "subscribe",
  "subscriptionId": "l2_01",
  "subscription": {
    "type": "l2Book",
    "coins": [
      "BTC",
      "ETH"
    ],
    "nLevels": 20
  }
}

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.
nSigFigsintegerNoGroup prices to 2–5 significant figures. Omit for exact prices.
mantissaintegerNo1, 2, or 5. Only with nSigFigs: 5; default 1.
nLevelsintegerNoLevels per side: 1, 10, 20 (default), or 50.

{
  "channel": "subscriptionResponse",
  "subscriptionId": "l2_01",
  "data": {
    "type": "l2Book",
    "coins": [
      "BTC",
      "ETH"
    ],
    "nLevels": 20
  }
}

{
  "seq": 1,
  "channel": "l2Book",
  "subscriptionId": "l2_01",
  "data": {
    "blockNumber": 1183759643,
    "blockTime": 1791999593526,
    "isSnapshot": true,
    "books": [
      {
        "coin": "BTC",
        "levels": [
          [
            {
              "px": "81772.0",
              "sz": "30.29109",
              "n": 96
            },
            {
              "px": "81770.0",
              "sz": "4.7457",
              "n": 9
            }
          ],
          [
            {
              "px": "81773.0",
              "sz": "0.02692",
              "n": 2
            },
            {
              "px": "81774.0",
              "sz": "1.2",
              "n": 3
            }
          ]
        ]
      }
    ]
  }
}
FieldDescription
data.isSnapshottrue on the first message after subscribing.
data.books[]One entry per market whose window changed in this block. The first message includes every subscribed market.
data.books[].levels[bids, asks]. Bids are sorted high to low, asks low to high.
px, sz, nPrice, total size at the level, and number of orders.
data.nSigFigs, data.mantissaPresent when you requested price grouping.

Every entry is a complete window for its market, so you can replace your view of that market with it. Markets that didn't change aren't included.

For a live book with less data, use l2BookDiff.

{"method":"unsubscribe","subscriptionId":"l2_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?