A landed-cost quote or a DDP checkout shows the buyer duty and import tax before the goods move. The customs office computes those amounts later, from the declaration, at the exchange rate its own rules name. If your duty engine converts at a market rate, the two figures disagree: the seller absorbs the difference on DDP, or the buyer gets a bill they did not expect.
The fix is to quote at the official customs rate the entry will actually use. This post shows how, using the AllRatesToday customs exchange rate API as the data source. The full guide is at allratestoday.com/docs/customs/landed-cost-and-ddp/.
Why the customs rate, not a market rate
Duty is a percentage of the customs value in the importing country's currency, and import VAT or GST is then charged on the customs value plus duty. Both depend on converting the invoice at the rate the customs authority fixed for the declaration.
Most authorities fix that rate for a whole period: a week in Japan and Korea, a fortnight in India, a month across most of the EU, and a day set the evening before in Canada and Australia. That is useful for a quote engine: a quote made inside the period can use exactly the number customs will use.
One call for every destination
A checkout that ships worldwide needs the rate for whichever country the buyer picks. You don't want a call per country per page view. /api/v1/customs/all/latest returns every covered country at once, converted from your pricing currency to each country's customs currency. It counts as one API call and reads from a cache, so a once-a-day refresh is enough:
# USD -> each destination's customs currency, every covered country, one call (paid plans) curl "https://allratestoday.com/api/v1/customs/all/latest?source=USD" \ -H "Authorization: Bearer art_live_your_key" { "count": ..., "source": "USD", "countries": [ { "country": "AU", "authority": "abf", "currency": "AUD", "rate_date": "...", "stale": false, "source": "USD", "target": "AUD", "rate": ..., "rate_type": "...", "derived": false, "method": "published" }, ... ] } A country whose authority does not quote your pricing currency comes back with an error field instead of a rate. Skip it in the quote or fall back to a manual estimate; do not substitute a market rate without labelling it. On free plans, use /api/v1/customs/{country}/latest per country instead.
When the quote and the clearance fall in different periods
This is the case that trips up most implementations. The rate that counts is the one in force when the goods are declared, not when the order is placed. An order placed on 28 November for delivery in December clears on December's table. Three ways to handle it, in order of preference:
- Use the next table if it is already fixed. EU monthly tables are set before the month starts, Canada and Australia set tomorrow's rate the evening before, and China fixes next month's rate mid-month.
/api/v1/customs/{country}/next(paid plans) returns it within_force_from, or404while it is not set yet. - Otherwise quote on the current table and say so. Show the table date and that the amount is recalculated if clearance falls in a new period.
- For DDP, re-price at clearance. Once the declaration is filed, look up the declaration date with
/api/v1/customs/{country}/{date}and book the actual duty. The difference against the quote is your FX exposure, and it is usually small because tables move once per period.
A quote function
Putting the pieces together: refresh all destinations once a day, check whether the expected clearance date falls under a next table that is already fixed, then compute customs value, duty and import VAT.
import datetime as dt import requests API = "https://allratestoday.com/api/v1/customs" HEADERS = {"Authorization": "Bearer art_live_your_key"} def rates_for_quote(source_ccy): """Refresh once per day: today's customs rate for every destination.""" body = requests.get(f"{API}/all/latest", params={"source": source_ccy}, headers=HEADERS, timeout=10).json() return {c["country"]: c for c in body["countries"] if "rate" in c} def next_rate(country, source_ccy, target_ccy): """The table already fixed for the next period, or None if not set yet.""" r = requests.get(f"{API}/{country}/next", params={"source": source_ccy, "target": target_ccy}, headers=HEADERS, timeout=10) return r.json() if r.status_code == 200 else None def landed_cost(goods_value, freight, insurance, source_ccy, country, duty_rate, vat_rate, expected_clearance: dt.date, today_rates): today = today_rates[country] rate, table = today["rate"], today["rate_date"] # Clearance falls after the next table takes effect? Use it if it exists. nxt = next_rate(country, source_ccy, today["target"]) if nxt and expected_clearance.isoformat() >= nxt["in_force_from"]: rate, table = nxt["rate"], nxt["rate_date"] # Valuation basis is the country's: e.g. the EU adds freight to the border, the US does not. customs_value = round((goods_value + freight + insurance) * rate, 2) duty = round(customs_value * duty_rate, 2) import_vat = round((customs_value + duty) * vat_rate, 2) return {"customs_value": customs_value, "duty": duty, "import_vat": import_vat, "currency": today["target"], "rate": rate, "table_date": table} Note what the exchange rate does and does not do here. It converts whatever amount the country's valuation rule produces. The EU includes freight and insurance to the point of entry in the customs value; the US uses the transaction value without international freight. Keep that rule per country in your duty engine. The rate step is the same for all of them, which is why the example above folds freight and insurance in unconditionally and leaves the per-country rule to you.
Caching and rounding
- Refresh once a day. Daily tables change once a day and the rest less often, so a morning refresh of
/all/latest(and/nextfor the countries you ship to most) keeps every quote current. - Watch
stale. It istruewhen an authority is late with its next table. The rate is still the one in force, but flag the quote for review. - Round the amounts, not the rate. Use the rate as returned and round the customs value, duty and tax to the currency's minor unit. Customs computes the same way.
- Keep the table date with the order. If the buyer or a marketplace disputes the import charges, the
rate_dateand authority code show which official table the quote used.
One scoping note: storefront prices are a different problem. Market rates are fine for showing a product price in the buyer's currency; customs rates are for the duty line.
Links
- Guide: https://allratestoday.com/docs/customs/landed-cost-and-ddp/
- Customs exchange rate API: https://allratestoday.com/customs-exchange-rate-api/
- ERP and trade-system integrations: https://allratestoday.com/docs/integrations/
- API key: https://allratestoday.com/register/
Rates are redistributed from each institution's own publication. They are reference rates for accounting, tax and compliance, not dealing quotes.



