@y2nk4/currency-converter
v1.1.0
Published
A currency converter based on currencyconverterapi.com's api
Downloads
11
Maintainers
Readme
node-currency-converter
A currency converter based on currencyconverterapi.com's api
About
Feature
:fire: Support most of the currency
:smiley: Using Promise
What is this module doing?
This module is based on currencyconverterapi.com, it will request this api to get the exchange rate between two currency.
You can get the api key from free.currencyconverterapi.com
The key used in the example is an example key from currencyconverterapi.com. But according to currencyconverterapi.com, you MUST NOT use this key, and it will get you banned.
Install via npm
npm i @y2nk4/currency-converter
Examples
let CurrencyConverter = require('@y2nk4/currency-converter')
// Please don't use this sample API key in your environment.
// Doing so will get you banned.
// You may get your free API key at free.currencyconverterapi.com
let converter = new CurrencyConverter('do-not-use-this-key')
converter.convert('USD', 'CNY', 100)
.then(console.log, console.error)
// returns 654.0698
const func = async () => {
let audValue = await converter.convert('USD', 'AUD', 1, false, '2019-12-26')
console.log(audValue)
}
func()
// returns 1.439797
Methods
convert(fromCurrency, toCurrency, [baseAmount = 1.0], [isRaw = false], [date])
fromCurrency
- three-digit currency code for currency you want to convert from, ex:USD
toCurrency
- three-digit currency code for currency you want to convert to, ex:CNY
baseAmount
- the amount you want to exchange, float, default:1.0
isRaw
- set it to betrue
if you want it to return raw data from the api, default:false
date
- historical single date for data to be pulled from, ex:2020-07-15
This method returns the conversion amount in a float number
conversion_amount
- Float Number ifisRaw
set to be false