Currency conversion in JavaScript and Node.js
Fetch live exchange rates and convert amounts in JavaScript using the global fetch API. Works in Node 18+, Deno, Bun, and modern browsers. No key to start, 10,000 calls a month on the free tier.
The quickest path to exchange rates in JavaScript is a GET to /v1/latest/USD using fetch. The response is plain JSON with rates across the supported 31-currency catalog, with per-currency sources and effective_at metadata. No API key is required for your first call.
fetch works out of the box in Node 18+, Deno, Bun, and browsers with no extra dependencies./v1/latest/{base} returns rates for 31 currencies, plus source and market_session.Authorization: Bearer exr_live_..., or use X-API-Key if your platform cannot set Authorization.Your first call, no key needed
In Node 18 or any modern browser you already have fetch. Check the HTTP status before reading the EUR rate:
Anonymous calls are capped per IP address, so move to a free key before you go past a quick test.
Add a key and error handling
Pass your key as a bearer token in the Authorization header. Check res.ok and throw on a bad status so errors surface early:
The X-API-Key: exr_live_... header is also accepted, for platforms that cannot set an Authorization header (some serverless runtimes, Zapier, and similar no-code tools).
Convert an amount
For a direct conversion call /v1/convert/{from}/{to}/{amount}. The response gives you both the rate and the converted amount in one round-trip:
The convert endpoint returns the same source and market_session fields as the latest endpoint, so you can show users the rate class and whether the interbank trading week is open.
Understand source and market_session
Use effective_at[currency] for the observation time of a displayed currency, and sources[currency] for its source. source summarizes the whole response; market_session describes the trading session rather than the age of a rate. source identifies the data class: live is an aggregated spot consensus that updates approximately every 60 seconds through the trading week, ecb_daily is the European Central Bank reference fix published once per business day around 16:00 CET, and fred_daily is the Federal Reserve daily series. market_session is open, weekend, or interbank_closed for a known non-weekend closure.
The data_updated_at field is the oldest contributing observation; it is not necessarily the age of the currency you display. timestamp records when the response was built. Together they let you decide how to cache and display the value.
notice field.Free tier limits
A free key gives you 10,000 calls per month at 12 requests per minute. No card is required to sign up. If you exceed the per-minute limit the API returns a 429; back off and retry. The monthly quota resets at 00:00 UTC on the first day of each calendar month. Honor Retry-After on 429 responses.
- 10,000 calls per month
- 12 requests per minute
- No credit card required
- Covers
/v1/latest,/v1/convert,/v1/range, and/v1/{date}/{base}