fawazahmed0 currency-api Fallback: Same Paths and JSON Shape

The fawazahmed0 currency-api README asks you to code a fallback when jsDelivr or currency-api.pages.dev fails. AllRatesToday serves the same /v1/currencies paths and lowercase JSON shape from the ECB reference table.

By Madhushan, Founder & Lead Developer ·

A third fallback for fawazahmed0 currency-api

fawazahmed0/exchange-api is still free and still updates daily. Its README asks you to include a fallback: if cdn.jsdelivr.net fails, fetch from currency-api.pages.dev. Both are served from the same daily build, so a failed run or a blocked CDN can take out both. This endpoint is a third source with the same paths and the same JSON shape.

The change is a prefix. Put https://allratestoday.com/api/compat/currency-api/ in front of {date}/v1/currencies/{code}.json. Lowercase keys, .min.json and dates all work.

Before and after

# primary
curl "https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@latest/v1/currencies/usd.json"
# fallback 1 (from the project's README)
curl "https://latest.currency-api.pages.dev/v1/currencies/usd.json"
# fallback 2: same path after /api/compat/currency-api/
curl "https://allratestoday.com/api/compat/currency-api/latest/v1/currencies/usd.json"

Response, same shape as the original:

{"date":"2026-11-06","usd":{"usd":1,"aud":1.4554411,"cad":1.4066279,"chf":0.81889834,"eur":0.89565607,...}}

Fallback code

JavaScript (browser or Node 18+, CORS is open):

const SOURCES = [
  (d, c) => `https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@${d}/v1/currencies/${c}.json`,
  (d, c) => `https://${d}.currency-api.pages.dev/v1/currencies/${c}.json`,
  (d, c) => `https://allratestoday.com/api/compat/currency-api/${d}/v1/currencies/${c}.json`,
];

async function getRates(code = 'usd', date = 'latest') {
  for (const url of SOURCES) {
    try {
      const r = await fetch(url(date, code));
      if (r.ok) return await r.json();   // { date, usd: { eur: 0.89, ... } }
    } catch { /* try the next source */ }
  }
  throw new Error('All currency sources failed');
}

const data = await getRates('usd');
console.log(data.date, data.usd.eur);

Python:

import requests

SOURCES = [
    "https://cdn.jsdelivr.net/npm/@fawazahmed0/currency-api@{d}/v1/currencies/{c}.json",
    "https://{d}.currency-api.pages.dev/v1/currencies/{c}.json",
    "https://allratestoday.com/api/compat/currency-api/{d}/v1/currencies/{c}.json",
]

def get_rates(code="usd", date="latest"):
    for url in SOURCES:
        try:
            r = requests.get(url.format(d=date, c=code), timeout=5)
            if r.ok:
                return r.json()
        except requests.RequestException:
            pass
    raise RuntimeError("All currency sources failed")

data = get_rates("usd")
print(data["date"], data["usd"]["eur"])

Endpoints

EndpointReturns
/api/compat/currency-api/latest/v1/currencies/usd.jsonLatest ECB table rebased to USD
/api/compat/currency-api/2026-03-06/v1/currencies/eur.jsonECB table in force on that date
/api/compat/currency-api/latest/v1/currencies.jsonCode to currency name
.min.json on any pathSame body

None of these needs a key. Rates are the European Central Bank's official daily reference rates, so the fallback covers the 30 currencies in that table. A code outside it, such as btc, returns a 404 so your loop moves on rather than using a wrong number.

When you need more than a fallback

Frequently asked questions

Which currencies does the fallback cover?

The 30 currencies in the European Central Bank's daily reference table, including USD, EUR, GBP, JPY, CHF, CAD, AUD, CNY and INR. Crypto, metals and other currencies return a 404, so your code moves on instead of getting a wrong number.

Are the numbers the same as currency-api?

Close but not identical. The fallback serves the ECB's official reference rates, published once per working day at about 16:00 CET, with cross-rates computed inside that table. currency-api does not name its source, so small differences are normal.

Do dates work?

Yes. Replace latest with a date such as 2026-03-06. You get the ECB table in force on that date, and the date field shows which table it was.

Can I use it commercially?

Yes. The compatible endpoints serve the ECB's public reference table and may be used commercially. Public displays must carry a visible attribution link to allratestoday.com.

Need live rates too?

A free API key adds rates for 160+ currencies, refreshed every 60 seconds.

Get a free API key All migration guides

Related