live-currency-rates
v1.1.1
Published
Convert currencies with live exchange rates. Fluent API: Convert(100).from('USD').to('EUR'). Multiple providers (free, no key by default) — Frankfurter, fawazahmed0, AllRatesToday. Zero dependencies.
Maintainers
Readme
live-currency-rates
Convert currencies with live exchange rates. Simple, fluent API. Multiple providers — use a free one (no key) or bring your own.
Install
npm install live-currency-ratesQuick Start (no key)
import { Convert } from 'live-currency-rates';
const result = await Convert(100).from('USD').to('EUR');
console.log(result.amount); // 92.45By default, the package uses the free Frankfurter provider (ECB data) — no signup, no API key.
Providers
Pick a provider based on your needs:
| Provider | Key? | Currencies | Source | Notes |
| ------------- | ----- | ---------- | ------------------------- | ----------------------------- |
| frankfurter | no | ~30 | European Central Bank | Default. Daily updates. |
| fawaz | no | 200+ | fawazahmed0/currency-api | Includes crypto. CDN-hosted. |
| allrates | yes | 160+ | AllRatesToday (Reuters) | Real-time mid-market rates. |
Choose a provider with setup():
import { setup, Convert } from 'live-currency-rates';
// Free, no key — 200+ currencies including crypto
setup({ provider: 'fawaz' });
// AllRatesToday — get a free key at https://allratestoday.com/register
setup({ apiKey: 'art_live_...' });API
Convert(amount).from('XXX').to('YYY')
const result = await Convert(250).from('GBP').to('JPY');
console.log(`250 GBP = ${result.amount} JPY`);
console.log(`Rate: ${result.rate}`);Returns: { amount, rate, from, to, originalAmount }
Rate('XXX').to('YYY')
import { Rate } from 'live-currency-rates';
const { rate } = await Rate('USD').to('EUR');
console.log(`1 USD = ${rate} EUR`);Rates('XXX', ['YYY', 'ZZZ'])
import { Rates } from 'live-currency-rates';
const rates = await Rates('USD', ['EUR', 'GBP', 'JPY']);
// { EUR: 0.92, GBP: 0.78, JPY: 149.5 }Omit the target list to get all available rates for the base currency.
Symbols()
import { Symbols } from 'live-currency-rates';
const symbols = await Symbols();
// { USD: 'United States Dollar', EUR: 'Euro', ... }setup(config)
setup({
provider: 'frankfurter' | 'fawaz' | 'allrates',
apiKey: 'art_live_...', // only for provider: 'allrates'
baseUrl: '...', // optional override
timeout: 10000, // ms, default 10000
});CommonJS
const { Convert } = require('live-currency-rates');
Convert(100).from('USD').to('EUR').then(r => console.log(r.amount));License
MIT
