CoinPaprika JavaScript SDK
The official Node.js client library for the CoinPaprika API provides convenient access to cryptocurrency market data.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.