get_kline
Retrieve candlestick (K-line) data for specific assets on Bybit, including historical price details, time intervals, and customizable start/end times for analysis and trading strategies.
Instructions
Get K-line (candlestick) data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | Yes | Category (spot, linear, inverse, etc.) | |
| end | No | End time in milliseconds | |
| interval | Yes | Time interval (1, 3, 5, 15, 30, 60, 120, 240, 360, 720, D, W, M) | |
| limit | No | Number of records to retrieve | |
| start | No | Start time in milliseconds | |
| symbol | Yes | Symbol (e.g., BTCUSDT) |
Implementation Reference
- src/bybit-service.ts:145-157 (handler)The core handler function that constructs the request parameters and calls the Bybit /v5/market/kline API endpoint via makeBybitRequest.async getKline( category: string, symbol: string, interval: string, start?: number, end?: number, limit: number = 200 ): Promise<BybitResponse<KlineData> | { error: string }> { const params: any = { category, symbol, interval, limit }; if (start) params.start = start; if (end) params.end = end; return this.makeBybitRequest('/v5/market/kline', 'GET', params); }
- src/index.ts:87-119 (schema)Input schema definition for the get_kline tool, specifying parameters, types, descriptions, and required fields.name: 'get_kline', description: 'Get K-line (candlestick) data', inputSchema: { type: 'object', properties: { category: { type: 'string', description: 'Category (spot, linear, inverse, etc.)', }, symbol: { type: 'string', description: 'Symbol (e.g., BTCUSDT)', }, interval: { type: 'string', description: 'Time interval (1, 3, 5, 15, 30, 60, 120, 240, 360, 720, D, W, M)', }, start: { type: 'number', description: 'Start time in milliseconds', }, end: { type: 'number', description: 'End time in milliseconds', }, limit: { type: 'number', description: 'Number of records to retrieve', default: 200, }, }, required: ['category', 'symbol', 'interval'], },
- src/index.ts:738-755 (registration)Tool call dispatcher in the MCP server's CallToolRequestSchema handler that invokes the getKline method with parsed arguments.case 'get_kline': { const result = await this.bybitService.getKline( typedArgs.category, typedArgs.symbol, typedArgs.interval, typedArgs.start, typedArgs.end, typedArgs.limit ); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; }
- src/types.ts:38-42 (schema)TypeScript interface defining the structure of KlineData returned by the Bybit kline API.export interface KlineData { symbol: string; category: string; list: [string, string, string, string, string, string, string][]; }