Skip to main content
Glama

get-ticker

Retrieve real-time ticker data, including price, volume, and market details, for specified trading pairs across multiple cryptocurrency exchanges using CCXT MCP Server.

Instructions

Get current ticker information for a trading pair

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
exchangeYesExchange ID (e.g., binance, coinbase)
marketTypeNoMarket type (default: spot)
symbolYesTrading pair symbol (e.g., BTC/USDT)

Implementation Reference

  • The main handler function for the 'get-ticker' tool. It rate-limits the API call, selects the exchange instance based on market type, uses caching to fetch ticker data via ex.fetchTicker(symbol), and returns formatted JSON response or error.
    }, async ({ exchange, symbol, marketType }) => {
      try {
        return await rateLimiter.execute(exchange, async () => {
          const ex = marketType 
            ? getExchangeWithMarketType(exchange, marketType)
            : getExchange(exchange);
          const cacheKey = `ticker:${exchange}:${marketType || 'spot'}:${symbol}`;
          
          const ticker = await getCachedData(cacheKey, async () => {
            log(LogLevel.INFO, `Fetching ticker for ${symbol} on ${exchange}`);
            return await ex.fetchTicker(symbol);
          });
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify(ticker, null, 2)
            }]
          };
        });
      } catch (error) {
        log(LogLevel.ERROR, `Error fetching ticker: ${error instanceof Error ? error.message : String(error)}`);
        return {
          content: [{
            type: "text",
            text: `Error: ${error instanceof Error ? error.message : String(error)}`
          }],
          isError: true
        };
      }
    });
  • Input schema using Zod for validating parameters: exchange (string), symbol (string), marketType (optional enum).
    exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"),
    symbol: z.string().describe("Trading pair symbol (e.g., BTC/USDT)"),
    marketType: z.enum(["spot", "future", "swap", "option", "margin"]).optional().describe("Market type (default: spot)")
  • The server.tool() registration call for 'get-ticker', including description, schema, and inline handler function within registerPublicTools.
    server.tool("get-ticker", "Get current ticker information for a trading pair", {
      exchange: z.string().describe("Exchange ID (e.g., binance, coinbase)"),
      symbol: z.string().describe("Trading pair symbol (e.g., BTC/USDT)"),
      marketType: z.enum(["spot", "future", "swap", "option", "margin"]).optional().describe("Market type (default: spot)")
    }, async ({ exchange, symbol, marketType }) => {
      try {
        return await rateLimiter.execute(exchange, async () => {
          const ex = marketType 
            ? getExchangeWithMarketType(exchange, marketType)
            : getExchange(exchange);
          const cacheKey = `ticker:${exchange}:${marketType || 'spot'}:${symbol}`;
          
          const ticker = await getCachedData(cacheKey, async () => {
            log(LogLevel.INFO, `Fetching ticker for ${symbol} on ${exchange}`);
            return await ex.fetchTicker(symbol);
          });
          
          return {
            content: [{
              type: "text",
              text: JSON.stringify(ticker, null, 2)
            }]
          };
        });
      } catch (error) {
        log(LogLevel.ERROR, `Error fetching ticker: ${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