GetOrderbook

Get a snapshot of the L2 orderbook for a specific market. Returns aggregated price levels with total size at each level.

GETGetOrderbookPublic

Returns the current orderbook state for a market. Bids are sorted descending by price, asks are sorted ascending.

Request

ParameterType
market_idrequireduint32
depthoptionaluint32

Response

FieldType
successbool
market_iduint32
bidsPriceLevel[]
asksPriceLevel[]
timestampuint64
sequenceuint64

Example

Requesttypescript
const orderbook = await client.getOrderbook('RLM-PERP', { depth: 10 });
console.log('Best bid:', orderbook.bids[0]?.price);
console.log('Best ask:', orderbook.asks[0]?.price);
console.log('Spread:', orderbook.asks[0]?.price - orderbook.bids[0]?.price);
// Process all levels
for (const bid of orderbook.bids) {
console.log(`Bid: ${bid.price} x ${bid.size}`);
}
Responsejson
{
"success": true,
"marketId": 0,
"bids": [
{ "price": 99.50, "size": 10.5 },
{ "price": 99.00, "size": 25.0 },
{ "price": 98.50, "size": 50.0 }
],
"asks": [
{ "price": 100.00, "size": 8.0 },
{ "price": 100.50, "size": 15.0 },
{ "price": 101.00, "size": 30.0 }
],
"timestamp": 1704067200000000000,
"sequence": 12345678
}

PriceLevel Structure

FieldTypeDescription
priceint64Price level (8 decimals)
sizeint64Total size at this level (8 decimals)

Usage Notes

  • L2 aggregation — Orders at the same price are combined into a single level. You see total size, not individual orders.
  • Sequence numbers — Use the sequence field to detect gaps when processing streaming updates.
  • Depth limits — Maximum depth is 100 levels per side. Default is 20.

Real-time Updates

For real-time orderbook updates, use the Subscribe endpoint with orderbook: true. This provides incremental updates rather than full snapshots.