npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@amrulizwan/coingecko-client

v1.0.0

Published

Professional JavaScript SDK for CoinGecko API with comprehensive cryptocurrency data access

Readme

CoinGecko Client

Professional JavaScript SDK for seamless integration with CoinGecko API. Access comprehensive cryptocurrency market data, prices, charts, and exchange information with built-in error handling and TypeScript-friendly design.

Features

  • 🚀 Easy Integration - Simple and intuitive API design
  • 📊 Complete Coverage - Access to all major CoinGecko endpoints
  • 🔒 Error Handling - Robust error handling with descriptive messages
  • Performance - Optimized HTTP client with configurable timeouts
  • 🎯 Flexible - Support for both free and pro API keys
  • 📦 Lightweight - Minimal dependencies

Installation

npm install coingecko-client

Quick Start

const CoinGeckoClient = require('coingecko-client');

const client = new CoinGeckoClient();

async function getCryptoPrices() {
  try {
    const prices = await client.getSimplePrice('bitcoin,ethereum', 'usd');
    console.log(prices);
  } catch (error) {
    console.error('Error:', error.message);
  }
}

getCryptoPrices();

Configuration

const client = new CoinGeckoClient({
  timeout: 10000,
  apiKey: 'your-pro-api-key',
});

Options

| Option | Type | Default | Description | | ----------- | ------ | ------- | -------------------------------------------- | | timeout | number | 10000 | Request timeout in milliseconds | | apiKey | string | null | CoinGecko Pro API key for higher rate limits |

API Methods

Basic Price Data

getSimplePrice(ids, vsCurrencies, options)

Get current prices for cryptocurrencies in specified currencies.

const prices = await client.getSimplePrice('bitcoin', 'usd');

const multiplePrices = await client.getSimplePrice(['bitcoin', 'ethereum'], ['usd', 'eur'], {
  include_market_cap: true,
  include_24hr_change: true,
  include_last_updated_at: true,
});

getSupportedVsCurrencies()

Get list of all supported fiat currencies and cryptocurrencies.

const currencies = await client.getSupportedVsCurrencies();

Coin Information

getCoinsList(includePlatform)

Get list of all supported coins with id, name, and symbol.

const coins = await client.getCoinsList();
const coinsWithPlatform = await client.getCoinsList(true);

getCoinById(id, options)

Get detailed information about a specific coin.

const bitcoin = await client.getCoinById('bitcoin');

const bitcoinDetailed = await client.getCoinById('bitcoin', {
  localization: false,
  tickers: true,
  marketData: true,
  communityData: true,
  developerData: true,
  sparkline: true,
});

getCoinsMarkets(vsCurrency, options)

Get market data for multiple coins.

const marketData = await client.getCoinsMarkets('usd');

const customMarketData = await client.getCoinsMarkets('usd', {
  order: 'market_cap_desc',
  perPage: 50,
  page: 1,
  sparkline: false,
  priceChangePercentage: '1h,24h,7d',
});

Historical Data

getCoinHistory(id, date, localization)

Get historical data for a coin on a specific date.

const history = await client.getCoinHistory('bitcoin', '30-12-2023');

getCoinMarketChart(id, vsCurrency, days, options)

Get market chart data (price, market cap, volume).

const chartData = await client.getCoinMarketChart('bitcoin', 'usd', 7);

const hourlyData = await client.getCoinMarketChart('ethereum', 'usd', 1, {
  interval: 'hourly',
});

getCoinMarketChartRange(id, vsCurrency, from, to)

Get market chart data within a specific date range.

const fromTimestamp = Math.floor(Date.now() / 1000) - 30 * 24 * 60 * 60;
const toTimestamp = Math.floor(Date.now() / 1000);

const rangeData = await client.getCoinMarketChartRange('bitcoin', 'usd', fromTimestamp, toTimestamp);

getCoinOHLC(id, vsCurrency, days)

Get OHLC (Open, High, Low, Close) data.

const ohlcData = await client.getCoinOHLC('bitcoin', 'usd', 7);

Exchange Data

getExchangesList()

Get list of all exchanges.

const exchanges = await client.getExchangesList();

getExchangeById(id)

Get detailed information about a specific exchange.

const binance = await client.getExchangeById('binance');

getExchangeTickers(id, options)

Get tickers from a specific exchange.

const tickers = await client.getExchangeTickers('binance');

const filteredTickers = await client.getExchangeTickers('binance', {
  coinIds: 'bitcoin,ethereum',
  includeExchangeLogo: true,
  page: 1,
  depth: true,
  order: 'trust_score_desc',
});

Global Market Data

getGlobalData()

Get global cryptocurrency market data.

const globalData = await client.getGlobalData();
console.log('Total Market Cap:', globalData.data.total_market_cap.usd);
console.log('Market Cap Change 24h:', globalData.data.market_cap_change_percentage_24h_usd);

getGlobalDeFiData()

Get global DeFi market data.

const defiData = await client.getGlobalDeFiData();

Trending & Search

getTrendingCoins()

Get trending cryptocurrencies.

const trending = await client.getTrendingCoins();
console.log('Trending coins:', trending.coins);
console.log('Trending NFTs:', trending.nfts);

searchCoins(query)

Search for coins, exchanges, and categories.

const searchResults = await client.searchCoins('bitcoin');

Utility

ping()

Check API server status.

const status = await client.ping();

Error Handling

The SDK provides comprehensive error handling with descriptive error messages:

try {
  const data = await client.getCoinById('invalid-coin-id');
} catch (error) {
  if (error.message.includes('CoinGecko API Error: 404')) {
    console.log('Coin not found');
  } else if (error.message.includes('Network Error')) {
    console.log('Connection issue');
  } else {
    console.log('Other error:', error.message);
  }
}

Error Types

  • API Errors: HTTP errors from CoinGecko API (400, 404, 429, 500, etc.)
  • Network Errors: Connection timeouts or network issues
  • Request Errors: Invalid parameters or malformed requests

Rate Limiting

CoinGecko API has rate limits:

  • Free Plan: 10-30 calls/minute
  • Pro Plan: Higher limits with API key
const client = new CoinGeckoClient({
  apiKey: 'your-pro-api-key',
});

Examples

Run example scripts:

npm run example:basic
npm run example:advanced

Testing

npm test
npm run test:watch
npm run test:coverage

API Reference

For complete API documentation, visit: CoinGecko API Documentation

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT License - see the LICENSE file for details.

Support

Disclaimer

This library is not officially affiliated with CoinGecko. Use at your own risk and ensure compliance with CoinGecko's Terms of Service.