Skip to content

CoinGecko

github-actions[bot] edited this page Oct 4, 2026 · 2 revisions

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.

JSR JSR Score

Overview

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.

Testing your code

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.

Documentation

Topic Description
API Client configuration and endpoint methods
Errors Error codes and diagnostic metadata
Schemas Public Guardian schemas and inferred types

Upstream

Installation

Deno:

deno add jsr:@tundraconnect/coingecko

Bun:

bunx jsr add @tundraconnect/coingecko

Node.js:

npx jsr add @tundraconnect/coingecko

Quick Start

Keyless (demo tier)

import { 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);

Pro tier

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);

License

MIT. Part of Tundra Connect, typed vendor API clients for Deno, Bun, Node.js and Cloudflare Workers.

Clone this wiki locally