money.js Exchange Rates: Load Live Rates into fx() Free

money.js (npm "money") converts currencies but ships no rates. Load them free with no key from the ECB table, or real-time for 160+ currencies, using money-rates: the same fx(100).from('USD').to('GBP') API with fx.load() built in.

By Madhushan, Founder & Lead Developer

Exchange rates for money.js, with no app ID

money.js (npm install money) is the most installed currency conversion library on npm, with about 80,000 downloads a month. It does the arithmetic, fx(100).from('USD').to('GBP'), but it ships no rates: every project has to fetch a feed and copy it into fx.rates by hand, usually from a service that needs an app ID. The last release was 0.2.0, in 2014.

money-rates is money.js with the rates built in. Same API, plus fx.load(). No key for the ECB table; a free key for real-time rates in 160+ currencies.

Before and after

Before, with money.js:

const fx = require('money');

// money.js has no rates of its own: you fetch a feed and copy it in by hand
const data = await fetch('https://openexchangerates.org/api/latest.json?app_id=YOUR_APP_ID').then(r => r.json());
fx.base = data.base;
fx.rates = data.rates;

fx(100).from('USD').to('GBP');

After, with money-rates:

const fx = require('money-rates');   // npm install money-rates

await fx.load();                      // keyless ECB rates, base USD
fx(100).from('USD').to('GBP');        // same API as money.js

Keep money.js, swap only the rates

If money.js is used all over a codebase, leave it alone and fill its rates:

const money = require('money');
const { loadInto } = require('money-rates');

await loadInto(money);                // fills money.base and money.rates
money(100).from('USD').to('EUR');

Real-time rates for 160+ currencies

The keyless table is the European Central Bank's, about 30 currencies, updated once per business day. For live mid-market rates, pass a free API key:

await fx.load({ apiKey: process.env.ALLRATESTODAY_API_KEY });
fx(100).from('USD').to('NGN');        // 160+ currencies, refreshed every 60 seconds

Without any package

The keyless endpoint returns base_code and rates in a shape money.js accepts directly:

const r = await fetch('https://allratestoday.com/api/open/latest/USD').then(x => x.json());
fx.base = r.base_code;
fx.rates = r.rates;

What is the same, what is new

Featuremoney.jsmoney-rates
fx(v).from(a).to(b), fx.convert, arraysYesYes, same results
fx.rates, fx.base, fx.settingsYesYes
Cross rates through the baseYesYes, same formula
Rates includedNofx.load(): ECB keyless, or live with a key
TypeScript types, ESMNoYes
accounting.js formatting helpersOptionalNo; use Intl.NumberFormat
Last release20142026

Attribution

Keyless rates are free for any use, commercial included. Where the rates are shown, add a visible link: <a href="https://allratestoday.com">Exchange rates by AllRatesToday</a>. fx.attributionHtml holds that snippet. Details in the attribution terms.

Frequently asked questions

Does money.js include exchange rates?

No. money.js (the npm package "money") only does the arithmetic. You set fx.base and fx.rates yourself, usually from an Open Exchange Rates feed that needs an app ID. Its last release was 0.2.0 in 2014.

Is money-rates a drop-in replacement for money.js?

Yes for the conversion API: fx(value).from().to(), fx.convert(value, {from, to}) with numbers or arrays, fx.rates, fx.base and fx.settings behave the same, cross rates included. It adds fx.load() and fx.loadInto(money) to fetch rates. The accounting.js formatting helpers are not included.

Are the rates free?

Without a key, fx.load() uses the European Central Bank reference table (about 30 currencies, any base, updated each business day), free for any use including commercial, with a visible link to allratestoday.com where the rates are shown. A free key adds real-time mid-market rates for 160+ currencies.

Can I keep using money.js?

Yes. Call loadInto(require('money')) from money-rates and it fills money.base and money.rates; the rest of your code is unchanged.

Install it

npm install money-rates, then await fx.load().

money-rates on npm Get a free API key

Related