# UK Trade Tariff Lookup (`toolman98/uk-trade-tariff-lookup`) Actor

Official UK import duty, VAT, tariff preferences and import controls from the HMRC Trade Tariff API. Look up by commodity code or product keyword, optionally filtered by country of origin.

- **URL**: https://apify.com/toolman98/uk-trade-tariff-lookup.md
- **Developed by:** [顾 骥仁](https://apify.com/toolman98) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 commodity tariff lookups

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## UK Trade Tariff Lookup — official HMRC duty, VAT & preferences

Look up **live UK import duties** from the official [HMRC Integrated Online Trade Tariff API](https://www.trade-tariff.service.gov.uk/api/v2/). Give the Actor a commodity / HS code or a product keyword (and optionally a country of origin) and get clean, flattened JSON: UK Global Tariff (third-country / MFN) duty, tariff preferences, additional duties, VAT, supplementary units, legal bases and import controls.

No API key, no browser, no residential proxies. The Actor is a thin, rate-limited client over a public government JSON API licensed under the [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/).

**Built for:** UK importers, freight forwarders, customs brokers, Amazon / e-commerce sellers, landed-cost engines, and AI agents that need a reliable “what duty applies if I ship this HS code from Vietnam / China / the EU into the UK?” answer.

### Why this Actor

The official API returns a verbose JSON:API document (measures, duty expressions, geographical areas and legal acts split across `included`). This Actor:

- Accepts **10-digit UK commodity codes**, shorter HS codes (6–8 digits, padded) and **product keywords** via HMRC’s official fuzzy search.
- Expands a 4-digit **heading** into declarable child commodity codes when a direct lookup 404s.
- Optionally filters by **country of origin** (`filter[geographical_area_id]`) and computes an **applicable-duty summary** (preferential rate if one exists, otherwise the UK Global Tariff, plus additional duties and VAT).
- Strips HTML, flattens relationships, and returns one clean dataset row per declarable commodity.
- Supports an optional **as-of date** for historical snapshots.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `queries` | string\[] | `["6109100010"]` | Commodity / HS codes and/or product keywords. Punctuation in codes is ignored. |
| `originCountry` | string | `"CN"` | ISO 3166-1 alpha-2 origin (e.g. `CN`, `VN`, `DE`, `US`). Leave empty for the full unfiltered measure list. |
| `asOfDate` | string | live tariff | Historical snapshot `YYYY-MM-DD`. |
| `maxCommodities` | integer | `5` | Cap on declarable codes returned (1–50). Applies to keyword search and heading expansion. |
| `includeMeasures` | boolean | `true` | Include the flattened measure list on each record. |

#### Example input

```json
{
  "queries": ["6109100010", "cotton t-shirt"],
  "originCountry": "CN",
  "maxCommodities": 3
}
```

A Vietnam-origin run of the same cotton T-shirt (`6109100010`, `originCountry: "VN"`) returns a **0% tariff preference** (UK–Vietnam and CPTPP) instead of the 12% UK Global Tariff that applies to China.

### Example output

One dataset item (abridged) for cotton T-shirts of HS `6109100010` from China:

```json
{
  "query": "6109100010",
  "queryType": "code",
  "commodityCode": "6109100010",
  "description": "T-shirts",
  "declarable": true,
  "originCountry": "CN",
  "thirdCountryDuty": "12.00 %",
  "thirdCountryDutyPercent": 12.0,
  "preferentialDuty": null,
  "vatRates": [
    { "duty": "0.00%", "dutyPercent": 0.0, "conditions": [] },
    { "duty": "20.00%", "dutyPercent": 20.0, "conditions": [] }
  ],
  "supplementaryUnit": "items (p/st)",
  "applicableDuty": {
    "originCountry": "CN",
    "basis": "third_country_duty",
    "scheme": "UK Global Tariff (ERGA OMNES)",
    "customsDuty": "12.00 %",
    "customsDutyPercent": 12.0,
    "additionalDuties": [],
    "vatPercent": 20.0,
    "vatRates": ["0.00%", "20.00%"],
    "note": "No tariff preference applied for the requested origin; the UK Global Tariff / third-country duty applies."
  },
  "officialUrl": "https://www.trade-tariff.service.gov.uk/commodities/6109100010?country=CN",
  "source": "HMRC UK Integrated Online Trade Tariff API v2",
  "license": "Open Government Licence v3.0",
  "retrievedAt": "2026-12-03T00:20:00Z"
}
```

`applicableDuty` is the field AI agents should read first. Preferential rates usually require a valid proof of origin — do not treat them as automatically claimable.

### Use cases

- Landed-cost and retail-price calculation for goods sold into the UK after Brexit.
- Comparing **China vs Vietnam / EU / CPTPP** origin for the same commodity code.
- Monitoring additional duties (e.g. Russia / Belarus) and import controls alongside the base rate.
- Feeding structured UK duty data into a compliance, ERP or AI-agent workflow (JSON / CSV / Excel export, or the Apify API).

### Pricing suggestion (Pay-Per-Event)

Recommended primary event: **`commodity-lookup` at $0.01** per declarable commodity record successfully written to the dataset.

- Platform cost per default run (256 MB, a few official HTTP calls, well under 60 seconds) is typically a fraction of a cent.
- After Apify’s 20% platform share, gross profit per record is about **$0.008** minus compute, i.e. a very high margin.
- Keyword searches and heading expansions only charge for the commodity records actually returned, not for intermediate search calls.

Set this in **Apify Console → Publishing → Monetization** (not in the source). Keep `apify-actor-start` at $0 or a negligible amount so AI agents and first-time users get a cheap sample run.

### Source, licence and limits

- API: `https://www.trade-tariff.service.gov.uk/api/v2/` (no authentication today).
- Data licence: [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/). Attribute “Contains public sector information licensed under the Open Government Licence v3.0.”
- HMRC has announced further rate limiting for unauthenticated traffic later in Q4 2026; this Actor already rate-limits requests (~3/sec) and retries 429/5xx. An optional API-key input can be added if keys become required.
- This Actor does **not** give legal advice or a Binding Tariff Information (BTI) ruling. Classification and preference claims remain the importer’s responsibility.
- Results are official public tariff data, not personal data.

### Local development

```bash
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

## Default input (from input schema defaults)
APIFY_LOCAL_STORAGE_DIR=./storage python -m src

## Or drop a custom INPUT.json into storage/key_value_stores/default/ and re-run
```

Dataset items are written to `storage/datasets/default/`.

To publish for the `toolman98` account, install the [Apify CLI](https://docs.apify.com/cli), run `apify login`, then `apify push` from this directory (or connect the GitHub repo in Console). Turn on monetization and complete KYC before making the Actor public.

# Actor input Schema

## `queries` (type: `array`):

Commodity / HS codes (2–10 digits; punctuation is ignored) and/or product keywords such as "cotton t-shirt". Numeric codes are looked up directly; keywords use the official HMRC fuzzy search.

## `originCountry` (type: `string`):

Optional ISO 3166-1 alpha-2 code (e.g. CN, VN, DE, US). When set, measures are filtered to those that apply to that origin, and an applicable-duty summary is computed. Leave empty to return the full measure list (MFN + all preferences).

## `asOfDate` (type: `string`):

Optional historical snapshot in YYYY-MM-DD. Defaults to the live (current) tariff.

## `maxCommodities` (type: `integer`):

Maximum number of declarable commodity codes to return. Caps keyword-search and heading-expansion results.

## `includeMeasures` (type: `boolean`):

If enabled, each record includes the flattened list of import measures (duties, preferences, VAT, additional duties and controls).

## Actor input object example

```json
{
  "queries": [
    "6109100010"
  ],
  "originCountry": "CN",
  "maxCommodities": 5,
  "includeMeasures": true
}
```

# Actor output Schema

## `commodities` (type: `string`):

Looked-up UK commodity codes with official HMRC duty, VAT and control data.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "queries": [
        "6109100010"
    ],
    "originCountry": "CN",
    "maxCommodities": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("toolman98/uk-trade-tariff-lookup").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "queries": ["6109100010"],
    "originCountry": "CN",
    "maxCommodities": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("toolman98/uk-trade-tariff-lookup").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "queries": [
    "6109100010"
  ],
  "originCountry": "CN",
  "maxCommodities": 5
}' |
apify call toolman98/uk-trade-tariff-lookup --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,toolman98/uk-trade-tariff-lookup"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/qEyKHNgcs5TszyFip/builds/hzsVBy8aOOWPJEsAK/openapi.json
