crypto-price-query

1.1.1 • Public • Published

Crypto Price Query

A simple NPM package for querying the current price of cryptocurrencies.

Installation

Install with npm:

npm install crypto-price-query

Usage

First, you need to import crypto-price-query:

const getCoinPrices = require('crypto-price-query'); Then, you can use the getCoinPrices function to query the price of one or more cryptocurrencies:

getCoinPrices(['bitcoin', 'ethereum'], 'usd')
  .then(prices => console.log(prices))
  .catch(error => console.error(error));

This will return an object with the coin names as keys and their corresponding prices as values like

{
  bitcoin: { usd: 62064 },
  ethereum: { usd: 3411.79 }
}

API

getCoinPrices(coins, currency)

coins: An array of strings, containing the names of the cryptocurrencies you want to query. currency: A string representing the currency you want to query against. Defaults to 'usd'. Error Handling If an error occurs during the query, the getCoinPrices function will throw an exception. You should use a try...catch statement or the catch method of the Promise to handle this exception.

getCoinRank(coinId)

coinId: A string, containing the names of the cryptocurrency you want to query. Error Handling If an error occurs during the query, the getCoinPrices function will throw an exception. You should use a try...catch statement or the catch method of the Promise to handle this exception.

getMarketCap(coinId, currency)

coinId: A string, containing the names of the cryptocurrency you want to query. currency: A string representing the currency you want to query against. Defaults to 'usd'. Error Handling If an error occurs during the query, the getMarketCap function will throw an exception. You should use a try...catch statement or the catch method of the Promise to handle this exception.

getVolume(coinId, currency)

coinId: A string, containing the names of the cryptocurrency you want to query. currency: A string representing the currency you want to query against. Defaults to 'usd'. Error Handling If an error occurs during the query, the getVolume function will throw an exception. You should use a try...catch statement or the catch method of the Promise to handle this exception.

License

MIT

Dependencies (1)

Dev Dependencies (1)

Package Sidebar

Install

npm i crypto-price-query

Weekly Downloads

0

Version

1.1.1

License

MIT

Unpacked Size

11.6 kB

Total Files

14

Last publish

Collaborators

  • binsz