jackwener/OpenCLI · error · ArgumentError
coingecko has no market totals for currency "${currency}"
Error message
coingecko has no market totals for currency "${currency}" What it means
This ArgumentError is thrown when the /global payload is valid but has neither total_market_cap[currency] nor total_volume[currency], meaning CoinGecko does not publish global market totals in the requested quote currency. It is an input-validation error: the currency argument is unsupported, not a network problem.
Source
Thrown at clis/coingecko/global.js:53
}
if (!resp.ok) {
throw new CommandExecutionError(`coingecko global returned HTTP ${resp.status}`);
}
let body;
try {
body = await resp.json();
}
catch (err) {
throw new CommandExecutionError(`coingecko global returned malformed JSON: ${err?.message ?? err}`);
}
const data = body?.data;
if (!data) {
throw new CommandExecutionError('coingecko global returned no data envelope');
}
const totalMarketCap = data?.total_market_cap?.[currency];
const totalVolume = data?.total_volume?.[currency];
if (totalMarketCap == null && totalVolume == null) {
throw new ArgumentError(
`coingecko has no market totals for currency "${currency}"`,
'Use a CoinGecko-supported quote currency such as usd, cny, eur, or jpy.',
);
}
return [{
currency: currency.toUpperCase(),
totalMarketCap: totalMarketCap != null ? Number(totalMarketCap) : null,
totalVolume24h: totalVolume != null ? Number(totalVolume) : null,
marketCapChange24hPct: data.market_cap_change_percentage_24h_usd != null ? Number(data.market_cap_change_percentage_24h_usd) : null,
btcDominancePct: data?.market_cap_percentage?.btc != null ? Number(data.market_cap_percentage.btc) : null,
ethDominancePct: data?.market_cap_percentage?.eth != null ? Number(data.market_cap_percentage.eth) : null,
activeCryptocurrencies: data.active_cryptocurrencies != null ? Number(data.active_cryptocurrencies) : null,
markets: data.markets != null ? Number(data.markets) : null,
ongoingIcos: data.ongoing_icos != null ? Number(data.ongoing_icos) : null,
updatedAt: data.updated_at ? new Date(data.updated_at * 1000).toISOString() : '',
}];
},
});View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run with a widely supported currency such as usd, cny, eur, or jpy.
- Check the exact currency code on CoinGecko's supported vs_currencies list (https://api.coingecko.com/api/v3/simple/supported_vs_currencies).
- Check the spelling/case of the currency argument in your script or config.
- Fall back to usd and convert locally if your currency is genuinely unsupported.
- If the code is supported but still fails, verify via curl that /global includes your currency key in total_market_cap.
Example fix
// before
await runCli('coingecko', 'global', ['--currency', 'xyz']);
// after
const SUPPORTED = ['usd','cny','eur','jpy','gbp'];
const cur = SUPPORTED.includes(args.currency) ? args.currency : 'usd';
await runCli('coingecko', 'global', ['--currency', cur]); Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED = new Set(['usd','eur','gbp','jpy','cny','aud','cad','chf','hkd','sgd','inr','krw','brl','try','rub','zar','btc','eth','ltc','xrp']);
if (!SUPPORTED.has(currency.toLowerCase())) throw new Error('unsupported quote currency: ' + currency);
const list = await (await fetch('https://api.coingecko.com/api/v3/simple/supported_vs_currencies')).json();
if (!list.includes(currency.toLowerCase())) throw new Error('unsupported vs_currency: ' + currency); Type guard
function isSupportedCurrency(c, supported) { return typeof c === 'string' && supported.map(s => s.toLowerCase()).includes(c.toLowerCase()); } Try / catch
try {
rows = await runCli('coingecko', 'global', ['--currency', cur]);
} catch (e) {
if (e instanceof ArgumentError || /no market totals/.test(e.message)) {
console.warn(`${cur} unsupported — falling back to usd`);
rows = await runCli('coingecko', 'global', ['--currency', 'usd']);
} else throw e;
} Prevention
- Validate currency codes against /simple/supported_vs_currencies
- Normalize user input: trim + lowercase before passing
- Default to usd and convert locally for exotic currencies
- Never interpolate locale-formatted currency strings ('USD-US', '$') into the arg
When it happens
Trigger: Passing a currency arg that passes the slug regex (2-20 chars of a-z0-9-) but is not a CoinGecko-supported quote currency, e.g. 'gbp' typos like 'usdd', 'xyz', or an exotic/obsolete code.
Common situations: Users guessing at currency codes ('chf', 'inr' variants, 'aud' typos); scripts parameterizing currency from config with an unsupported value; locale-based currency strings like 'USD-US' or '$' leaking into the arg.
Related errors
- currency must be a 3-letter ISO code (e.g. USD, JPY, CNY), g
- coingecko sort "${args.sort}" is not supported
- coingecko limit must be a positive integer
- coingecko limit must be <= 100
- archive search sort must be one of ${SORT_OPTIONS.join(', ')
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/8429106048bdbd6e.
Report an issue: GitHub.