GetOrderbook
Get a snapshot of the L2 orderbook for a specific market. Returns aggregated price levels with total size at each level.
GET
GetOrderbookPublicReturns the current orderbook state for a market. Bids are sorted descending by price, asks are sorted ascending.
Request
| Parameter | Type | Description |
|---|---|---|
market_idrequired | uint32 | Market ID (0 = RLM-PERP, 1 = RLM-USDC, etc.) |
depthoptional | uint32 | Number of levels per sideDefault: 20 |
Response
| Field | Type | Description |
|---|---|---|
success | bool | Request succeeded |
market_id | uint32 | Market ID |
bids | PriceLevel[] | Bid levels, sorted descending by price |
asks | PriceLevel[] | Ask levels, sorted ascending by price |
timestamp | uint64 | Server timestamp (nanoseconds) |
sequence | uint64 | Sequence 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 levelsfor (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
| Field | Type | Description |
|---|---|---|
price | int64 | Price level (8 decimals) |
size | int64 | Total 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.