Stale Exchange Rates: How to Detect Them and What to Do About It

6 min read

Stale Exchange Rates: How to Detect Them and What to Do About It

A stale exchange rate is a rate whose observation is older than your application can safely tolerate. To detect one, compare the rate's observation timestamp with the current time and decide what to do based on the use case, not on a single global rule. Showing a slightly old rate on a dashboard is harmless. Charging a customer with it may not be.

Most exchange rate bugs that reach production are not wrong numbers. They are old numbers that nobody noticed were old: a cache that never expired, an upstream outage that left the last value in place, or a derived rate built from one fresh input and one ancient one. This article explains what makes a rate stale, how to measure it, and which policy to apply in common situations.

What makes an exchange rate stale

Staleness is about time since the last observation, and the acceptable limit depends on the asset. Crypto prices move constantly, so a one-minute-old Bitcoin price is already questionable. Major fiat currencies move more slowly in a quiet market, so a few minutes is usually tolerable.

GetRatesAPI reflects this directly. Crypto prices refresh every 10 seconds, and fiat currencies and metals every 60 seconds. Every rate carries two fields that describe its age:

  • as_of: the time of the observation, in UTC.
  • status: fresh or stale. Crypto becomes stale after 1 minute, fiat after 5 minutes.
{
  "base": "EUR",
  "quote": "USD",
  "rate": "1.0842",
  "as_of": "2026-01-02T10:00:00Z",
  "status": "fresh",
  "type": "direct"
}

One design choice matters here: stale rates are flagged, not withheld. The API returns the number and tells you it is old. That leaves the decision with you, which is right, because only your application knows whether a five-minute-old rate is acceptable.

Derived rates and the oldest input

Not every pair is quoted directly. When no market quotes a pair, GetRatesAPI derives it through USD, EUR or BTC, and marks the response "type": "derived". The as_of of a derived rate is its oldest input. If you convert a small fiat currency to a crypto asset, the result is only as fresh as the older of the legs involved. This is the conservative choice, and it means you can trust as_of without working out the inputs yourself. For background on how derived pairs are built, see cross rates explained.

Why the status flag alone is not enough

The status field is true at the moment the API answers. It is not a promise about the future. Two common situations make it misleading if you read it carelessly:

  1. Cached responses. If you store a response for 30 seconds and read it again, its status still says fresh even though the observation is now 30 seconds older. A crypto rate cached this way can silently cross the one-minute line.
  2. Stricter business rules. The API's threshold is a general one. Your checkout might want rates no older than 2 minutes, while the fiat threshold is 5 minutes. A rate can be fresh by the API's definition and still too old for you.

The fix is to treat status as a useful first signal and as_of as the source of truth. Compute the age yourself, at the moment you use the rate. Our guide to caching exchange rates without showing stale prices covers cache lifetimes in more detail.

Measure the age of a rate in code

Here is a small JavaScript helper (Node 18 or later) that fetches a rate, computes its age from as_of, and checks both the API's flag and your own limit. Rates stay as strings; nothing here does arithmetic on the rate itself.

const API = "https://api.getratesapi.com";

async function getRate(base, quote) {
  const res = await fetch(`${API}/v1/rates/${base}/${quote}`, {
    headers: { Authorization: `ApiKey ${process.env.GETRATES_API_KEY}` },
  });
  if (!res.ok) {
    const err = await res.json();
    throw new Error(err.code); // match on "code" only
  }
  return res.json();
}

function ageSeconds(rate, now = Date.now()) {
  return Math.max(0, Math.round((now - Date.parse(rate.as_of)) / 1000));
}

function assess(rate, maxAgeSeconds) {
  const age = ageSeconds(rate);
  if (rate.status === "stale") return { usable: false, age, reason: "api_stale" };
  if (age > maxAgeSeconds) return { usable: false, age, reason: "too_old" };
  return { usable: true, age, reason: "ok" };
}

Because assess works from as_of, it gives the right answer for a rate you read from a cache five seconds or five minutes after you fetched it. Note that it also relies on your server clock being reasonably accurate, so keep NTP enabled on your hosts.

Choose a policy for each use case

Once you can tell that a rate is old, you need to decide what to do. There are four reasonable reactions: show it with a warning, refetch, fall back to something else, or refuse. The right one depends on what the rate is used for.

Use caseSuggested reaction to a stale rate
Informational price displayShow it with a "rates as of 10:04 UTC" label
Multi-currency dashboardShow it, mark the affected figure, retry in the background
Checkout or quoteRefetch once; if still stale, fall back to a settlement-currency price or pause the quote
InvoicingRefetch; if still stale, block issuing and alert someone
Month-end snapshotRefuse to store a stale rate; rerun the snapshot
Crypto price alertsSkip the evaluation rather than act on an old price

Display: be honest about the time

For anything informational, the simplest safe behavior is to show the observation time next to the number. Users forgive an old rate they can see is old. They do not forgive one that looks live and is not. A dashboard that adds up balances in one currency can mark the affected row and carry on; see how to show a total balance in one currency.

Checkout: refetch, then degrade gracefully

At checkout, a stale rate turns into a price the customer actually pays. Refetch once, and if the result is still too old, avoid guessing. Reasonable fallbacks include charging in your settlement currency or telling the user the local price is temporarily unavailable. Whatever you choose, do it before the customer sees a total. If you quote a rate and hold it for a few minutes, also read how to lock an exchange rate at checkout, because a quote's expiry is a separate clock from the rate's age.

Accounting and invoicing: fail loudly

Financial records need a rate you can defend later. A stale rate stored in a ledger is hard to detect afterward. For invoices and month-end snapshots, prefer to stop and retry over saving a questionable number. Store the as_of and type alongside the rate so an auditor can see how old the observation was. The articles on invoicing in a foreign currency and month-end revaluation snapshots go through what to keep.

Put it together: a refetch-then-decide flow

This function applies a per-use-case maximum age, refetches once, and then returns a decision your caller can act on.

const MAX_AGE = { display: 900, checkout: 120, ledger: 120 };

async function rateFor(useCase, base, quote) {
  const limit = MAX_AGE[useCase];
  let rate = await getRate(base, quote);
  let check = assess(rate, limit);

  if (!check.usable && useCase !== "display") {
    rate = await getRate(base, quote); // one retry
    check = assess(rate, limit);
  }

  return { rate, ...check, action: decide(useCase, check) };
}

function decide(useCase, check) {
  if (check.usable) return "proceed";
  if (useCase === "display") return "show_with_warning";
  return "block_and_alert";
}

A few details are worth keeping:

  • Do not loop. One refetch is enough. If the data is still old, a tighter loop will not help and will burn request units and rate limit.
  • Handle errors separately. A temporarily_unavailable (503) response is not a stale rate; it means you got no rate. Treat both as "no trustworthy rate", but log them differently. The error handling guide lists what each code means.
  • Log the age. Recording the age of the rate you actually used makes later investigations simple.

Reduce staleness at the source

You can lower the number of stale-rate events with a few habits:

  • Fetch several quotes in one call with GET /v1/rates/{base}?quote=EUR,GBP,JPY (up to 20 quotes, 1 request unit) so all of them are observed together. See getting multiple exchange rates in one call.
  • Match cache lifetimes to the asset: well under a minute for crypto, longer for fiat.
  • Keep your own maximum age at or below the API's stale threshold for money-moving paths.

Try it with your own thresholds

Every response from GetRatesAPI includes as_of, status and type, so you can apply the policies above without extra calls. The current rate documentation describes each field. You can sign up for the free plan with no credit card and try the checks in the dashboard playground, then pick a plan on the pricing page when your traffic grows.

All articles →
Stale Exchange Rates: Detect and Handle Them — GetRatesAPI