How to Convert Currencies in Real-Time with a Free API
If your application handles international transactions, displays prices in multiple currencies, or generates financial reports across regions, you need reliable exchange rate data. Most currency APIs either charge immediately, require credit card signup for a "free" tier, or throttle aggressively after a handful of requests.
This article shows how to convert currencies, fetch historical rates, and list supported currencies using a free API backed by European Central Bank data, with working JavaScript examples you can drop into your project today.
Where the rates come from
The European Central Bank publishes reference exchange rates daily for 30+ currencies against the EUR. These are the same rates used by financial institutions across Europe for settlement and accounting. The data goes back to January 1999, which means you can query historical rates for any business day in the last 27 years.
The API wraps the Frankfurter API, which sources directly from the ECB. Rates are cached for one hour to balance freshness with performance.
Supported currencies include: USD, EUR, GBP, JPY, CHF, CAD, AUD, CNY, INR, BRL, MXN, KRW, SGD, HKD, NOK, SEK, DKK, PLN, ZAR, TRY, and more.
Converting between currencies
A simple conversion from 100 USD to EUR:
curl "https://currency-exchang.up.railway.app/convert?from=USD&to=EUR&amount=100"
{
"from": "USD",
"to": "EUR",
"amount": 100,
"result": 91.47,
"rate": 0.9147,
"date": "2026-03-14"
}
The date field shows which trading day the rate corresponds to. ECB rates are updated around 16:00 CET on business days.
Getting all rates for a base currency
If you need to display a rate table or pre-compute conversions:
curl "https://currency-exchang.up.railway.app/rates?base=USD"
{
"base": "USD",
"date": "2026-03-14",
"rates": {
"EUR": 0.9147,
"GBP": 0.7823,
"JPY": 148.52,
"CAD": 1.3641,
"AUD": 1.5312,
"CHF": 0.8834
}
}
Fetching historical rates
Need the USD/EUR rate on a specific date? Useful for invoice reconciliation, travel expense reports, or financial audits:
curl "https://currency-exchang.up.railway.app/historical?date=2025-01-15&base=USD&symbols=EUR,GBP,JPY"
{
"base": "USD",
"date": "2025-01-15",
"rates": {
"EUR": 0.9712,
"GBP": 0.8198,
"JPY": 156.23
}
}
Historical data is available back to January 4, 1999.
Integrating into a Node.js application
Here is a practical currency conversion module you can use in an e-commerce backend or financial dashboard:
const CURRENCY_BASE = 'https://currency-exchang.up.railway.app';
const convertCurrency = async (amount, from, to) => {
const params = new URLSearchParams({
from,
to,
amount: String(amount),
});
const res = await fetch(`${CURRENCY_BASE}/convert?${params}`);
const data = await res.json();
return {
original: { amount, currency: from },
converted: { amount: data.result, currency: to },
rate: data.rate,
date: data.date,
};
};
const getAllRates = async (base = 'USD') => {
const res = await fetch(`${CURRENCY_BASE}/rates?base=${base}`);
return res.json();
};
const getHistoricalRate = async (date, from, to) => {
const params = new URLSearchParams({ date, base: from, symbols: to });
const res = await fetch(`${CURRENCY_BASE}/historical?${params}`);
const data = await res.json();
return data.rates[to];
};
// Convert a product price for international display
const priceUSD = 49.99;
const priceEUR = await convertCurrency(priceUSD, 'USD', 'EUR');
console.log(`$${priceUSD} = ${priceEUR.converted.amount} EUR (rate: ${priceEUR.rate})`);
// Get the rate that was active when an invoice was issued
const invoiceDate = '2025-06-15';
const rateOnDate = await getHistoricalRate(invoiceDate, 'USD', 'GBP');
console.log(`USD/GBP on ${invoiceDate}: ${rateOnDate}`);
Listing all supported currencies
To populate a currency selector dropdown:
curl "https://currency-exchang.up.railway.app/currencies"
{
"AUD": "Australian Dollar",
"BGN": "Bulgarian Lev",
"BRL": "Brazilian Real",
"CAD": "Canadian Dollar",
"CHF": "Swiss Franc",
"CNY": "Chinese Yuan",
"EUR": "Euro",
"GBP": "Pound Sterling",
"USD": "US Dollar"
}
The full list includes 30+ currencies. Each is identified by its ISO 4217 code.
Using the MCP server in Claude Desktop
For quick currency conversions without leaving your editor, the MCP Finance server adds currency tools to Claude Desktop.
npx @easysolutions906/mcp-finance
Add this to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"finance": {
"command": "npx",
"args": ["-y", "@easysolutions906/mcp-finance"]
}
}
}
With the server connected, you can ask Claude "Convert 500 USD to Japanese yen" or "What was the EUR/GBP rate on December 1, 2024?" and it calls the currency_convert or currency_historical tool directly. The response includes the exact rate and the date it was published.
This is handy during development when you are testing internationalization logic, verifying exchange rate calculations, or just need a quick conversion without opening a browser tab.
Why use this instead of other currency APIs
Most currency APIs fall into two categories: free-but-limited (100 requests/month, stale data, no historical rates) or paid-from-day-one ($10-50/month for basic access).
This API sits in a practical middle ground:
- ECB reference rates: The same source used by banks. Not scraped from a forex feed with dubious accuracy.
- Historical data back to 1999: Most free APIs only offer current rates.
- No signup required: No API key, no credit card, no email verification.
- 30+ currencies: Covers all major trading pairs.
- MCP integration: Use it as an AI tool, not just a REST endpoint.
The trade-off is that ECB rates update once per business day, not in realtime. For most applications -- e-commerce, invoicing, expense reports, financial dashboards -- daily reference rates are exactly what you need. If you need tick-by-tick forex data for a trading platform, this is not the right tool.
Get started
- REST API: Deployed on Railway. Convert, rates, historical, and currencies endpoints are open with no key required.
-
MCP server:
npx @easysolutions906/mcp-financeadds currency tools to Claude Desktop or Cursor. -
npm package:
npm install @easysolutions906/mcp-finance
Thirty currencies, twenty-seven years of history, zero signup friction.
Top comments (0)