Skip to content

wuseyu/crypto-price-query

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%