DEV Community

Exchange Rate API
Exchange Rate API

Posted on Edited on

Daily, hourly or every minute? Picking the right exchange rate freshness

"How often does the rate update?" has three different answers depending on which rate you mean.

Rate type Updates Example source
Official fixing once a day (some weekly or monthly) ECB, Bank of England, RBI/FBIL
Bank board a few times a day SBI card rate, HSBC TT board
Market mid rate continuously interbank market

Frankfurter covers the first row thoroughly: 112 providers, almost all daily. AllRatesToday covers all three: official rates from 141 central banks and 68 tax and customs authorities, bank boards read hourly, and market rates refreshed every 60 seconds.

Match the rate to the job

Accounting, tax, customs: use the official fixing the rule names. It changes once a day, so cache it for the day. Polling it every minute just repeats the same number.

Showing users what they'll get at a bank: use bank boards. Hourly is enough, since banks rarely change boards more often, and show the board's own timestamp.

Pricing, checkout, dashboards: use the market rate. Cache for 60 seconds, so one request a minute serves every user.

Code: one key, three freshness levels

const H = { headers: { Authorization: `Bearer ${process.env.ART_KEY}` } };
const base = "https://allratestoday.com/api/v1";

const market   = await fetch(`${base}/rates?source=USD&target=EUR`, H);          // ~60 s
const official = await fetch(`${base}/central-bank/ecb/latest?source=EUR&target=USD`, H); // daily
const boards   = await fetch(`${base}/bank-rates/sg`, H);                         // hourly
Enter fullscreen mode Exit fullscreen mode

Set your cache TTLs to match: 60 seconds, until the next publication, and one hour.


Top comments (0)