exchangeio

Make exchange calculations in just a few lines of code.

Usage no npm install needed!

<script type="module">
  import exchangeio from 'https://cdn.skypack.dev/exchangeio';
</script>

README

Exchangeio

Make exchange calculations in just a few lines of code.

Learning to use:

Import the package

const exchangeio = require('exchangeio')

or

import exchangeio from 'exchangeio'

To check the availability of currencies for exchange use:

import exchangeio from 'exchangeio'

exchangeio.check('USD')
    .then(valid => {
        console.log(valid)
    })

The answer can be either true or false.

The verification can also be done asynchronously:

import exchangeio from 'exchangeio'

(async function () {
  console.log(await exchangeio.check('BRL'))
}())

There are two possibilities for exchanging currencies:

import exchangeio from 'exchangeio'

exchangeio.convert({
  from: 'BRL',
  to: 'USD',
  amount: 25
})
  .then(result => {
    console.log(result)
  })

or

import exchangeio from 'exchangeio'

(async function () {
  console.log(await exchangeio.convert({ from: 'USD', to: 'BRL', amount: 2 }))
}())

It is important that the check() function is called before calling the convert() method to avoid an error in the application, knowing that the check() function checks whether the reported currency is available to be exchanged.

To get all currencies:

import exchangeio from 'exchangeio'

(async function () {
  console.log(await exchangeio.currencies())
}())