L2 Grouped

l2:perps:grouped

Price-bucketed depth snapshot. Prices are floored to the nearest bucket boundary (e.g., 2495.37 at bucket 0.5 becomes 2495.0). Includes cumulative depth for depth chart rendering. Published every 250ms when the book has updates.

Channel: l2:perps:grouped:{bucket}:{instrument} Example: l2:perps:grouped:0.5:ETH_USDC-PERPETUAL

Payload

{
  "timestamp": 1704067200000,
  "bids": [
    ["2495", "15000.5", "15000.5"],
    ["2494.5", "8200", "23200.5"]
  ],
  "asks": [
    ["2495.5", "12000", "12000"],
    ["2496", "9500", "21500"]
  ]
}
FieldTypeDescription
timestampintegerUnix timestamp in milliseconds
bidsarrayBid levels, best (highest) first. Each: [price, amount, cumulative]
asksarrayAsk levels, best (lowest) first. Each: [price, amount, cumulative]

Level array elements:

IndexTypeDescription
0stringBucket boundary price (floored)
1stringTotal amount at this bucket (notional USD)
2stringCumulative amount from best to this level

Available Buckets

InstrumentBuckets
ETH_USDC-PERPETUAL0.1, 0.2, 0.5, 1, 10, 100
BTC_USDC-PERPETUAL1, 2, 5, 10, 100, 1000
sub.on("publication", (ctx) => {
  const { timestamp, bids, asks } = ctx.data;
  // Each level: [bucketPrice, amount, cumulativeAmount]
  for (const [price, amount, cumulative] of bids) {
    // price, amount, cumulative are all strings
  }
});

Recovery

Subscribe with since: {} to receive the last cached snapshot as the first publication, before any live updates. On reconnect, the SDK automatically recovers the latest snapshot.