CoinDesk API client
Node.js client written in Javascript for CoinDesk API service.
If you like this package please give it a ⭐️ in the Github repo.
Features
- Get Bitcoin current price
- Get Bitcoin historical price
Getting Started
These instructions will get you a copy of the project on your local system.
Dependencies
CoinDesk API client for node.js uses a number of open source projects to work properly:
- @hapi/joi - The most powerful schema description language and data validator for Javascript
- axios - Promise based HTTP client for the browser and node.js
- node-fetch - A light-weight module that brings window.fetch to node.js
- winston - A logger for just about everything
And of course CoinDesk API client for node.js itself is open source with a public repository on GitHub.
Installation
Install the npm package from npmjs.com with the command:
npm install --save coindesk
Quick Start
A series of simple examples for Bitcoin price fetching:
Get currentprice price for Bitcoin in json format
const CoindeskAPIClient = ;const apiClient = CoindeskAPIClientstart'currentprice';const response = apiClient ;
Get currentprice price for Bitcoin in other currency than USD
const CoindeskAPIClient = ;const apiClient = CoindeskAPIClientstart'currentprice' currency: 'EUR' ;const response = apiClient ;
Get historical price for Bitcoin in json format
const CoindeskAPIClient = ;const apiClient = CoindeskAPIClientstart'historical';const response = apiClient ;
Get historical price for Bitcoin providing optional parameters
const CoindeskAPIClient = ;const apiClient = CoindeskAPIClientstart'historical' currency: 'EUR' for: 'yesterday' ;const response = apiClient ;
Get raw http response for either currentprice or historical (defaults to false)
const CoindeskAPIClient = ;const apiClient = CoindeskAPIClientstart'currentprice';const response = apiClient ;
Get supported currencies to fetch Bitcoin price in
const CoindeskAPIClient = ;const apiClient = ;const supportedCurrencies = apiClient;
Examples for CoinDesk API response parsing (currentprice or historical):
Parse and validate fetched Bitcoin price response
const CoindeskAPIClient CoindeskAPIResponse = ;const dataType = 'historical';const apiClient = dataType;const response = apiClient ;
Get info from parsed Bitcoin price response
const CoindeskAPIResponse = ;const parsedResponse = CoindeskAPIResponse;const apiResponse = parsedResponseresponse;const jsonResponse = parsedResponseJSONResponse;const items = parsedResponseresponseItems;const bpi = parsedResponse;
Full documentation for CoinDesk API is available at https://www.coindesk.com/api/.
License
MIT
Free Software. Hell Yeah!