Skip to main content
Glama

get_l2_orderbook_history

Read-onlyIdempotent

Retrieve Hyperliquid L2 orderbook history snapshots over a specified time range and coin. Get periodic aggregated orderbook data for analysis or backtesting.

Instructions

Get Hyperliquid L2 full-depth orderbook checkpoints (Build+ tier). Returns periodic aggregated orderbook snapshots over a time range.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coinYesCoin/market symbol, e.g. 'BTC', 'ETH', 'SOL'
startNoStart timestamp (Unix ms or ISO). Defaults to 24h ago.
endNoEnd timestamp (Unix ms or ISO). Defaults to now.
limitNoMax records to return (default 100, max 1000)
cursorNoPagination cursor from previous response's nextCursor
depthNoOrderbook depth — number of price levels per side

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
recordsYesArray of result records
countYesTotal number of records in the full result set
nextCursorNoCursor for next page, if more results available

Implementation Reference

  • src/index.ts:1136-1145 (registration)
    Registration of the 'get_l2_orderbook_history' tool using the registerHistoryTool helper. It delegates to the SDK's hyperliquid.l2Orderbook.history() method with a coin parameter (normalized to uppercase), time range params, and an optional depth parameter. Uses the HistoryParams pattern for start/end/limit/cursor.
    // Hyperliquid L2 Orderbook History
    registerHistoryTool(
      "get_l2_orderbook_history",
      "Get Hyperliquid L2 full-depth orderbook checkpoints (Build+ tier). Returns periodic aggregated orderbook snapshots over a time range.",
      (coin, params) =>
        api().hyperliquid.l2Orderbook.history(coin, params as any),
      CoinParam,
      normalizeHLCoin,
      { depth: DepthParam }
    );
  • DepthParam schema used as optional input for the depth parameter in the L2 orderbook history tool.
    const DepthParam = z
  • HistoryParams shared schema providing start/end/limit/cursor fields used by the L2 orderbook history tool.
    const HistoryParams = {
      start: TimestampParam.describe(
        "Start timestamp (Unix ms or ISO). Defaults to 24h ago."
      ),
      end: TimestampParam.describe(
        "End timestamp (Unix ms or ISO). Defaults to now."
      ),
      limit: LimitParam,
      cursor: CursorParam,
    };
  • Output schema for the L2 orderbook history tool, returning an array of records with count and optional pagination cursor.
    const ListOutputSchema: ZodRawShape = {
      records: z.array(z.record(z.unknown())).describe("Array of result records"),
      count: z.number().describe("Total number of records in the full result set"),
      nextCursor: z
        .string()
        .optional()
        .describe("Cursor for next page, if more results available"),
    };
  • registerHistoryTool helper function that the L2 orderbook history tool uses. It builds the input schema with coin + HistoryParams + extraSchema, resolves time range, builds SDK params, calls the provided SDK function, and formats the cursor-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);
      });
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, destructiveHint, idempotentHint, openWorldHint. Description adds that results are periodic aggregated snapshots, but does not expand on behavior beyond annotations. No contradiction.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two concise sentences that front-load the core function and add key context. No extraneous words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given many sibling orderbook history tools, description clarifies this is for L2 historical snapshots with Build+ tier. Output schema exists. Could further differentiate from get_orderbook_history or explain pagination, but sufficient for most use cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% description coverage with detailed parameter explanations. Description does not add additional parameter meaning beyond the schema. Baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the verb (Get), resource (L2 full-depth orderbook checkpoints), and scope (over a time range). It distinguishes from siblings like get_l2_orderbook (current snapshot) and other orderbook history tools of different levels.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Mentions 'Build+ tier' (access) and 'periodic aggregated orderbook snapshots over a time range' but does not explicitly compare to alternatives like get_orderbook_history. Siblings are numerous and naming provides some guidance, but more explicit when-to-use would help.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/0xArchiveIO/0xarchive-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server