safe-exchange-rate

1.2.1 • Public • Published

safe-exchange-rate

Build Status Code Style Known Vulnerabilities

Safely get exchange rates from different providers. If any provider is down or failing, a different one from an internal list will be used.

The following exchange rate pairs are currently supported:

  • BAT:USD
  • ETH:USD
  • DAI:USD
  • ETC:USD
  • KNC:USD
  • MANA:USD
  • QTUM:USD
  • USDC:USD
  • WBTC:USD
  • ZRX:USD

Only 100% open and free providers are queried:

Installation

npm install safe-exchange-rate

Usage

const getExchangeRate = require('safe-exchange-rate')

getExchangeRate('ETH:USD').then(function (rate) {
  console.log(rate) // 225.68
}

API

getExchangeRate(pair) ⇒ Promise<number>

Obtain the exchange rate between two assets given list of providers. If one fails for any reason, the next in the list is used. The providers include: Bittrex, CoinCap, CoinGecko.

Returns: Promise<number> - The exchange rate.

Param Type Description
pair string The rate pair like ETH:USD.

License

MIT

Package Sidebar

Install

npm i safe-exchange-rate

Weekly Downloads

1

Version

1.2.1

License

MIT

Unpacked Size

9.4 kB

Total Files

7

Last publish

Collaborators

  • gndelia
  • gabmontes