jackwener/OpenCLI · error · CommandExecutionError

coingecko returned no market data for currency "${currency}"

Error message

coingecko returned no market data for currency "${currency}"

What it means

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.

Source

Thrown at clis/coingecko/coin.js:79

        }
        let data;
        try {
            data = await resp.json();
        } catch (error) {
            throw new CommandExecutionError(`coingecko returned malformed JSON: ${error?.message || error}`);
        }
        if (data?.error) {
            throw new CommandExecutionError(`coingecko returned error: ${data.error}`);
        }

        const md = data.market_data || {};
        const pick = (obj, key) => (obj && obj[key] != null ? obj[key] : null);
        const isoFromMaybe = (s) => (s ? String(s).slice(0, 10) : '');
        const price = pick(md.current_price, currency);
        const marketCap = pick(md.market_cap, currency);
        const volume24h = pick(md.total_volume, currency);
        if (price == null && marketCap == null && volume24h == null) {
            throw new CommandExecutionError(
                `coingecko returned no market data for currency "${currency}"`,
                'Use a CoinGecko-supported quote currency such as usd, cny, eur, or jpy.',
            );
        }

        return [{
            id: data.id || id,
            symbol: String(data.symbol || '').toUpperCase(),
            name: data.name || '',
            rank: data.market_cap_rank ?? null,
            price,
            marketCap,
            volume24h,
            change24hPct: md.price_change_percentage_24h ?? null,
            change7dPct: md.price_change_percentage_7d ?? null,
            change30dPct: md.price_change_percentage_30d ?? null,
            ath: pick(md.ath, currency),
            athDate: isoFromMaybe(pick(md.ath_date, currency)),

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use a supported quote currency: usd, cny, eur, jpy (or gbp, aud, cad, etc.)
  2. Check the supported list at https://api.coingecko.com/api/v3/simple/supported_vs_currencies
  3. Default to omitting --currency (defaults to 'usd')

Example fix

// before
opencli coingecko coin bitcoin --currency usa
// after
opencli coingecko coin bitcoin --currency usd
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = new Set(['usd','eur','gbp','jpy','cny','aud','cad','chf','inr','krw','btc','eth']);
if (!SUPPORTED.has(ccy)) throw new Error(`Unsupported quote currency: ${ccy}`);

Type guard

const isSupportedCurrency = (v) => typeof v === 'string' && supportedVsCurrencies.has(v.trim().toLowerCase());

Try / catch

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

Prevention

When it happens

Trigger: 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').

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/0d9b6b602dfe011d. Report an issue: GitHub.