This library provides convenient way to use Coinpaprika.com API in NodeJS.
Coinpaprika delivers full market data to the world of crypto: coin prices, volumes, market caps, ATHs, return rates and more.
npm install @coinpaprika/api-nodejs-clientRequires Node.js 18 or newer (uses the built-in global fetch). If you need to support Node 14–17, stay on the 2.x line.
const CoinpaprikaAPI = require('@coinpaprika/api-nodejs-client');
const client = new CoinpaprikaAPI();
client.getGlobal().then(console.log).catch(console.error);
client.getCoin('btc-bitcoin').then(console.log).catch(console.error);import CoinpaprikaAPI from '@coinpaprika/api-nodejs-client';
const client = new CoinpaprikaAPI();
const data = await client.getGlobal();Type declarations ship with the package — no @types install needed.
import CoinpaprikaAPI from '@coinpaprika/api-nodejs-client';
const client = new CoinpaprikaAPI({ apiKey: process.env.COINPAPRIKA_KEY });
const markets = await client.getCoinMarkets('btc-bitcoin', { quotes: ['USD', 'BTC'] });Check out the Coinpaprika API documentation for more information!
const client = new CoinpaprikaAPI({
version: 'v1', // API version (default 'v1')
pro: true, // Use Pro host (api-pro.coinpaprika.com). Default false.
baseUrl: 'https://api.coinpaprika.com',// Override entirely (wins over `pro`)
apiKey: process.env.COINPAPRIKA_KEY, // Sent as `Authorization: <key>` per Coinpaprika docs (no Bearer prefix)
retry: { attempts: 3, delay: 300 }, // Opt-in retry on 408/425/429/5xx & network errors (exponential backoff)
config: { // Passed straight to fetch(url, config)
headers: { 'User-Agent': 'my-app/1.0' },
signal: controller.signal // AbortSignal for cancellation (see below)
},
fetcher: customFetch // Optional: override the fetch implementation
});Pro-tier endpoints (getCoinsMappings, getChangelogIds, getKeyInfo, and some fields on public endpoints) require an API key and the Pro host (https://api-pro.coinpaprika.com). The client sends the key exactly as documented — Authorization: <key> (no Bearer prefix).
const client = new CoinpaprikaAPI({
pro: true,
apiKey: process.env.COINPAPRIKA_KEY
});
await client.getKeyInfo();Client-wide (all calls on this client share the signal):
const controller = new AbortController();
const client = new CoinpaprikaAPI({ config: { signal: controller.signal } });
const p = client.getCoins();
setTimeout(() => controller.abort(), 100);
try { await p } catch (e) { /* AbortError */ }Per-call via withSignal(signal) — returns a new client bound to that signal; the original is untouched:
const client = new CoinpaprikaAPI();
const controller = new AbortController();
const p = client.withSignal(controller.signal).getCoins();
setTimeout(() => controller.abort(), 100);
try { await p } catch (e) { /* AbortError on the scoped call only */ }
// The parent client keeps working:
await client.getGlobal();Opt in via retry. Retries only on transient failures (408, 425, 429, 500–504, network errors); 2xx/4xx (besides the above) are returned as-is. Exponential backoff: delay * 2^(attempt-1).
const CoinpaprikaAPI = require('@coinpaprika/api-nodejs-client')
const client = new CoinpaprikaAPI()client.getGlobal() // Global market overview
client.getCoins() // List all coins
client.getCoin('btc-bitcoin') // Coin details
client.getCoin('btc-bitcoin', { quotes: ['USD', 'BTC'] }) // Coin details with quotes
getTickerandgetAllTickerswere removed in 3.0.0 (upstream/tickerendpoint is deprecated). UsegetCoin,getCoinsOHLCVLatest, andgetCoinsOHLCVHistoricalinstead. See the CHANGELOG for migration snippets.
client.getCoinsOHLCVLatest('btc-bitcoin') // Latest full day OHLCV
client.getCoinsOHLCVToday('btc-bitcoin') // Today's OHLCV (live)
client.getCoinsOHLCVHistorical({ coinId: 'btc-bitcoin', start: '2024-01-01' }) // Historicalclient.getCoinTwitter('btc-bitcoin') // Twitter timeline
client.getCoinEvents('btc-bitcoin') // Coin events
client.getCoinExchanges('btc-bitcoin') // Exchanges listing coin
client.getCoinMarkets('btc-bitcoin', { quotes: ['USD', 'BTC'] }) // Markets for coin (array or CSV string)
client.getCoinsMappings() // ID mappings (Pro)client.getExchanges() // List all exchanges
client.getExchange('binance') // Exchange details
client.getExchangeMarkets('binance', { quotes: ['USD', 'BTC'] }) // Markets on exchange (array or CSV string)client.getPlatforms() // List contract platforms
client.getContracts('eth-ethereum') // Contracts on Ethereum
client.getTickerByContract('eth-ethereum', '0xdac1...') // Ticker by contract
client.getHistoricalByContract('eth-ethereum', '0xdac1...', { start: '2024-01-01' })client.search({ q: 'bitcoin', c: 'currencies', limit: 10 })
client.priceConverter({ base_currency_id: 'btc-bitcoin', quote_currency_id: 'usd-us-dollars', amount: 1 })
client.getPeople('satoshi-kobayashi') // Person details
client.getTags() // List tags
client.getTag('blockchain-service') // Tag details
client.getKeyInfo() // API key info (requires key)
client.getChangelogIds() // Recent changelog IDs (Pro)- Any param that accepts multiple values (e.g.
quotes,cforsearch) can be passed as either a CSV string or an array; arrays are joined with commas automatically before being sent to the API. - Required params are validated synchronously and throw a descriptive
Errorbefore any network call (e.g.client.search({})throws"q (search query) is required").
See CHANGELOG.md for release notes.
CoinpaprikaAPI is available under the MIT license. See the LICENSE file for more info.