{"record":{"id":"0d9b6b602dfe011d","repo":"jackwener/OpenCLI","slug":"coingecko-returned-no-market-data-for-currency","errorCode":null,"errorMessage":"coingecko returned no market data for currency \"${currency}\"","messagePattern":"coingecko returned no market data for currency \"(.+?)\"","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/coingecko/coin.js","lineNumber":79,"sourceCode":"        }\n        let data;\n        try {\n            data = await resp.json();\n        } catch (error) {\n            throw new CommandExecutionError(`coingecko returned malformed JSON: ${error?.message || error}`);\n        }\n        if (data?.error) {\n            throw new CommandExecutionError(`coingecko returned error: ${data.error}`);\n        }\n\n        const md = data.market_data || {};\n        const pick = (obj, key) => (obj && obj[key] != null ? obj[key] : null);\n        const isoFromMaybe = (s) => (s ? String(s).slice(0, 10) : '');\n        const price = pick(md.current_price, currency);\n        const marketCap = pick(md.market_cap, currency);\n        const volume24h = pick(md.total_volume, currency);\n        if (price == null && marketCap == null && volume24h == null) {\n            throw new CommandExecutionError(\n                `coingecko returned no market data for currency \"${currency}\"`,\n                'Use a CoinGecko-supported quote currency such as usd, cny, eur, or jpy.',\n            );\n        }\n\n        return [{\n            id: data.id || id,\n            symbol: String(data.symbol || '').toUpperCase(),\n            name: data.name || '',\n            rank: data.market_cap_rank ?? null,\n            price,\n            marketCap,\n            volume24h,\n            change24hPct: md.price_change_percentage_24h ?? null,\n            change7dPct: md.price_change_percentage_7d ?? null,\n            change30dPct: md.price_change_percentage_30d ?? null,\n            ath: pick(md.ath, currency),\n            athDate: isoFromMaybe(pick(md.ath_date, currency)),","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/coingecko/coin.js#L61-L97","documentation":"This CommandExecutionError is thrown when the response contains a market_data object but has no price, market cap, or total volume for the requested quote currency (all three lookups are null). This usually means CoinGecko does not offer market data quoted in that currency for the coin. The message echoes the currency and a hint lists known-supported slugs.","triggerScenarios":"Calling `opencli coingecko coin <id> --currency <ccy>` where <ccy> passes slug validation but isn't a currency CoinGecko quotes (e.g. 'xyz', 'foo', or a niche/misspelled code like 'usa' instead of 'usd').","commonSituations":"Guessing currency codes ('usa' vs 'usd', 'eur' vs 'euro'); very rare fiat or crypto quote currencies not in CoinGecko's supported list; transient cases where a currency was dropped.","solutions":["Use a supported quote currency: usd, cny, eur, jpy (or gbp, aud, cad, etc.)","Check the supported list at https://api.coingecko.com/api/v3/simple/supported_vs_currencies","Default to omitting --currency (defaults to 'usd')"],"exampleFix":"// before\nopencli coingecko coin bitcoin --currency usa\n// after\nopencli coingecko coin bitcoin --currency usd","handlingStrategy":"validation","validationCode":"const SUPPORTED = new Set(['usd','eur','gbp','jpy','cny','aud','cad','chf','inr','krw','btc','eth']);\nif (!SUPPORTED.has(ccy)) throw new Error(`Unsupported quote currency: ${ccy}`);","typeGuard":"const isSupportedCurrency = (v) => typeof v === 'string' && supportedVsCurrencies.has(v.trim().toLowerCase());","tryCatchPattern":"try { await run(['coingecko', 'coin', id, '--currency', ccy]); } catch (e) { if (/no market data for currency/.test(e.message)) { return run(['coingecko', 'coin', id]); } throw e; } // fall back to usd","preventionTips":["Fetch /api/v3/simple/supported_vs_currencies and validate currencies against it","Stick to well-known fiat codes (usd, eur, jpy, cny, gbp)","Fall back to the usd default when a currency yields no data"],"tags":["api-response","currency","empty-result"],"backgroundTag":"unsupported-quote-currency","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}