Node.js and JavaScript: Exchange Rate APIs Compared with Code
JavaScript runs everywhere — browsers, Node.js servers, Cloudflare Workers, Deno, Bun, serverless functions. If you are building anything that touches money, prices, or international users, you need exchange rate data. And you need an API that fits naturally into the JavaScript and TypeScript ecosystem: an npm package you can install, proper types, and async/await support out of the box.
Several currency APIs offer only a REST endpoint and leave you to write the HTTP wrapper, error handling and caching yourself. Some have npm packages maintained by community members rather than the vendor. Most restrict features such as historical rates or non-USD/EUR base currencies to paid plans. None of that is disqualifying, but it matters when you are picking one for a codebase you will maintain.
This article compares 6 widely used exchange rate APIs for JavaScript and Node.js developers. We look at SDK quality, TypeScript support, free-tier limits, update frequency, and integration patterns. Vendor facts (free-tier caps, update frequency, entry prices) were re-checked against each provider's public pricing page on 24 October 2026. Disclosure: AllRatesToday publishes this blog, so read the sections on our own API with that in mind; we have tried to keep every claim specific and checkable, and the "Which one should you pick" section recommends competitors where they are the better fit.
Side-by-Side Comparison
Here is how the top 6 exchange rate APIs compare for JavaScript and Node.js developers:
| API | JS/TS SDK | npm Package | Free Tier | WebSocket | Update Speed |
|---|---|---|---|---|---|
| AllRatesToday | Official + Types | @allratestoday/sdk | Free, no CC | Planned | 60 seconds |
| Open Exchange Rates | Community only | open-exchange-rates | 1,000 req/mo | No | Hourly |
| Fixer.io | No | None | 100 req/mo | No | Hourly |
| CurrencyAPI | Official | @everapi/currencyapi-js | 300 req/mo | No | Daily |
| Frankfurter | No | None | Keyless, no caps | No | Daily (ECB) |
| ExchangeRate-API | No | None | 1,500 req/mo | No | Daily |
Key takeaway: Two of the six ship an official npm package (AllRatesToday and CurrencyAPI). AllRatesToday updates every 60 seconds; Open Exchange Rates and Fixer update hourly on their free tiers; the rest are daily. Frankfurter is the only keyless option with no request caps. Historical data is free on Fixer, currencylayer and exchangeratesapi.io (non-commercial), and paid on the others.
1. AllRatesToday — Official npm SDK, 60-Second Updates
AllRatesToday provides an official JavaScript/TypeScript SDK published on npm. It supports ESM and CommonJS, includes full type definitions, and works in Node.js, Deno, Bun, and edge runtimes such as Cloudflare Workers. Use it on the server: an API key in browser code is public. The API delivers mid-market rates for 160+ currencies, refreshed every 60 seconds.
Install the SDK
npm install @allratestoday/sdk Or with yarn/pnpm:
yarn add @allratestoday/sdk
# or
pnpm add @allratestoday/sdk Get a single exchange rate
import AllRatesToday from '@allratestoday/sdk';
const client = new AllRatesToday({ apiKey: 'YOUR_API_KEY' });
// Fetch real-time USD to EUR rate
const { rate } = await client.getRate('USD', 'EUR');
console.log(`1 USD = ${rate} EUR`); Convert an amount
const result = await client.convert('USD', 'EUR', 1000);
console.log(`$1,000 = €${result.result}`);
console.log(`Rate: ${result.rate}`); Fetch historical rates (paid plans)
const history = await client.getHistoricalRates('USD', 'EUR', '30d');
// { source, target, period, data: [{ date, rate, timestamp }, ...] }, oldest first
history.data.forEach(point => {
console.log(`${point.date}: ${point.rate}`);
}); Using fetch directly (no SDK)
If you prefer native fetch without installing a package:
const API_KEY = 'YOUR_API_KEY';
const response = await fetch(
'https://allratestoday.com/api/v1/rates?source=USD&target=EUR',
{
headers: { 'Authorization': `Bearer ${API_KEY}` }
}
);
// Always an array of rows: [{ rate, source, target, time }]
const [data] = await response.json();
console.log(`1 USD = ${data.rate} EUR`);
console.log(`Updated: ${data.time}`); TypeScript with full type safety
import AllRatesToday from '@allratestoday/sdk';
interface ConversionResult {
from: string;
to: string;
amount: number;
result: number;
rate: number;
}
const client = new AllRatesToday({ apiKey: 'YOUR_API_KEY' });
async function convertCurrency(
from: string,
to: string,
amount: number
): Promise<ConversionResult> {
const result = await client.convert(from, to, amount);
return result as ConversionResult;
}
const conversion = await convertCurrency('USD', 'JPY', 5000);
console.log(`$5,000 = ¥${conversion.result.toLocaleString()}`); npm: @allratestoday/sdk — View on GitHub
- Data source: aggregated market data; see our data sources page
- Update frequency: Every 60 seconds
- Currencies: 160+ including majors, minors, and exotics
- Rate type: Mid-market (no bank markup)
- Free tier: free API key, no credit card required (non-commercial; historical data on paid plans from €4.99/mo)
- TypeScript: Built-in type definitions, no @types package needed
2. Open Exchange Rates
Open Exchange Rates is one of the older currency APIs, launched in 2012. There is no official npm package. The community-maintained open-exchange-rates package exists but is not actively updated and lacks TypeScript types.
// No official SDK - using fetch
const APP_ID = 'YOUR_APP_ID';
const response = await fetch(
`https://openexchangerates.org/api/latest.json?app_id=${APP_ID}&base=USD`
);
const data = await response.json();
const eurRate = data.rates.EUR;
console.log(`1 USD = ${eurRate} EUR`); - Free tier: 1,000 requests/month, USD base only
- Update frequency: Hourly on free, more frequent on paid
- Paid from: $12/mo
- Limitation: Free plan locked to USD as base currency
- npm package: Community only, no TypeScript types
3. Fixer.io
Fixer is now part of APILayer. There is no official npm package, so you write HTTP calls yourself. The free tier allows 100 requests per month with EUR as the only base currency, but it does include hourly updates, HTTPS and historical rates (non-commercial use). Paid plans start at $14.99/mo and unlock other base currencies.
const API_KEY = 'YOUR_API_KEY';
const response = await fetch(
`https://data.fixer.io/api/latest?access_key=${API_KEY}&base=EUR&symbols=USD,GBP,JPY`
);
const data = await response.json();
console.log(data.rates); - Free tier: 100 requests/month, EUR base only, HTTPS, historical included, non-commercial
- Update frequency: Hourly
- Paid from: $14.99/mo
- Limitation: Very low free request cap, EUR base only on free, no SDK
- npm package: None
4. CurrencyAPI
CurrencyAPI (currencyapi.com) offers an official npm package (@everapi/currencyapi-js), which is a notable advantage. The free tier allows 300 requests per month with daily rate updates; paid plans start at $9.99/mo.
// npm install @everapi/currencyapi-js
import CurrencyAPI from '@everapi/currencyapi-js';
const client = new CurrencyAPI('YOUR_API_KEY');
const result = await client.latest({
base_currency: 'USD',
currencies: 'EUR,GBP,JPY'
});
Object.entries(result.data).forEach(([code, info]) => {
console.log(`USD/${code}: ${info.value}`);
}); - Free tier: 300 requests/month
- Update frequency: Daily on free tier
- Paid from: $9.99/mo
- npm package: Official (@everapi/currencyapi-js)
- Limitation: Historical data requires paid plan, low free request limit
5. Frankfurter
Frankfurter is a free, open-source API that serves European Central Bank (ECB) data. No API key is needed and there are no request caps, which makes it a good default for hobby projects and prototypes. It updates once daily when the ECB publishes (around 16:00 CET) and carries ECB history back to 1999. There is no official npm package.
// No API key needed, no SDK
const response = await fetch(
'https://api.frankfurter.app/latest?from=USD&to=EUR,GBP,JPY'
);
const data = await response.json();
console.log(`Date: ${data.date}`);
Object.entries(data.rates).forEach(([currency, rate]) => {
console.log(`USD/${currency}: ${rate}`);
}); - Free tier: Keyless, no request caps, ECB history back to 1999
- Update frequency: Daily (ECB publishes at 16:00 CET)
- Currencies: ~30 on v1; 165+ on the 2026 v2 (official sources)
- Limitation: Official daily fixings only — no real-time market data, no weekend updates, no support/SLA
- npm package: None
6. ExchangeRate-API
ExchangeRate-API provides a straightforward REST interface with no SDK. The free tier allows 1,500 requests per month with daily updates; historical data is on paid plans, with Pro at $10/mo.
const API_KEY = 'YOUR_API_KEY';
const response = await fetch(
`https://v6.exchangerate-api.com/v6/${API_KEY}/latest/USD`
);
const data = await response.json();
console.log(`1 USD = ${data.conversion_rates.EUR} EUR`);
console.log(`Updated: ${data.time_last_update_utc}`); - Free tier: 1,500 requests/month
- Update frequency: Daily
- Paid from: Pro $10/mo
- npm package: None
- Limitation: No real-time rates, historical data requires paid plan
Express.js Currency Conversion API
Build a production-ready currency conversion microservice with Express and AllRatesToday:
// npm install express @allratestoday/sdk
import express from 'express';
import AllRatesToday from '@allratestoday/sdk';
const app = express();
const client = new AllRatesToday({ apiKey: process.env.ALLRATESTODAY_API_KEY });
// Simple in-memory cache
const cache = new Map();
const CACHE_TTL = 5 * 60 * 1000; // 5 minutes
function getCachedRate(key) {
const entry = cache.get(key);
if (entry && Date.now() - entry.time < CACHE_TTL) {
return entry.rate;
}
return null;
}
app.get('/api/rate/:from/:to', async (req, res) => {
const { from, to } = req.params;
const cacheKey = `${from}_${to}`;
try {
let rate = getCachedRate(cacheKey);
if (!rate) {
({ rate } = await client.getRate(from, to));
cache.set(cacheKey, { rate, time: Date.now() });
}
res.json({ from, to, rate, cached: !!getCachedRate(cacheKey) });
} catch (error) {
res.status(500).json({ error: 'Failed to fetch rate' });
}
});
app.get('/api/convert', async (req, res) => {
const { from, to, amount } = req.query;
if (!from || !to || !amount) {
return res.status(400).json({
error: 'Missing required parameters: from, to, amount'
});
}
try {
const result = await client.convert(from, to, parseFloat(amount));
res.json(result);
} catch (error) {
res.status(500).json({ error: 'Conversion failed' });
}
});
app.listen(3000, () => {
console.log('Currency API running on http://localhost:3000');
}); Test it:
curl http://localhost:3000/api/rate/USD/EUR
curl "http://localhost:3000/api/convert?from=USD&to=EUR&amount=500" Next.js Server Action Example
Use AllRatesToday in a Next.js 14+ server action for server-side currency conversion:
// app/actions/currency.ts
'use server';
import AllRatesToday from '@allratestoday/sdk';
const client = new AllRatesToday({ apiKey: process.env.ALLRATESTODAY_API_KEY! });
export async function getExchangeRate(from: string, to: string) {
const { rate } = await client.getRate(from, to);
return { from, to, rate, timestamp: new Date().toISOString() };
}
export async function convertAmount(
from: string,
to: string,
amount: number
) {
const result = await client.convert(from, to, amount);
return result;
} // app/components/CurrencyConverter.tsx
'use client';
import { useState } from 'react';
import { convertAmount } from '../actions/currency';
export default function CurrencyConverter() {
const [result, setResult] = useState<number | null>(null);
const [loading, setLoading] = useState(false);
async function handleConvert(formData: FormData) {
setLoading(true);
const from = formData.get('from') as string;
const to = formData.get('to') as string;
const amount = parseFloat(formData.get('amount') as string);
const data = await convertAmount(from, to, amount);
setResult(data.result);
setLoading(false);
}
return (
<form action={handleConvert}>
<input name="from" defaultValue="USD" placeholder="From" />
<input name="to" defaultValue="EUR" placeholder="To" />
<input name="amount" type="number" defaultValue="100" />
<button type="submit" disabled={loading}>
{loading ? 'Converting...' : 'Convert'}
</button>
{result !== null && <p>Result: {result}</p>}
</form>
);
} React Hook for Exchange Rates
A reusable React hook for fetching exchange rates on the client side. The browser never holds your API key: the hook calls the /api/rate/:from/:to route from the Express service above, which keeps the key in an environment variable and caches rates. (The keyed /api/v1/rates endpoint does not allow cross-origin browser calls anyway.)
import { useState, useEffect } from 'react';
export function useExchangeRate(from: string, to: string) {
const [rate, setRate] = useState<number | null>(null);
const [loading, setLoading] = useState(true);
const [error, setError] = useState<Error | null>(null);
useEffect(() => {
let cancelled = false;
setLoading(true);
fetch(`/api/rate/${from}/${to}`) // your own backend route
.then(res => {
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
})
.then(r => {
if (!cancelled) {
setRate(r.rate);
setLoading(false);
}
})
.catch(err => {
if (!cancelled) {
setError(err);
setLoading(false);
}
});
return () => { cancelled = true; };
}, [from, to]);
return { rate, loading, error };
}
// Usage in a component
function PriceTag({ amount, from, to }: {
amount: number;
from: string;
to: string;
}) {
const { rate, loading, error } = useExchangeRate(from, to);
if (loading) return <span>Loading...</span>;
if (error) return <span>Error fetching rate</span>;
return <span>{(amount * rate!).toFixed(2)} {to}</span>;
} Cloudflare Workers / Edge Runtime
AllRatesToday works in edge runtimes like Cloudflare Workers since you can use the native fetch API:
export default {
async fetch(request, env) {
const url = new URL(request.url);
const from = url.searchParams.get('from') || 'USD';
const to = url.searchParams.get('to') || 'EUR';
const response = await fetch(
`https://allratestoday.com/api/v1/rates?source=${from}&target=${to}`,
{
headers: { 'Authorization': `Bearer ${env.ALLRATESTODAY_API_KEY}` }
}
);
const [data] = await response.json(); // array of rows
return new Response(JSON.stringify({
from,
to,
rate: data.rate,
time: data.time
}), {
headers: { 'Content-Type': 'application/json' }
});
}
}; Where AllRatesToday Fits for Node.js and JavaScript
Specific things you can verify from the npm package and API docs:
- Official npm package:
npm install @allratestoday/sdk— maintained by the AllRatesToday team with regular updates and proper semver. - Full TypeScript support: Built-in type definitions ship with the package. No separate
@typesinstallation needed. Types are accurate and comprehensive. - ESM and CommonJS: Works with both module systems. Import with
importorrequire()without configuration issues. - 60-second updates: The fastest refresh of the six. Open Exchange Rates and Fixer update hourly on free; CurrencyAPI, ExchangeRate-API and Frankfurter are daily.
- Mid-market rates: The mid-market rate with no markup applied.
- 160+ currencies: Majors, minors, and exotic pairs. Frankfurter v1 covers ~30 ECB currencies.
- Works in every server runtime: Node.js, Deno, Bun, Cloudflare Workers, Vercel Edge Functions. The REST API works with native
fetchin any of them. In the browser, call your own backend route so your key stays private. - Historical data on paid plans: Historical rates are included on every paid plan, starting at €4.99/mo.
- No credit card required: Sign up for a free API key and start testing immediately (non-commercial use on the free tier).
Which One Should You Pick?
- Hobby project, prototype, or anything where ECB daily rates are enough: Frankfurter. No key, no caps, open source, history back to 1999. You will write a few lines of fetch code and never think about quotas.
- USD-based app where hourly updates are fine: Open Exchange Rates. 1,000 requests/month free, a long track record, and paid plans from $12/mo if you need other base currencies.
- Low-volume app that needs free historical data: Fixer, currencylayer or exchangeratesapi.io (all APILayer, all $14.99/mo on paid). Fixer's free tier is hourly; the other two are daily. All three are non-commercial on free.
- Most free requests on a simple REST API: ExchangeRate-API at 1,500 requests/month, daily updates; Pro is $10/mo.
- Official npm package and daily rates are enough: CurrencyAPI (
@everapi/currencyapi-js), 300 requests/month free, paid from $9.99/mo. - Official npm package with TypeScript types, 60-second updates, or coverage beyond ECB currencies: AllRatesToday. Use the free API key to evaluate; move to a paid plan (from €4.99/mo) for commercial use or historical data.
- Enterprise procurement, contracts, or tick-level data: look at OANDA or XE, which are outside the scope of this comparison.
Quick Reference
- Install:
npm install @allratestoday/sdk - Get rates:
GET /api/v1/rates?source=USD&target=EUR - Historical:
GET /api/historical-rates?source=USD&target=EUR&period=30d(paid plans) - Auth:
Authorization: Bearer YOUR_API_KEY - npm: @allratestoday/sdk
- GitHub: allratestoday/exchange-rates-api
Try AllRatesToday from Node.js
Get your free API key, install the SDK with npm install @allratestoday/sdk, and fetch mid-market rates for 160+ currencies updated every 60 seconds. Compare all options on our AllRatesToday exchange rate API page.