"Forex API" means two different things, and picking the wrong kind wastes a week:

You need What to look for
Prices to trade on: bid/ask ticks, order books, execution A broker's or trading venue's API, usually tied to a trading account
Rates to price, convert, display or report: "what is EUR/USD right now?" An FX rates API

This post is about the second kind, the one behind checkout pages, invoicing tools, dashboards, travel apps and most fintech back offices. AllRatesToday has a free tier for it.

What the free tier gives you

  • Mid-market rates, aggregated from institutional FX market data and updated every 60 seconds. The free tier gets the same feed as the paid plans.
  • 160+ currencies, any base.
  • Several pairs per request (target=EUR,GBP,JPY), counted as one call.
  • Official central bank tables (ECB, Fed, Bank of England, RBI and 130+ others) on the same key.
  • No credit card: register and the key is on your dashboard.

It's for personal projects, prototypes and testing. Commercial use and historical data are on the paid plans.

What it isn't

  • Not a tick feed. You get one mid-market rate per pair per minute, not every trade.
  • Not bid/ask. The mid-market rate is the midpoint. A bank or card charges a spread on top of it.
  • Not for executing trades. Use your broker's API for that.

If what you're building only ever shows or converts amounts, a rates API is the right tool, and it's far simpler.

PHP

<?php function fx_rates(string $source, array $targets): array { $url = 'https://allratestoday.com/api/v1/rates?' . http_build_query([ 'source' => $source, 'target' => implode(',', $targets), ]); $ch = curl_init($url); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10, CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('ALLRATES_KEY')], ]); $body = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); curl_close($ch); if ($status !== 200) { throw new RuntimeException("FX API returned $status: $body"); } $out = []; foreach (json_decode($body, true) as $q) { $out[$q['target']] = $q['rate']; } return $out; } $r = fx_rates('EUR', ['USD', 'GBP', 'CHF']); printf("1 EUR = %.4f USD\n", $r['USD']); 

For money, keep amounts in minor units (cents) as integers and round once at the end, or use bcmath. Floating-point euros add up to off-by-a-cent totals.

Python

import os, time, requests _cache = {"at": 0, "rates": {}} def fx_rates(source="USD", targets=("EUR", "GBP", "JPY"), max_age=60): """Live mid-market rates, cached for max_age seconds (the feed updates every 60 s).""" if time.time() - _cache["at"] < max_age: return _cache["rates"] r = requests.get("https://allratestoday.com/api/v1/rates", params={"source": source, "target": ",".join(targets)}, headers={"Authorization": f"Bearer {os.environ['ALLRATES_KEY']}"}, timeout=10) r.raise_for_status() _cache.update(at=time.time(), rates={q["target"]: q["rate"] for q in r.json()}) return _cache["rates"] print(fx_rates()) 

Polling: how often?

The rates update every 60 seconds, so polling faster than once a minute only re-reads the same number. For most uses, longer is fine:

Use Refresh
Trading-style dashboard every 1 minute
Checkout / price display every 5–15 minutes
Invoices, reports once, at the moment you issue the document (store the rate)

On the free tier, cache aggressively. The quota doesn't reset monthly, and every response's X-Monthly-Used header shows where you stand.

When the rate must be official

Prices and dashboards can use the live rate. Invoices for VAT, customs declarations and statutory accounts usually have to use a named authority's rate. Same key, different endpoint:

curl "https://allratestoday.com/api/v1/central-bank/ecb/latest?source=EUR&target=USD" \ -H "Authorization: Bearer art_live_your_key" 

Links

Rates by AllRatesToday. Mid-market rates are indicative, not executable quotes.