test_futures_endpoints
Validate Binance futures API endpoints by testing trading pair connectivity and response functionality for cryptocurrency market data integration.
Instructions
Test individual futures endpoints
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Trading pair symbol (e.g., BTCUSDT) |
Implementation Reference
- src/index.ts:185-207 (handler)Main handler logic for the 'test_futures_endpoints' tool. Validates input parameters and fetches data from three futures endpoints (open interest, funding rate, liquidations) using the BinanceRestConnector, then returns the combined results as JSON.case "test_futures_endpoints": { if (!isFuturesDataParams(request.params.arguments)) { throw new Error('Invalid futures data parameters'); } const { symbol } = request.params.arguments; // Test each endpoint individually const openInterest = await restConnector.getFuturesOpenInterest(symbol); const fundingRate = await restConnector.getFuturesFundingRate(symbol); const liquidations = await restConnector.getFuturesLiquidations(symbol); // Return all test results return { content: [{ type: "text", text: JSON.stringify({ openInterest, fundingRate, liquidations }, null, 2) }] }; }
- src/index.ts:66-79 (registration)Tool registration in the ListTools response, defining name, description, and input schema requiring a 'symbol' string.{ name: "test_futures_endpoints", description: "Test individual futures endpoints", inputSchema: { type: "object", properties: { symbol: { type: "string", description: "Trading pair symbol (e.g., BTCUSDT)" } }, required: ["symbol"] } },
- Helper method called by the tool handler to fetch futures open interest data from Binance API endpoint '/futures/v1/openInterest'.public async getFuturesOpenInterest(symbol: string): Promise<any> { try { logger.info(`Getting futures open interest for ${symbol}`); const response = await this.executeWithRetry(() => this.axiosInstance.get(`${config.FUTURES_REST_URL}/openInterest`, { params: { symbol: symbol.toUpperCase() } }) ); logger.info('Successfully fetched open interest data'); return response.data; } catch (error) { logger.error('Error fetching open interest:', error); throw new APIError('Failed to fetch open interest data', error as Error); } }
- Helper method called by the tool handler to fetch futures funding rate (premium index) from Binance API endpoint '/futures/v1/premiumIndex'.public async getFuturesFundingRate(symbol: string): Promise<any> { try { logger.info(`Getting futures funding rate for ${symbol}`); const response = await this.executeWithRetry(() => this.axiosInstance.get(`${config.FUTURES_REST_URL}/premiumIndex`, { params: { symbol: symbol.toUpperCase() } }) ); logger.info('Successfully fetched funding rate data'); return response.data; } catch (error) { logger.error('Error fetching funding rate:', error); throw new APIError('Failed to fetch funding rate data', error as Error); } }
- Helper method called by the tool handler to fetch recent futures liquidations (force orders) from Binance API endpoint '/futures/v1/forceOrders' for the last 24 hours.public async getFuturesLiquidations(symbol: string): Promise<any> { try { logger.info(`Getting futures liquidations for ${symbol}`); const response = await this.executeWithRetry(() => this.axiosInstance.get(`${config.FUTURES_REST_URL}/forceOrders`, { params: { symbol: symbol.toUpperCase(), startTime: Date.now() - 24 * 60 * 60 * 1000, limit: 1000 } }) ); logger.info('Successfully fetched liquidations data'); return response.data; } catch (error) { logger.error('Error fetching liquidations:', error); throw new APIError('Failed to fetch liquidations data', error as Error); } }