Node.js and JavaScript: Exchange Rate APIs Compared with Code

Reviewed by Madhushan, Fintech Developer — November 2026
JavaScript code on monitor

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

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`);

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);

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}`);
});

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}`);
});

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}`);

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 (
    &lt;form action=&#123;handleConvert&#125;&gt;
      &lt;input name="from" defaultValue="USD" placeholder="From" /&gt;
      &lt;input name="to" defaultValue="EUR" placeholder="To" /&gt;
      &lt;input name="amount" type="number" defaultValue="100" /&gt;
      &lt;button type="submit" disabled=&#123;loading&#125;&gt;
        &#123;loading ? 'Converting...' : 'Convert'&#125;
      &lt;/button&gt;
      &#123;result !== null && &lt;p&gt;Result: &#123;result&#125;&lt;/p&gt;&#125;
    &lt;/form&gt;
  );
}

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:

Which One Should You Pick?

Quick Reference

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.

Get Your Free API Key

Related Articles