The rate is the easy part: what a tariff API needs to be useful
A tariff lookup looks simple. Send an HS code, get a duty rate, show it in a table.
I built TariffAPI around that lookup. The rate turned out to be the smallest part of the response.
Here is a real example. The same code, 61091000, in three public destinations. Set TARIFFAPI_KEY to a direct API key before running it:
curl -H "X-API-Key: $TARIFFAPI_KEY" \ "https://api.matakupanlabs.com/v1/tariff?hs=61091000&destination=US" The US response returns:
{ "hs6": "610910", "destination": "US", "national_code": "61091000", "description": "Of cotton", "duty_rate": "16.5%", "duty_pct": 16.5, "match_level": "national_8", "source": "USITC HTS 2026", "version": "2026-11-25", "effective_date": "2026-01-01" } The EU response for the same code returns a 12.000% rate, but with match_level: "hs6" and an empty national_code. The UK response returns 404 tariff_not_found for that code in the public dataset.
One code. Three different outcomes. A table that shows only 16.5%, 12.000%, and an empty cell would hide the part that matters.
Three layers in one response
1. The code layer
The six digit HS code is the shared parent. The national code is where the rate actually lives.
A US line can be eight digits. An EU or UK line can be ten. A client that treats all codes as six digits will miss national subdivisions, units, and conditions.
match_level tells the client what it received:
-
national_8ornational_10: an exact national line -
hs8: an eight digit fallback -
hs6: the parent rate -
hs6_representative: the parent rate varies across children
That field is more useful than a boolean found flag. It lets the caller decide whether to show the result, ask for a more specific code, or stop.
2. The source layer
A duty rate without a source is hard to defend in a customs workflow.
Each record includes:
-
source: the dataset name -
source_url: the official source -
version: the dataset version -
effective_date: the base date of the line -
meta.request_id: the request identifier
The date matters. A rate can be correct for one period and wrong for another. A source URL lets a human check the claim without searching a portal by hand.
3. The meaning layer
duty_rate is the text a person reads. duty_pct is the numeric value a program can compare. They are both present because clients use them differently.
Empty strings and zero are not the same thing:
-
0.0means a real zero rate. - An empty
duty_ratemeans the source did not provide a usable rate.
A response also has qualifier, unit, and end_date because tariff lines are not always a single unconditional percentage. A conditional rate, a specific duty, or an expiring measure needs a different presentation.
What I changed after building the lookup
Return a gap, not a guess
If a code has national children but no HS6 parent, the API returns 404 coverage_gap and tells the caller to use the eight or ten digit code. If a destination has no row, it returns 404 tariff_not_found.
Returning an empty rate would let a client render a blank cell as if it were a valid answer. An explicit error is easier to handle and easier to audit.
Keep the source trail in the same object
The source fields are part of the record, not a separate documentation page. A client can store the source and version with the result. That makes a later review possible without asking the API what it meant six months ago.
Treat the sample as a schema test, not a database
The public sample has 120 real records, 40 each for the US, EU, and UK. It is one national line per HS chapter where possible, and it includes the JSON Schema, CSV, and a validator. The sample was generated on 28 November 2026 from USITC HTS 2026, TARIC 2026-11, and UK Trade Tariff 2026-11-25.
git clone https://github.com/FauziMatakupan/tariffapi-sample cd tariffapi-sample python3 -m venv .venv . .venv/bin/activate pip install -r requirements.txt python scripts/validate.py The sample exists so a developer can inspect the shape before creating an account. It is not a replacement for the live dataset, and it is not an official customs publication.
What I would test before trusting a tariff lookup
- Does the response tell you whether the code matched a national line or only a parent?
- Can you see the source, version, and effective date without leaving the response?
- Does a missing rate produce an error, or a blank value that looks valid?
- Does the API distinguish zero from missing?
- Can you retrieve a stable request ID for support and debugging?
These are the questions I would ask before putting a tariff lookup behind an import calculation. The duty rate is the visible output. The source trail is what makes the output usable.
TariffAPI is a project I maintain at Matakupan Labs. The sample, schema, and validator are at github.com/FauziMatakupan/tariffapi-sample. The live documentation is at tariffapi.dev/docs.
The sample is not legal or customs advice. Verify the official source before making a decision.