An FX rates API is a web service that returns foreign exchange rates: how many units of one currency equal one unit of another, and when that was true. You call a URL, you get back a number and a time. That is the whole idea, but the details (which rate, from when, against which base) decide whether the number is right for your use.

This guide explains each part of a response, the different kinds of rate, and what to check before you pick one.

What an FX rates API returns

Every useful response carries four things:

  • Base currency (also called source). The currency you have one unit of. In USD/EUR = 0.9215, the base is USD.
  • Quote currency (also called target). The currency the rate is expressed in. Here, EUR.
  • Rate. How many units of the quote currency one unit of the base buys: 1 USD = 0.9215 EUR.
  • Timestamp or date. When the rate was observed or set.

Currencies are identified by ISO 4217 three-letter codes: USD, EUR, JPY, KWD. Here is a real request shape:

curl "https://allratestoday.com/api/v1/rates?source=USD&target=EUR" \ -H "Authorization: Bearer YOUR_API_KEY" 
[{"rate":0.9215,"source":"USD","target":"EUR","time":"2026-04-03T12:00:00Z"}] 

Some APIs return a map instead of a list, for example "rates": {"EUR": 0.9215, "GBP": 0.7893} with one shared timestamp. Both carry the same information. Read the docs for the shape: this endpoint returns an array even for a single pair, so the rate is data[0].rate, not data.rate.

Mid, bid/ask, and official rates

"The exchange rate" can mean three different numbers.

Rate type What it is Changes Used for
Bid / ask The prices a dealer will buy and sell at Every tick Trading, executing a conversion
Mid-market The midpoint between bid and ask Continuously; APIs sample it Showing prices, conversion estimates, reporting
Official reference or fixing One rate per day (or month) set by a central bank or tax authority Once per period, then fixed Invoices, VAT, customs, accounting rules

Bid and ask come from brokers and dealers. The gap between them is the spread. If you need these, you need a trading API, not a rates API.

Mid-market is what most FX rates APIs serve. It has no margin built in. It is the fair number to show a customer, and the one to compare a bank's quote against. The mid-market vs retail guide shows how large that gap usually is.

Official rates are set by an institution at a stated time. The European Central Bank sets euro reference rates each working day; tax authorities such as HMRC set monthly rates for customs and VAT. These do not move during the day. When a rule says "use the central bank rate of the invoice date", only the official rate satisfies it. A live mid rate, however accurate, is a different number.

Update cadence

How often the rate changes depends on the type and the provider:

  • Live mid-market: every minute, hourly or daily, depending on provider and plan.
  • Daily fixings: once per working day, at the institution's fixing time. None on weekends or public holidays.
  • Monthly tax rates: once a month, set in advance.

Two times matter. The rate time is when the rate refers to. The fetch time is when you received it. A daily fixing fetched at 23:00 still has a rate time of that afternoon. For official rates, also store the rate date the institution assigned, because some release a table today that is valid for tomorrow. The update frequency guide covers this per source.

Base currency and cross rates

Many APIs let you set the base. Some free plans fix it to USD or EUR. If yours does, you compute other pairs yourself:

EUR/JPY = USD/JPY ÷ USD/EUR = 153.47 ÷ 0.9215 = 166.54 

Rules for cross rates:

  • Use two rates from the same timestamp. Mixing a fresh rate with an old one gives a pair that never existed.
  • Keep full precision in the calculation. Round only the result you display.
  • An inverse is a cross rate too: EUR/USD = 1 ÷ 0.9215 = 1.0852. It is not the same as asking the API for EUR/USD a minute later.

More detail and code are in the base currency conversion guide.

History

Historical rates answer "what was the rate on this date". Two shapes are common:

  • A single past date: one table for one day. This is the normal shape for official rates.
  • A time series: a list of date and rate points for a range, for charts and analysis.

For example, 30 days of USD/EUR history:

curl "https://allratestoday.com/api/historical-rates?source=USD&target=EUR&period=30d" \ -H "Authorization: Bearer YOUR_API_KEY" 
{"source":"USD","target":"EUR","data":[{"date":"2026-03-05","rate":0.9241,"timestamp":1772668800000}],"source_api":"mid-market","period":"30d"} 

The period presets are 1d, 7d, 30d and 1y. Check how your provider handles the edges: what counts as a day, whether weekends are filled with Friday's rate, and whether a missing day is skipped or interpolated.

Formats

JSON is the default. Finance and data teams often want something else:

  • CSV for spreadsheets and bulk loads.
  • XML for older ERP and accounting integrations.
  • XLSX for people who will open the file directly.

On AllRatesToday, table endpoints accept ?format=json|csv|xml|xlsx. If your target system is Excel, the Excel exchange rates guide shows the options.

How to read a response, step by step

Take this response:

[ {"rate":0.9215,"source":"USD","target":"EUR","time":"2026-04-03T12:00:00Z"}, {"rate":153.47,"source":"USD","target":"JPY","time":"2026-04-03T12:00:00Z"} ] 
  1. Find the direction. source USD, target EUR: 1 USD = 0.9215 EUR. To convert 250 USD, multiply: 230.375, shown as €230.38.
  2. Check the time. 2026-04-03T12:00:00Z is UTC. If it is older than your tolerance, treat the data as stale.
  3. Check the type. This endpoint is mid-market. Do not label it as an official rate.
  4. Keep the full rate. Store 0.9215 and the time, not the rounded €230.38 alone.
  5. Format per currency. JPY has no minor unit, so 250 USD is ¥38,368, not ¥38,367.50.

Picking an FX rates API

Ask these questions, in this order:

  1. Which rate do I need? Mid-market for pricing and display. Official for rules that name an institution. Bid/ask only for trading.
  2. How fresh? Daily is fine for reporting. Checkout pricing usually wants minutes.
  3. Which currencies? Check your exact list, including any exotic currency.
  4. How much history? And is it on the plan you can afford?
  5. What does it cost at my real volume? After caching. The caching guide shows how to cut calls.
  6. What are the terms? Commercial use, attribution, and what happens when you exceed a limit.

For a side-by-side of providers, see the free currency API comparison.

AllRatesToday serves mid-market rates for 160+ currencies refreshed every 60 seconds on every plan, and official rates from 123 central banks and 6 tax authorities with each institution's own rate date. It is REST over HTTPS with a Bearer key. The docs list every endpoint.

FAQ

What does FX stand for in FX rates API?

FX is short for foreign exchange. An FX rates API returns foreign exchange rates: how much of one currency you get for one unit of another.

What is the difference between a mid rate and a fixing?

A mid rate is the midpoint between buy and sell prices at a given moment, and it moves all day. A fixing or reference rate is one figure an institution sets for a day at a stated time, and it does not change afterwards.

Why does my FX rates API return a different rate from my bank?

Your bank quotes a retail rate that includes its margin. Most FX rates APIs return a mid-market rate with no margin. The difference is the bank's spread and fees.

How do I get a cross rate like EUR/JPY from a USD-based API?

Divide the two USD rates: EUR/JPY equals USD/JPY divided by USD/EUR. Use rates from the same timestamp, and round only the final result.

Is a timestamp in the response important?

Yes. It tells you how old the rate is. Store it next to every converted amount so you can explain the figure later, and alert when it gets older than you allow.

Try an FX rates API. Mid-market rates for 160+ currencies every 60 seconds, and official rates from 123 central banks and 6 tax authorities, as JSON, CSV, XML or Excel. Get a free API key

Originally published at allratestoday.com.