@y2nk4/currency-converter

1.1.0 • Public • Published

node-currency-converter

A currency converter based on currencyconverterapi.com's api

Build Status Coverage Status

About

Feature

🔥 Support most of the currency

😃 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 be true 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 if isRaw set to be false

/@y2nk4/currency-converter/

    Package Sidebar

    Install

    npm i @y2nk4/currency-converter

    Weekly Downloads

    1

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    6.81 kB

    Total Files

    8

    Last publish

    Collaborators

    • y2nk4