get_l4_orderbook
Retrieves Hyperliquid L4 orderbook at a specific timestamp, showing individual order IDs, user addresses, prices, and sizes for full market depth analysis.
Instructions
Get Hyperliquid L4 orderbook reconstruction (Pro+ tier). Returns full order-level orderbook at a specific timestamp with individual order IDs, user addresses, prices, and sizes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coin | Yes | Coin/market symbol, e.g. 'BTC', 'ETH', 'SOL' | |
| timestamp | No | Timestamp for orderbook reconstruction (Unix ms or ISO) | |
| depth | No | Orderbook depth — number of price levels per side |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| data | Yes | Result data object |
Implementation Reference
- src/index.ts:1069-1088 (registration)Registration of the 'get_l4_orderbook' tool using registerTool(). Takes coin, timestamp, and optional depth params. Calls api().hyperliquid.l4Orderbook.get() with the normalized coin and SDK params.
registerTool( "get_l4_orderbook", "Get Hyperliquid L4 orderbook reconstruction (Pro+ tier). Returns full order-level orderbook at a specific timestamp with individual order IDs, user addresses, prices, and sizes.", { coin: CoinParam, timestamp: TimestampParam.describe("Timestamp for orderbook reconstruction (Unix ms or ISO)"), depth: DepthParam, }, ObjectOutputSchema, async (params) => { const sdkParams: Record<string, unknown> = {}; if (params.timestamp != null) sdkParams.timestamp = toUnixMs(params.timestamp); if (params.depth) sdkParams.depth = params.depth; const data = await api().hyperliquid.l4Orderbook.get( normalizeHLCoin(params.coin), sdkParams as any ); return formatResponse(data); } ); - src/index.ts:1078-1088 (handler)Handler for get_l4_orderbook. Builds SDK params from timestamp and depth, calls api().hyperliquid.l4Orderbook.get() with the normalized coin and params, then returns the formatted response.
async (params) => { const sdkParams: Record<string, unknown> = {}; if (params.timestamp != null) sdkParams.timestamp = toUnixMs(params.timestamp); if (params.depth) sdkParams.depth = params.depth; const data = await api().hyperliquid.l4Orderbook.get( normalizeHLCoin(params.coin), sdkParams as any ); return formatResponse(data); } ); - src/index.ts:1072-1077 (schema)Input schema for get_l4_orderbook: coin (string), timestamp (number or string Unix ms/ISO), depth (optional number). Output schema: ObjectOutputSchema (single data object).
{ coin: CoinParam, timestamp: TimestampParam.describe("Timestamp for orderbook reconstruction (Unix ms or ISO)"), depth: DepthParam, }, ObjectOutputSchema, - src/index.ts:20-22 (helper)Helper function that returns the SDK client instance used by the handler to call hyperliquid.l4Orderbook.get().
function api(): OxArchive { return client!; } - src/index.ts:147-154 (helper)Helper function used by the handler to convert timestamp parameters (number or ISO string) to Unix milliseconds.
function toUnixMs(ts: number | string): number { if (typeof ts === "number") return ts; // MCP/JSON-RPC may deliver numeric timestamps as strings if (/^\d+$/.test(ts)) return Number(ts); const parsed = Date.parse(ts); if (isNaN(parsed)) throw new Error(`Invalid timestamp: "${ts}"`); return parsed; }