fiatMap
Retrieve a mapping of supported fiat currencies to their unique CoinMarketCap IDs, with options for pagination, sorting, and including precious metals.
Instructions
Returns a mapping of all supported fiat currencies to unique CoinMarketCap IDs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start | No | ||
| limit | No | ||
| sort | No | ||
| include_metals | No |
Implementation Reference
- index.js:558-573 (registration)Registration of the 'fiatMap' tool on the MCP server, binding it to the CoinMarketCap /v1/fiat/map API endpoint.
// /fiat/map server.tool("fiatMap", "Returns a mapping of all supported fiat currencies to unique CoinMarketCap IDs.", { start: z.number().optional(), limit: z.number().optional(), sort: z.string().optional(), include_metals: z.boolean().optional() }, async (params) => { return handleEndpoint(async () => { const data = await makeApiRequest(apiKey, '/v1/fiat/map', params) return formatResponse(data) }) } ) - index.js:567-572 (handler)The inline async handler for fiatMap that calls makeApiRequest with the /v1/fiat/map endpoint and formats the response.
async (params) => { return handleEndpoint(async () => { const data = await makeApiRequest(apiKey, '/v1/fiat/map', params) return formatResponse(data) }) } - index.js:561-566 (schema)Input schema for fiatMap using Zod: optional start (number), limit (number), sort (string), include_metals (boolean).
{ start: z.number().optional(), limit: z.number().optional(), sort: z.string().optional(), include_metals: z.boolean().optional() }, - index.js:50-73 (helper)The makeApiRequest helper that sends HTTP GET requests to the CoinMarketCap pro API.
async function makeApiRequest(apiKey, endpoint, params = {}) { const queryParams = new URLSearchParams() Object.entries(params).forEach(([key, value]) => { if (value !== undefined) { queryParams.append(key, value.toString()) } }) const url = `https://pro-api.coinmarketcap.com${endpoint}${queryParams.toString() ? `?${queryParams.toString()}` : ''}` const response = await fetch(url, { method: 'GET', headers: { 'Accept': 'application/json', 'X-CMC_PRO_API_KEY': apiKey, } }) if (!response.ok) { throw new Error(`Error fetching data from CoinMarketCap: ${response.statusText}`) } return await response.json() } - index.js:82-88 (helper)The handleEndpoint helper that wraps API calls with try/catch error handling.
async function handleEndpoint(apiCall) { try { return await apiCall() } catch (error) { return formatErrorResponse(error.message, error.status || 403) } }