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
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | Category (spot, linear, inverse, etc.) | |
| symbol | Yes | Symbol (e.g., BTCUSDT) | |
| limit | No | Number of orderbook entries to retrieve |
Implementation Reference
- src/index.ts:722-736 (handler)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'], }, },
- src/bybit-service.ts:141-143 (helper)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 }); }
- src/types.ts:30-36 (schema)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; }
- src/index.ts:66-84 (schema)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'], },