DEV Community

Exchange Rate API
Exchange Rate API

Posted on

Historical Exchange Rate API: A Rate on a Date, a Daily Range, and Official Central Bank History

Historical exchange rates come up in three situations:

  1. One date. "What was USD/EUR on the invoice date, 14 March?"
  2. A range. "Give me daily GBP/USD for the last year for a chart or a backtest."
  3. An official series. "Revalue at the ECB (or Fed, or RBI) rate for each month-end since 2020."

AllRatesToday's API covers all three. Historical data is on the paid plans (from a few euros a month); the examples use a key from your dashboard.

1. The rate on a past date

Add time to the same endpoint you use for live rates:

curl "https://allratestoday.com/api/v1/rates?source=USD&target=EUR&time=2026-03-14" \
  -H "Authorization: Bearer art_live_your_key"
Enter fullscreen mode Exit fullscreen mode

This returns the mid-market rate at that date, in the same array shape as the live call.

2. A daily range

Use from and to for a daily series of one pair:

import requests

H = {"Authorization": "Bearer art_live_your_key"}

r = requests.get("https://allratestoday.com/api/v1/rates",
                 params={"source": "GBP", "target": "USD",
                         "from": "2025-11-25", "to": "2026-11-24"},
                 headers=H, timeout=30)
r.raise_for_status()
series = r.json()                      # one point per day
print(len(series), series[0], series[-1])
Enter fullscreen mode Exit fullscreen mode

Two limits to plan for:

  • At most 366 days per request. For longer series, loop a year at a time.
  • A single-pair range is billed per month of data, not as one call, so cache the result rather than re-fetching it.
import datetime as dt

def yearly_chunks(start, end):
    s = dt.date.fromisoformat(start)
    e = dt.date.fromisoformat(end)
    while s <= e:
        chunk_end = min(dt.date(s.year + 1, s.month, s.day) - dt.timedelta(days=1), e)
        yield s.isoformat(), chunk_end.isoformat()
        s = chunk_end + dt.timedelta(days=1)

for a, b in yearly_chunks("2022-01-01", "2026-11-24"):
    print(a, b)            # request each chunk, append to one DataFrame/table
Enter fullscreen mode Exit fullscreen mode

3. Official central bank history

For accounting, tax and audit, the series usually has to be a specific institution's. Each central bank table has its own history endpoint:

# ECB reference rates, daily, as CSV
curl "https://allratestoday.com/api/v1/central-bank/ecb/history?from=2026-01-01&to=2026-06-30&format=csv" \
  -H "Authorization: Bearer art_live_your_key" -o ecb-h1-2026.csv

# The table in force on one date (holidays resolve to the last published table)
curl "https://allratestoday.com/api/v1/central-bank/rbi/2026-03-31" \
  -H "Authorization: Bearer art_live_your_key"
Enter fullscreen mode Exit fullscreen mode

How far back it goes depends on the institution: the ECB from 1999, the RBI from 2003, and so on. Each bank's page on the coverage list shows its start date and cadence.

Weekends and holidays

Central banks don't publish on weekends or public holidays. The dated endpoint returns the last table published on or before the date you asked for, and says so:

{ "requested_date": "2026-03-31", "rate_date": "2026-03-30", "published_on_requested_date": false }
Enter fullscreen mode Exit fullscreen mode

Store rate_date, not just the date you requested. Months later, that one field answers "which rate did we use?"

What to store with every historical rate

Field Why
rate The number
rate_date (or time) The publisher's date, not your fetch date
source mid-market, ecb, rbi, ... Two sources give two different numbers
fetched_at Debugging

With those four columns, a report can always be recomputed exactly.

Formats

Every table endpoint takes format=json, csv, xml or xlsx, so a finance team can open the result in Excel without a conversion step.

Links

Rates by AllRatesToday. Central bank figures are the official rates each institution publishes.

Top comments (0)