get_l2_orderbook
Retrieve Hyperliquid L2 full-depth orderbook with aggregated price levels, total size, and order counts per level. Supports historical snapshots by timestamp and configurable depth.
Instructions
Get Hyperliquid L2 full-depth orderbook (Build+ tier). Returns aggregated price levels with total size and order count per level. Derived from L4 data. Data from March 2026+.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coin | Yes | Coin/market symbol, e.g. 'BTC', 'ETH', 'SOL' | |
| timestamp | No | Timestamp for historical state (Unix ms or ISO). Omit for current. | |
| 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:1115-1134 (registration)Registration of the 'get_l2_orderbook' tool. Defines input schema (coin, optional timestamp, optional depth), uses ObjectOutputSchema, and delegates to api().hyperliquid.l2Orderbook.get() with normalized coin.
registerTool( "get_l2_orderbook", "Get Hyperliquid L2 full-depth orderbook (Build+ tier). Returns aggregated price levels with total size and order count per level. Derived from L4 data. Data from March 2026+.", { coin: CoinParam, timestamp: TimestampParam.describe("Timestamp for historical state (Unix ms or ISO). Omit for current.").optional(), 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.l2Orderbook.get( normalizeHLCoin(params.coin), sdkParams as any ); return formatResponse(data); } ); - src/index.ts:98-101 (schema)Shared Zod schema for the optional 'depth' parameter used by get_l2_orderbook.
const DepthParam = z .number() .optional() .describe("Orderbook depth — number of price levels per side"); - src/index.ts:53-55 (schema)Shared Zod schema for the 'coin' parameter used by get_l2_orderbook.
const CoinParam = z .string() .describe("Coin/market symbol, e.g. 'BTC', 'ETH', 'SOL'"); - src/index.ts:139-141 (schema)Output schema (ObjectOutputSchema) used by get_l2_orderbook — wraps the result in a 'data' field.
const ObjectOutputSchema: ZodRawShape = { data: z.record(z.unknown()).describe("Result data object"), }; - src/index.ts:296-298 (helper)Normalizer that uppercases the coin symbol before passing it to the SDK.
function normalizeHLCoin(coin: string): string { return coin.toUpperCase(); }