Skip to main content
Glama

get_orderbook

Read-onlyIdempotent

Retrieve current Hyperliquid L2 orderbook snapshot with bids, asks, mid price, and spread. Optionally specify depth for number of price levels per side.

Instructions

Get the current Hyperliquid L2 orderbook snapshot for a coin. Returns bids, asks, mid price, and spread. Optionally specify depth (price levels per side). Requires Pro tier or higher for full depth.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coinYesCoin/market symbol, e.g. 'BTC', 'ETH', 'SOL'
depthNoOrderbook depth — number of price levels per side

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYesResult data object

Implementation Reference

  • src/index.ts:478-485 (registration)
    Registration of the 'get_orderbook' tool via the registerOrderbookTool helper. It binds the Hyperliquid orderbook SDK call, uses CoinParam schema (uppercased string), passes optional depth param, and normalizes coin to uppercase.
    // 2. Current Orderbook
    registerOrderbookTool(
      "get_orderbook",
      "Get the current Hyperliquid L2 orderbook snapshot for a coin. Returns bids, asks, mid price, and spread. Optionally specify depth (price levels per side). Requires Pro tier or higher for full depth.",
      (coin, params) => api().hyperliquid.orderbook.get(coin, params),
      CoinParam,
      normalizeHLCoin
    );
  • Input schema for the coin parameter: a simple string describing the market symbol.
    const CoinParam = z
      .string()
      .describe("Coin/market symbol, e.g. 'BTC', 'ETH', 'SOL'");
  • Optional depth parameter schema used by get_orderbook to limit price levels per side.
    const DepthParam = z
      .number()
      .optional()
      .describe("Orderbook depth — number of price levels per side");
  • Helper function registerOrderbookTool that encapsulates the common pattern for orderbook tools. Takes an SDK call, coin schema, and normalization function; passes optional depth param; formats the response as a single object.
    // Pattern 3: Orderbook snapshot (coin + optional depth)
    function registerOrderbookTool(
      name: string,
      description: string,
      sdkCall: (coin: string, params?: { depth?: number }) => Promise<unknown>,
      coinSchema: z.ZodString,
      normFn: (coin: string) => string
    ): void {
      registerTool(
        name,
        description,
        { coin: coinSchema, depth: DepthParam },
        ObjectOutputSchema,
        async (params) => {
          const sdkParams = params.depth ? { depth: params.depth } : undefined;
          const data = await sdkCall(normFn(params.coin), sdkParams);
          return formatResponse(data);
        }
      );
    }
  • Output schema for orderbook (and other single-object) tools: returns a 'data' key with the result object.
    const ObjectOutputSchema: ZodRawShape = {
      data: z.record(z.unknown()).describe("Result data object"),
    };
Behavior4/5

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

Annotations already indicate read-only and idempotent behavior. The description adds specific return fields (bids, asks, mid price, spread) and the depth limitation tied to subscription tier, going beyond the structured metadata.

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 sentences, front-loaded with purpose and output, followed by optional parameter and requirement. No redundant information.

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

Completeness5/5

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

For a simple tool with complete input schema and output schema present, the description covers all essential aspects: what it returns, optional parameter, and access requirement. No gaps.

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?

Schema coverage is 100% with clear descriptions for both parameters. The description only reiterates that depth is optional and specifies price levels per side, adding no new semantics beyond the schema.

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

Purpose4/5

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

Clearly states it retrieves the current L2 orderbook snapshot for a coin, listing returned data (bids, asks, mid price, spread). However, it does not differentiate from many sibling orderbook tools like get_l2_orderbook or get_spot_orderbook.

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

Usage Guidelines3/5

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

Mentions the Pro tier requirement for full depth, providing a usage constraint. Lacks explicit guidance on when to use this tool vs alternatives or when not to use it.

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