Convert a value from one currency to another according to exchange rate of a certain day.


022.0.73 years ago6 years agoMinified + gzip package size for @divvit/currency-converter in KB


Currency Converter

A small library to convert currencies according to the EZB exchange rates.


npm install @divvit/currency-converter --save


  var converter = require('@divvit/currency-converter')();
  // if you want to change the storage path, call the script like that:
  // var converter = require('@divvit/currency-converter')({ storageDir: '/some/other/path' });
  // the default path is process.env.TMPDIR

  var moment = require('moment');

  var eurValue = 10;
  var conversionDate = moment('2015-01-01');
  converter.convert(eurValue, conversionDate, 'EUR', 'USD', function(err, usdResult) {
    if (err)
      return callback(err);

    console.log('Converted ' + eurValue + ' EUR to ' + usdResult.value + ' USD, according to FX rate of ' . usdResult.usedDate.format('DD.MM.YYYY') );

Important Notes:

  • If the queried day exists in the cache then the library uses the queried day for conversion.
  • If the queried day does not exit the library will try to use the nearst day before.


npm test


Nino Ulsamer, Divvit AB

Release History

  • 2.0.0 Fix currency file updates.
  • 2.0.0 Uses data in-memory and binary-search and includes and enriched response.
  • 1.0.3 Fixed issue #1: round currency conversion results to max 2 digits
  • 1.0.2 Changed default working directory to __dirname
  • 1.0.1 Improved README formatting
  • 1.0.0 Initial release

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.