Skip to main content
Glama

get_orderbook

Retrieve real-time orderbook data for cryptocurrency trading pairs on Bybit to analyze market depth, identify support/resistance levels, and make informed trading decisions.

Instructions

Get orderbook data for a specific symbol

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesCategory (spot, linear, inverse, etc.)
symbolYesSymbol (e.g., BTCUSDT)
limitNoNumber of orderbook entries to retrieve

Implementation Reference

  • Handler for the 'get_orderbook' tool. Extracts parameters from request and calls BybitService.getOrderbook, then returns the result as JSON text content.
    case 'get_orderbook': {
      const result = await this.bybitService.getOrderbook(
        typedArgs.category,
        typedArgs.symbol,
        typedArgs.limit
      );
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • src/index.ts:63-85 (registration)
    Registration of the 'get_orderbook' tool including name, description, and input schema definition in the tools array passed to MCP server.
    {
      name: 'get_orderbook',
      description: 'Get orderbook data for a specific symbol',
      inputSchema: {
        type: 'object',
        properties: {
          category: {
            type: 'string',
            description: 'Category (spot, linear, inverse, etc.)',
          },
          symbol: {
            type: 'string',
            description: 'Symbol (e.g., BTCUSDT)',
          },
          limit: {
            type: 'number',
            description: 'Number of orderbook entries to retrieve',
            default: 50,
          },
        },
        required: ['category', 'symbol'],
      },
    },
  • Core implementation of getOrderbook in BybitService class, which makes the HTTP request to Bybit's /v5/market/orderbook endpoint.
    async getOrderbook(category: string, symbol: string, limit: number = 50): Promise<BybitResponse<OrderbookData> | { error: string }> {
      return this.makeBybitRequest('/v5/market/orderbook', 'GET', { category, symbol, limit });
    }
  • TypeScript interface defining the structure of the orderbook response data (output schema).
    export interface OrderbookData {
      symbol: string;
      bids: [string, string][];
      asks: [string, string][];
      ts: number;
      u: number;
    }
  • JSON Schema for input validation of the 'get_orderbook' tool parameters.
    inputSchema: {
      type: 'object',
      properties: {
        category: {
          type: 'string',
          description: 'Category (spot, linear, inverse, etc.)',
        },
        symbol: {
          type: 'string',
          description: 'Symbol (e.g., BTCUSDT)',
        },
        limit: {
          type: 'number',
          description: 'Number of orderbook entries to retrieve',
          default: 50,
        },
      },
      required: ['category', 'symbol'],
    },

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/kondisettyravi/mcp-bybit-node'

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