Use casesUse case

Exchange rate API for international payroll

A 3,200 USD monthly fee paid in pesos, rupees and reais

7 Nov 2026 · 2 min read

Payroll needs one rule: pick the rate date for the pay run, use it for everyone, and save it. The API returns the daily reference rate for any past business day, so the same run can be repeated and audited. The example converts a 3,200 USD fee for three contractors at the rate of 30 October 2026.

Choose the rate date once

Two choices are common. Some teams use the rate on the last business day of the pay period, and others use the rate on the payment date. Either works if the contract says which. Write the date into the pay run and pass it to every conversion, so a rerun next week gives the same numbers.

Convert the fee for each contractor

The date endpoint takes a base currency and a list of symbols. The script uses Decimal for the arithmetic and rounds half to even at two decimals.

Python
import json, urllib.requestfrom decimal import Decimal, ROUND_HALF_EVENdef get(path):    return json.load(urllib.request.urlopen(f"https://api.exchangerate.dev/v1/{path}"))cutoff = "2026-10-30"           # last business day of the pay periodsalary_usd = Decimal("3200.00")day = get(f"{cutoff}?base=USD&symbols=PHP,INR,BRL")for ccy, rate in day["rates"].items():    pay = (salary_usd * Decimal(str(rate))).quantize(Decimal("0.01"), ROUND_HALF_EVEN)    print(f"{cutoff} USD/{ccy} {rate} -> {pay:,} {ccy}")
Output
2026-10-30 USD/PHP 63.68 -> 203,776.00 PHP2026-10-30 USD/INR 94.955 -> 303,856.00 INR2026-10-30 USD/BRL 5.43251 -> 17,384.03 BRL

A run with cutoff set to a past date asks for that day's rate each time, so repeating the run gives the same figures.

Store what you used

  • Rate and date. The number you multiplied by, the pair (here USD to PHP), the date you asked for and is_forward_filled from the response.
  • Amounts. The source amount, the converted amount and the rounding rule.

Average over the month

Some contracts convert at the average rate for the month. The range endpoint returns one rate per business day, and the average is a line of code. Free covers the last 30 days of daily history. Basic ($19 a month) covers a year, and Plus ($39 a month) covers everything back to 1999.

Shell
curl "https://api.exchangerate.dev/v1/range?base=USD&symbols=PHP&start_date=2026-10-01&end_date=2026-10-05" \  -H "X-API-Key: $EXCHANGERATE_API_KEY"
Output, trimmed to the rates
{"data":[{"date":"2026-10-01","rates":{"PHP":62.799}},{"date":"2026-10-02","rates":{"PHP":62.597}},{"date":"2026-10-05","rates":{"PHP":62.673}}],"has_more":false}

October 3 and 4 were a weekend, so the range holds three rows for five calendar days. Divide by the rows you get back.

Indicative rates

The API serves indicative rates. If your contract names a specific bank or central bank rate, use that source for the conversion and keep this API for estimates and cross-checks. The official rates tables cover tax and customs authorities.

Questions

Which rate date should payroll use?

The one your contract names. When it is silent, use the last business day of the period and write that rule into the contract.

Why store the rate if I can query the date again?

The stored rate is the one you paid on. It also survives a plan change, since the history window depends on the plan.

Can I get monthly averages directly?

Not as one number. Request the range for the month and average the rows, or use the official-rate period endpoint for tables that publish an average.

Keep reading

Run this against the live API

The Free plan gives 5,000 requests a month and 10 a minute. Commercial use is allowed with a visible, linked credit. Calls without a key work at 100 an hour per IP address.

Get a free key