Repository navigation
CoinGecko
Typed CoinGecko API client for Deno, Bun, Node.js and Cloudflare Workers, on the Demo and Pro tiers. Fetch cryptocurrency prices, market data and the full coin list.
CoinGecko provides validated simple-price, coin-list, and market-data responses for the CoinGecko REST API. It uses RESTler for transport and Guardian for runtime response validation.
The client works keyless against the public demo tier, or with an API key
against either the demo or paid pro tier — pro requires an apiKey.
Your tests don't need to fake HTTP. Have your code take a CoinGecko instance
and pass in a stand-in that returns the shapes from
@tundraconnect/coingecko/schemas or throws a real CoinGeckoError:
import { CoinGeckoError } from '@tundraconnect/coingecko/errors';
const outage = new CoinGeckoError('SERVICE_UNAVAILABLE', { status: 503 });
console.log(outage.code);To exercise the client itself against a fake transport, subclass it and
reassign the protected _fetch.
| Topic | Description |
|---|---|
| API | Client configuration and endpoint methods |
| Errors | Error codes and diagnostic metadata |
| Schemas | Public Guardian schemas and inferred types |
Deno:
deno add jsr:@tundraconnect/coingeckoBun:
bunx jsr add @tundraconnect/coingeckoNode.js:
npx jsr add @tundraconnect/coingeckoimport { CoinGecko } from '@tundraconnect/coingecko';
const client = new CoinGecko();
const prices = await client.getPrice({
ids: ['bitcoin', 'ethereum'],
vsCurrencies: 'usd',
});
console.log(prices.bitcoin?.usd);
const markets = await client.getMarkets({ vsCurrency: 'usd', perPage: 10 });
console.log(markets[0]?.name, markets[0]?.current_price);import { CoinGecko } from '@tundraconnect/coingecko';
const client = new CoinGecko({
auth: { type: 'CUSTOM', environment: 'pro', apiKey: 'your-pro-api-key' },
});
const coins = await client.listCoins({ includePlatform: true });
console.log(coins.length);MIT. Part of Tundra Connect, typed vendor API clients for Deno, Bun, Node.js and Cloudflare Workers.