cryptoCurrencyMap
Map all cryptocurrencies to unique CoinMarketCap IDs for data integration, analysis, or tracking purposes. Access comprehensive crypto IDs with customizable filters like listing status, symbol, and sorting options.
Instructions
Returns a mapping of all cryptocurrencies to unique CoinMarketCap IDs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| aux | No | ||
| limit | No | ||
| listing_status | No | ||
| sort | No | ||
| start | No | ||
| symbol | No |
Implementation Reference
- index.js:158-180 (registration)Registration of the 'cryptoCurrencyMap' tool using server.tool, including description, Zod input schema, and inline asynchronous handler function.server.tool("cryptoCurrencyMap", "Returns a mapping of all cryptocurrencies to unique CoinMarketCap IDs.", { listing_status: z.string().optional(), start: z.number().optional(), limit: z.number().optional(), sort: z.string().optional(), symbol: z.string().optional(), aux: z.string().optional() }, async ({ listing_status = 'active', start = 1, limit = 100, sort = 'id', symbol, aux }) => { return handleEndpoint(async () => { return await makeApiRequestWithErrorHandling(apiKey, '/v1/cryptocurrency/map', { listing_status, start, limit, sort, symbol, aux }) }) } )
- index.js:168-179 (handler)The core handler logic for executing the 'cryptoCurrencyMap' tool. It invokes helper functions to make an authenticated request to the CoinMarketCap '/v1/cryptocurrency/map' endpoint with provided parameters.async ({ listing_status = 'active', start = 1, limit = 100, sort = 'id', symbol, aux }) => { return handleEndpoint(async () => { return await makeApiRequestWithErrorHandling(apiKey, '/v1/cryptocurrency/map', { listing_status, start, limit, sort, symbol, aux }) }) }
- index.js:160-167 (schema)Zod schema defining the input parameters for the 'cryptoCurrencyMap' tool, including optional filters like listing_status, pagination, sorting, and symbol.{ listing_status: z.string().optional(), start: z.number().optional(), limit: z.number().optional(), sort: z.string().optional(), symbol: z.string().optional(), aux: z.string().optional() },
- index.js:40-47 (helper)Helper function that wraps the core API request with specific CoinMarketCap error handling and JSON response formatting, directly used by the tool handler.async function makeApiRequestWithErrorHandling(apiKey, endpoint, params = {}) { try { const data = await makeApiRequest(apiKey, endpoint, params) return formatResponse(data) } catch (error) { return formatErrorResponse(`Error fetching data from CoinMarketCap: ${error.message}`, 500) } }
- index.js:82-88 (helper)General-purpose helper function for handling API endpoints with try-catch error management, invoked by the tool handler.async function handleEndpoint(apiCall) { try { return await apiCall() } catch (error) { return formatErrorResponse(error.message, error.status || 403) } }