DEV Community

allratestoday
allratestoday

Posted on

Pulling Real-Time FX Rates into Your Systems: An Integration Checklist for Fintech Teams

The question in a fintech architecture review isn't "which API returns EUR/USD". They all do. It's "what happens to our product when the FX feed is slow, stale or wrong, and can we prove later which rate we used?"

Here's a checklist from building and running an FX rates service. The examples use AllRatesToday's API, but the checklist applies whatever feed you pick.

1. Decide which kind of rate each flow needs

One "FX rate" field across the whole product is the most common design mistake.

Flow Rate type Why
Quotes, checkout prices, balances in a second currency Live mid-market (updated every 60 s) Closest to the market; you add your own margin explicitly
VAT invoices, customs, statutory accounts, audits Official central bank or tax authority rate Regulations name the publisher and the date
"What will my bank give me?" comparisons Bank board rates (buy/sell) That's the price the customer actually gets

All three come from the same API with different endpoints:

/api/v1/rates?source=USD&target=EUR,GBP              live mid-market
/api/v1/central-bank/ecb/latest?source=EUR&target=USD official (ECB; 130+ others by code)
/api/v1/bank-rates/{country}/{bank}?ccy=USD          a bank's own board
Enter fullscreen mode Exit fullscreen mode

2. Put one internal service in front of the feed

Don't let ten microservices each call the provider. One FX service:

  • holds the key (never in mobile or browser code);
  • caches the latest rates and serves everyone from the cache;
  • is the single place where fallbacks, staleness rules and logging live.
import os, time, threading, requests

API = "https://allratestoday.com/api/v1/rates"
H = {"Authorization": f"Bearer {os.environ['ALLRATES_KEY']}"}
BASE, TARGETS = "USD", ["EUR", "GBP", "JPY", "INR", "AED", "SGD", "AUD", "CAD"]

state = {"rates": {}, "as_of": None, "fetched_at": 0.0, "error": None}

def refresh():
    try:
        r = requests.get(API, params={"source": BASE, "target": ",".join(TARGETS)}, headers=H, timeout=10)
        r.raise_for_status()
        q = r.json()
        state.update(rates={x["target"]: x["rate"] for x in q},
                     as_of=max(x["time"] for x in q), fetched_at=time.time(), error=None)
    except Exception as e:                    # keep serving the last good table
        state["error"] = repr(e)

def loop(every=60):
    while True:
        refresh()
        time.sleep(every)

threading.Thread(target=loop, daemon=True).start()
Enter fullscreen mode Exit fullscreen mode

One request per minute, whatever your traffic, and the call batches every target, so it's one call per base currency.

3. Define "stale" and act on it

Every rate needs an age, and every flow needs a limit:

def get_rate(ccy, max_age_s=300):
    age = time.time() - state["fetched_at"]
    if ccy not in state["rates"]:
        raise LookupError(f"no rate for {ccy}")
    if age > max_age_s:
        raise RuntimeError(f"FX rates are {age:.0f}s old; refusing to quote")   # or widen the margin
    return state["rates"][ccy], state["as_of"]
Enter fullscreen mode Exit fullscreen mode

Pick limits per flow: maybe 2 minutes for a payment quote, an hour for a dashboard. For official tables, the API's stale flag tells you when a publisher has missed its normal cadence.

4. Store provenance with every converted amount

Each conversion record should carry:

amount_from, ccy_from, amount_to, ccy_to,
rate, rate_type (mid / official:ecb / bank:xyz), rate_time, fetched_at, margin_applied
Enter fullscreen mode Exit fullscreen mode

When a customer disputes a conversion, or an auditor samples invoices, you answer from the row, not from logs.

5. Keep your margin separate from the rate

Store the mid-market rate and your markup as two fields. Then "our rate vs the market" is a query, not a reconstruction, and changing pricing doesn't rewrite history.

6. Money math

Use integer minor units or exact decimals (Decimal, BigDecimal, big.Rat), and round once, at the end, with a documented rule. Respect currency exponents: JPY has 0 decimals, KWD and BHD have 3.

7. Plan for the failure modes

Failure Behaviour
Timeout / 5xx Retry with backoff, keep serving the cache, alert when it gets old
401 Config error. Page someone; retrying won't help
429 Quota or burst limit. Back off; check X-Monthly-Used before it happens
A rate moves >X% between fetches Hold quotes and alert. It's usually real, but check

8. Formats for the finance side

Ops and finance teams want files, not JSON. Every table endpoint supports format=csv, xml or xlsx, so the same service can hand month-end tables to Excel or an ERP without another integration.

Getting started

  • Prototype on a free key. It uses the same 60-second feed and includes official central bank tables.
  • Production, commercial use and history are on the paid plans. There's also an Official Rates plan for finance teams that only need authority rates.

Links

Rates by AllRatesToday.

Top comments (0)