Skip to main content
Skip to main content

CoinGecko Data Connector

Need charts for thousands of crypto assets without mapping every symbol to an exchange pair? The CoinGecko connector loads historical OHLC from CoinGecko REST API and polls for near-real-time prices — ideal for portfolio trackers, news embeds, and multi-asset dashboards.

Loading chart…

Use the controls above to change coin id and timeframe. This is the same integration you will copy into your app.

Standalone demo

Full-page version with sample code: CoinGecko live demo.

What you get

FeatureDetails
Coverage10,000+ crypto assets via CoinGecko coin ids
HistoryOHLC from /coins/{id}/ohlc and date ranges via /market_chart/range
Live updatesREST polling every 60 seconds (configurable)
SymbolsCoin ids like bitcoin, ethereum — not BTCUSDT
Dev tierCoinGecko Demo API for development
LicenseMIT connector package

Perfect for portfolio apps, market news embeds, and research dashboards. For sub-second exchange ticks, use Binance, Bybit, OKX, Kraken, or KuCoin.

Install

npm install @efixdata/exeria-chart @efixdata/connector-coingecko

Minimal example

import { createChart } from "@efixdata/exeria-chart";
import { CoingeckoAdapter } from "@efixdata/connector-coingecko";

const connector = new CoingeckoAdapter({ pollIntervalMs: 60_000 });

const chart = createChart({
container,
dataAdapter: connector,
});

chart.init();

await chart.loadData("bitcoin", {
interval: "1d",
limit: 90,
});

chart.subscribeToUpdates("bitcoin", (tick) => {
console.log("Last price:", tick.price ?? tick.c);
});

Step by step

1 — Create the connector

const connector = new CoingeckoAdapter({ pollIntervalMs: 60_000 });

Uses the CoinGecko Demo API by default. Optional Pro API key below.

2 — Attach to the chart

const chart = createChart({ container, dataAdapter: connector });
chart.init();

The chart delegates loadData and subscribeToUpdates to the connector.

3 — Load history

await chart.loadData("bitcoin", {
interval: "1d",
limit: 90,
});
OptionMeaning
intervalCandle size — "1d" works best on Demo API; "1h" has coarser granularity on free tier
limitHow many recent bars to keep after fetch
from / toOptional date range (uses /market_chart/range)

4 — Go live (polling)

chart.subscribeToUpdates("bitcoin");
// or with a callback:
chart.subscribeToUpdates("bitcoin", (tick) => { /* update UI */ });

CoinGecko has no native WebSocket for OHLC — the adapter polls /simple/price every 60 seconds by default.

5 — Clean up

chart.unsubscribeFromUpdates();
await connector.disconnect();
Coin idAsset
bitcoinBitcoin
ethereumEthereum
solanaSolana
cardanoCardano
rippleXRP
binancecoinBNB

Look up ids in CoinGecko API docs or via /coins/list.

CoinGecko ids vs exchange pairs

Binance / BybitCoinGecko
BTCUSDTbitcoin
ETHUSDTethereum
Exchange trading pairCoinGecko coin id

Switch asset

async function switchCoin(newCoinId: string) {
chart.unsubscribeFromUpdates();

await chart.loadData(newCoinId, {
interval: "1d",
limit: 90,
});

chart.subscribeToUpdates(newCoinId);
}

Always unsubscribe before loading a new symbol on the same chart instance.

Custom configuration (optional)

const connector = new CoingeckoAdapter({
baseUrl: "https://api.coingecko.com/api/v3",
apiKey: process.env.COINGECKO_API_KEY,
vsCurrency: "usd",
pollIntervalMs: 60_000,
requestTimeout: 10000,
maxRetries: 5,
retryDelay: 2000,
});

For Pro API:

const connector = new CoingeckoAdapter({
baseUrl: "https://pro-api.coingecko.com/api/v3",
apiKey: process.env.COINGECKO_API_KEY,
});

Pass the key at runtime:

await connector.initialize({ apiKey: process.env.COINGECKO_API_KEY });

Error handling

try {
await chart.loadData("bitcoin", { interval: "1d", limit: 90 });
} catch (error) {
if (error instanceof Error && error.message.includes("Invalid coin")) {
console.error("Coin id not found on CoinGecko");
} else {
console.error("Load failed:", error);
}
}

Show a retry button or message in your UI — rate limits and network blips happen on free tiers.

Limits to know

TopicLimit
Demo API rate100 requests/minute, 10,000/month
Live updatesPolling (default 60s) — not exchange-grade WebSocket
/ohlc volumeNot included — volume is 0; use market_chart/range if you need volume
Historical range (Demo)Past 365 days on some endpoints
Sub-minute barsNot supported on Demo API — use an exchange connector

For heavy traffic: cache history server-side and keep pollIntervalMs at 60s or higher.

When to use CoinGecko vs exchanges

CoinGeckoBinance / Bybit / OKX
SymbolbitcoinBTCUSDT / BTC-USDT
Coverage10,000+ assetsExchange-listed pairs
Live dataPolling (~60s)WebSocket ticks
API key (public data)Optional on DemoNo

Need live BTC/USDT or BTC/USD from an exchange? See Binance, Bybit, OKX, Kraken, or KuCoin.

Pricing

TierUse
Demo APIDevelopment and prototypes
Paid plansProduction traffic — see CoinGecko pricing

The connector package is MIT-licensed; CoinGecko data terms apply separately.

What is next?