CoinGecko API Client for Node.js

1.0.10 · abandoned · verified Wed Apr 22

This package, `coingecko-api`, is a Node.js wrapper for the CoinGecko API, notable for its explicit lack of external dependencies. The current stable version, 1.0.10, was published over six years ago and appears to be largely unmaintained. While the CoinGecko API itself is actively developed with frequent updates and breaking changes, this particular wrapper does not reflect those ongoing developments, including new endpoints, security updates, or changes in data structures. As such, it differentiates itself by being dependency-free but offers an outdated interface to the CoinGecko API. Newer community-driven wrappers, often with TypeScript support, have emerged to keep pace with the official API's evolution.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates initializing the CoinGecko API client, making a simple ping request, fetching Bitcoin's price, and listing top coins by market cap using an internal constant.

const CoinGecko = require('coingecko-api');

const CoinGeckoClient = new CoinGecko();

const fetchPingAndBitcoinPrice = async () => {
  try {
    // Ping the API to check connectivity
    let pingData = await CoinGeckoClient.ping();
    console.log('API Ping Status:', pingData.data.gecko_says);

    // Get current price of Bitcoin in USD
    let bitcoinPrice = await CoinGeckoClient.simple.price({
      ids: 'bitcoin',
      vs_currencies: 'usd'
    });
    console.log('Bitcoin Price (USD):', bitcoinPrice.data.bitcoin.usd);

    // Example using a constant for ordering results
    let markets = await CoinGeckoClient.coins.markets({
      vs_currency: 'usd',
      order: CoinGecko.ORDER.MARKET_CAP_DESC,
      per_page: 5
    });
    console.log('Top 5 Coins by Market Cap:', markets.data.map(coin => coin.name));

  } catch (error) {
    console.error('Error fetching data from CoinGecko:', error.message);
  }
};

fetchPingAndBitcoinPrice();

view raw JSON →