Skip to main content
Glama

batch-get-tickers

Retrieve real-time ticker data for multiple trading pairs simultaneously on supported exchanges. Specify exchange, symbols, and market type for efficient data fetching.

Instructions

Get ticker information for multiple trading pairs at once

Input Schema

NameRequiredDescriptionDefault
exchangeYesExchange ID (e.g., binance, coinbase)
marketTypeNoMarket type (default: spot)
symbolsYesList of trading pair symbols (e.g., ['BTC/USDT', 'ETH/USDT'])

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "exchange": { "description": "Exchange ID (e.g., binance, coinbase)", "type": "string" }, "marketType": { "description": "Market type (default: spot)", "enum": [ "spot", "future", "swap", "option", "margin" ], "type": "string" }, "symbols": { "description": "List of trading pair symbols (e.g., ['BTC/USDT', 'ETH/USDT'])", "items": { "type": "string" }, "type": "array" } }, "required": [ "exchange", "symbols" ], "type": "object" }

Implementation Reference

  • The core handler function for the batch-get-tickers tool. It uses rate limiting, caching, fetches the appropriate exchange instance, and calls ex.fetchTickers(symbols) to retrieve ticker data for multiple symbols. Returns JSON stringified response or error.
    }, async ({ exchange, symbols, marketType }) => { try { return await rateLimiter.execute(exchange, async () => { const ex = marketType ? getExchangeWithMarketType(exchange, marketType) : getExchange(exchange); const cacheKey = `tickers:${exchange}:${marketType || 'spot'}:${symbols.join(',')}`; const tickers = await getCachedData(cacheKey, async () => { log(LogLevel.INFO, `Batch fetching tickers for ${symbols.length} symbols on ${exchange}`); return await ex.fetchTickers(symbols); }); return { content: [{ type: "text", text: JSON.stringify(tickers, null, 2) }] }; }); } catch (error) { log(LogLevel.ERROR, `Error batch fetching tickers: ${error instanceof Error ? error.message : String(error)}`); return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; }
  • Zod input schema defining parameters for the tool: exchange (string), symbols (array of strings), and optional marketType (enum).
    exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"), symbols: z.array(z.string()).describe("List of trading pair symbols (e.g., ['BTC/USDT', 'ETH/USDT'])"), marketType: z.enum(["spot", "future", "swap", "option", "margin"]).optional().describe("Market type (default: spot)")
  • Registration of the batch-get-tickers tool with McpServer using server.tool(), providing name, description, input schema, and inline handler function.
    server.tool("batch-get-tickers", "Get ticker information for multiple trading pairs at once", { exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"), symbols: z.array(z.string()).describe("List of trading pair symbols (e.g., ['BTC/USDT', 'ETH/USDT'])"), marketType: z.enum(["spot", "future", "swap", "option", "margin"]).optional().describe("Market type (default: spot)") }, async ({ exchange, symbols, marketType }) => { try { return await rateLimiter.execute(exchange, async () => { const ex = marketType ? getExchangeWithMarketType(exchange, marketType) : getExchange(exchange); const cacheKey = `tickers:${exchange}:${marketType || 'spot'}:${symbols.join(',')}`; const tickers = await getCachedData(cacheKey, async () => { log(LogLevel.INFO, `Batch fetching tickers for ${symbols.length} symbols on ${exchange}`); return await ex.fetchTickers(symbols); }); return { content: [{ type: "text", text: JSON.stringify(tickers, null, 2) }] }; }); } catch (error) { log(LogLevel.ERROR, `Error batch fetching tickers: ${error instanceof Error ? error.message : String(error)}`); return { content: [{ type: "text", text: `Error: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } });

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/doggybee/mcp-server-ccxt'

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