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.
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}")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 BRLA 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
dateyou asked for andis_forward_filledfrom 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.
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"{"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.
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.