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

ParameterTypeDescription
market_idrequireduint32Market ID (0 = RLM-PERP, 1 = RLM-USDC, etc.)
depthoptionaluint32Number of levels per sideDefault: 20

Response

FieldTypeDescription
successboolRequest succeeded
market_iduint32Market ID
bidsPriceLevel[]Bid levels, sorted descending by price
asksPriceLevel[]Ask levels, sorted ascending by price
timestampuint64Server timestamp (nanoseconds)
sequenceuint64Sequence number for ordering updates

Example

Request

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}`);
}

Response

{
"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.