A marketplace collects in one currency and pays sellers in theirs. A payout run needs one request for the whole batch, rounding that never pays more than the balance, and a record of the rate each seller received. The script below pays four sellers from a dollar balance after a 2% fee.
One request for the batch
Collect the payout currencies from the sellers who are due, then ask for all of them at once. A run of 5,000 sellers in 12 currencies still costs one request. The script rounds down to the currency's smallest unit, so the platform never pays out a fraction it does not hold. Yen has no decimals, and /v1/currencies lists the minor units for every code.
import json, urllib.requestfrom decimal import Decimal, ROUND_DOWNdef get(path): return json.load(urllib.request.urlopen(f"https://api.exchangerate.dev/v1/{path}"))MINOR = {"JPY": 0} # decimal places; everything else uses 2sales = {"EUR": Decimal("1840.50"), "GBP": Decimal("612.00"), "JPY": Decimal("99.99"), "AUD": Decimal("2210.75")} # USD owed to each sellerrates = get("latest/USD?symbols=" + ",".join(sales))["rates"]for ccy, usd in sales.items(): places = Decimal(1).scaleb(-MINOR.get(ccy, 2)) fee = usd * Decimal("0.02") payout = ((usd - fee) * Decimal(str(rates[ccy]))).quantize(places, ROUND_DOWN) print(f"{ccy}: owed {usd} USD, fee {fee:.2f}, rate {rates[ccy]}, pay {payout:,} {ccy}")EUR: owed 1840.50 USD, fee 36.81, rate 0.89264, pay 1,610.04 EURGBP: owed 612.00 USD, fee 12.24, rate 0.7457, pay 447.24 GBPJPY: owed 99.99 USD, fee 2.00, rate 157.957, pay 15,478 JPYAUD: owed 2210.75 USD, fee 44.22, rate 1.4268, pay 3,091.21 AUDCheck one payout with the convert endpoint
To verify a figure, ask the API to convert it. The convert endpoint returns the rate, the converted amount and the timestamp of the data. Yen comes back as a whole number.
curl "https://api.exchangerate.dev/v1/convert/USD/JPY/1250"{"result":"success","from":"USD","to":"JPY","amount":1250.0,"rate":157.917,"converted":197396.0,"stale":false,"data_updated_at":"2026-11-02T11:29:00Z"}Keep the rate on each payout
Write the rate, the data_updated_at timestamp and the rounding rule on every payout row. A seller who asks why they received 15,478 yen gets an answer from the row: 97.99 USD at 157.957. If the payout provider applies its own rate, keep both, and treat this one as the platform's reference.
Fetch once per run
Fetch the rates when the run starts and use them for the whole run. Sellers paid in the same currency in the same run then get the same rate, and a run that takes ten minutes does not drift between the first and last seller. Rates without a key arrive about 15 minutes after the market. Paid plans return rates about a minute old on trading days.
The API returns indicative rates. Your payout provider or bank sets the rate at which money actually moves. Use this API to show sellers an estimate before payout and to reconcile afterwards.