CoinPaprika JavaScript SDK
The official Node.js client library for the CoinPaprika API provides convenient access to cryptocurrency market data.See also: REST API Reference, Coverage Checker, Historical OHLCV
Installation
Install the CoinPaprika JavaScript SDK using npm:Quick Start
The following example shows how to create a client instance and fetch global market data and a list of all tickers.Using Promises
Using Async/Await
Common Use Cases
Getting Coin Information
Fetch a list of all available coins and find a specific one by its ID.Getting Ticker Data
Fetch ticker information for all coins or for a specific coin.Historical OHLCV Data
Fetch historical Open-High-Low-Close-Volume (OHLCV) data for a specific coin.Historical Ticker Data
Fetch historical ticker data for a specific coin within a date range and at a given interval.Error Handling
The client returns a Promise, so you can handle errors by chaining a.catch() block or by using a try...catch block with async/await. The error object from the underlying node-fetch library will contain details about the failure.
Available Methods
getGlobal()
- Description: Get global market overview.
getCoins()
- Description: List all coins available on Coinpaprika.
getCoin(coinId)
- Description: Get a specific coin by its ID.
coinId: e.g.,'btc-bitcoin'
getAllTickers(options)
- Description: Get tickers for all coins or a specific coin.
options(Object):coinId(String): ID of a specific coin.quotes(Array<String>): Quote currencies (e.g.,['USD', 'BTC']).
getAllTickers({ historical })
- Description: Get historical ticker data.
historical(Object):start(String): Required. Start date (e.g.,'2023-01-01').end(String): Optional. End date.limit(Number): Optional. Data points limit.quote(String): Optional. Quote currency (e.g.,'usd').interval(String): Optional. Time interval (e.g.,'1h').
getCoinsOHLCVHistorical(options)
- Description: Get historical OHLCV data for a coin.
options`(Object)**:coinId(String): Required. ID of a specific coin.quote(String): Optional. Quote currency (defaults to'usd').start(String): Required. Start date.end(String): Optional. End date.
Requirements
- Node.js 12.0 or higher
Dependencies
node-fetch: For making HTTP requests.qs: For query string handling.
License
This library is available under the MIT license. See the LICENSE file for more info.FAQs
How do I authenticate with the JS SDK?
How do I authenticate with the JS SDK?
Create the client with your key when needed or configure HTTP headers before calls; free endpoints work without a key.
How do I find a coin_id for methods like getCoin or getAllTickers?
How do I find a coin_id for methods like getCoin or getAllTickers?
Use the Coverage Checker to look up canonical IDs such as
btc-bitcoin.How do I get historical OHLCV data?
How do I get historical OHLCV data?
Use
getCoinsOHLCVHistorical({ coinId, start, end, quote }) with an API key.What’s the recommended error handling pattern?
What’s the recommended error handling pattern?
Wrap calls in
try/catch (async/await) or chain .catch(), and back off on 429 Too Many Requests.