get_lighter_orderbook_history
Access historical Lighter.xyz orderbook data with customizable granularity, returning L2 snapshots of bids and asks for a given coin and time range.
Instructions
Get historical Lighter.xyz orderbook snapshots. Returns L2 snapshots with bids/asks over a time range. Supports granularity levels: checkpoint (default), 30s, 10s, 1s, tick.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| coin | Yes | Lighter.xyz coin symbol, e.g. 'BTC', 'ETH' | |
| start | No | Start timestamp (Unix ms or ISO). Defaults to 24h ago. | |
| end | No | End timestamp (Unix ms or ISO). Defaults to now. | |
| limit | No | Max records to return (default 100, max 1000) | |
| cursor | No | Pagination cursor from previous response's nextCursor | |
| depth | No | Orderbook depth — number of price levels per side | |
| granularity | No | Orderbook resolution: 'checkpoint' (default), '30s', '10s', '1s', 'tick' (Enterprise) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| records | Yes | Array of result records | |
| count | Yes | Total number of records in the full result set | |
| nextCursor | No | Cursor for next page, if more results available |
Implementation Reference
- src/index.ts:800-815 (registration)Tool registration for 'get_lighter_orderbook_history' using the registerHistoryTool helper. Registers the tool with input schema (coin, start, end, limit, cursor, depth, granularity) and delegates to api().lighter.orderbook.history().
// Lighter Orderbook History registerHistoryTool( "get_lighter_orderbook_history", "Get historical Lighter.xyz orderbook snapshots. Returns L2 snapshots with bids/asks over a time range. Supports granularity levels: checkpoint (default), 30s, 10s, 1s, tick.", (coin, params) => api().lighter.orderbook.history(coin, params as any), LighterCoinParam, normalizeLighterCoin, { depth: DepthParam, granularity: z .enum(["checkpoint", "30s", "10s", "1s", "tick"]) .optional() .describe("Orderbook resolution: 'checkpoint' (default), '30s', '10s', '1s', 'tick' (Enterprise)"), } ); - src/index.ts:316-318 (helper)Normalization helper: converts Lighter coin symbols to uppercase.
function normalizeLighterCoin(coin: string): string { return coin.toUpperCase(); } - src/index.ts:407-438 (helper)registerHistoryTool — the generic registration function that builds the input schema (including coin, start, end, limit, cursor, plus extra params), resolves time range and limit, calls the SDK, and formats the cursor-based paginated response.
// Pattern 4: History with cursor pagination (coin + time range) function registerHistoryTool( name: string, description: string, sdkCall: (coin: string, params: Record<string, unknown>) => Promise<{ data: unknown; nextCursor?: string }>, coinSchema: z.ZodString, normFn: (coin: string) => string, extraSchema?: ZodRawShape ): void { const schema: ZodRawShape = { coin: coinSchema, ...HistoryParams }; if (extraSchema) Object.assign(schema, extraSchema); registerTool(name, description, schema, ListOutputSchema, async (params) => { const { coin, start, end, limit, cursor, ...extra } = params; const timeRange = resolveTimeRange(start, end); const sdkParams: Record<string, unknown> = { ...timeRange, limit: resolveLimit(limit), }; if (cursor) sdkParams.cursor = cursor; // Pass through extra params (interval, side, etc.) for (const [k, v] of Object.entries(extra)) { if (v !== undefined) sdkParams[k] = v; } const result = await sdkCall(normFn(coin), sdkParams); return formatCursorResponse(result); }); } - src/index.ts:108-111 (schema)AggregationIntervalParam schema — used as part of the extraSchema for some history tools (though get_lighter_orderbook_history uses its own granularity param instead).
const AggregationIntervalParam = z .enum(["5m", "15m", "30m", "1h", "4h", "1d"]) .optional() .describe("Aggregation interval. Omit for raw ~1 min data."); - src/index.ts:73-75 (schema)LighterCoinParam schema — defines the Lighter coin parameter accepted by the tool.
const LighterCoinParam = z .string() .describe("Lighter.xyz coin symbol, e.g. 'BTC', 'ETH'");