# UK Trade Data - Imports & Exports by Commodity 2000-2026 (`j0401/uk-trade-info`) Actor

HMRC overseas trade statistics (OGL v3, no key): UK imports and exports by commodity (CN8/HS6/HS4/HS2), country and port, monthly from 2000 to the latest published month. Value in GBP, net mass and supplementary units, with server-side filtering and aggregation.

- **URL**: https://apify.com/j0401/uk-trade-info.md
- **Developed by:** [Wenhao Yang](https://apify.com/j0401) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.03 / 1,000 uk trade records

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-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 Data - Imports & Exports by Commodity 2000-2026

HMRC's Overseas Trade Statistics: what the UK imported and exported, by
commodity code, country and port, every month from **January 2000** to the
latest published month (**August 2026**). **503,906 detail rows** in the
latest month alone, with **£99.21 billion** of trade. The lookup tables cover
**16,243 commodity entries**, **263 countries** and **190 ports**.

### Low cost

**From $0.00005 per record, down to $0.00003 at Gold.** Pay only for the
records you receive - the whole 122-million-row statistics table stays
queryable, and you are never billed for the scan behind it.

### What you get per row

| field | meaning |
|---|---|
| `month` | the row's trade month, `YYYY-MM` (blank on a multi-month grouped row that does not group by month; `groupKey` then carries the dimension) |
| `flow` | `EU Imports`, `EU Exports`, `Non-EU Imports`, `Non-EU Exports` |
| `commodityCode`, `commodityDescription` | CN8 code and its HS2/HS4/HS6/CN8 description |
| `countryCode`, `countryName` | ISO alpha-2 code and country |
| `portCode`, `portName` | port or airport |
| `valueGbp` | trade value in pounds sterling |
| `netMassKg` | net mass in kilograms where published |
| `supplementaryUnits` | quantity in the commodity's supplementary unit (litres, items, ...) where published |
| `groupKey`, `groupCount`, `groupBy` | aggregate label, rows behind the group, dimension |
| `totalMatched`, `totalValueGbp` | rows and value matched by your filters |
| `refreshedDate` | latest published month |

### Latest month at a glance

| flow | value | detail rows |
|---|---|---|
| EU Imports | £26.71 bn | 171,449 |
| EU Exports | £14.08 bn | 110,104 |
| Non-EU Imports | £41.21 bn | 103,682 |
| Non-EU Exports | £17.21 bn | 118,671 |

The default (empty) run returns this table for the latest month.

### Search it

- **Commodity** - `commodity="30049000"` (CN8), `"300490"` (HS6),
  `"3004"` (HS4) or `"30"` (HS2 chapter). A 2-digit chapter filter also
  includes HMRC's chapter-level rows (trade published without CN8 detail).
- **Country** - `country="DE"` or `country="France"`.
- **Flow** - `flow="import"` (EU + non-EU), `"export"`, or one exact flow.
- **Month** - `month="2026-08"` for one month, or `monthFrom` / `monthTo`
  for a range. With both blank you get the latest month; `monthTo` alone
  covers the 12 months ending there.
- **Port** - `port="DOV"` (port code) or a port ID.

Search results are the first `maxResults` matching rows in the API's own
order - not a random sample. Use `mode=aggregate` when you need every group,
and `totalMatched` / `totalValueGbp` for the true size and value of the match.

### Example inputs

**Wine imports by country, latest month**

```json
{ "month": "2026-08", "commodity": "2204", "flow": "import",
  "mode": "aggregate", "groupBy": "country" }
```

**German imports in one HS chapter**

```json
{ "commodity": "22", "country": "DE", "flow": "import", "maxResults": 100 }
```

**One CN8 commodity's monthly history (last 12 published months)**

```json
{ "commodity": "30049000", "flow": "import", "mode": "aggregate",
  "groupBy": "month" }
```

### Aggregate it

`groupBy` = `flow` (default), `country`, `commodity`, `port` or `month`.
Aggregates return one row per group. The whole commodity universe is about
16,000 codes; an aggregate that would exceed 20,000 groups fails loudly
instead of silently truncating.

### Scope, exclusions and licence

- **Values are in GBP** as published by HMRC. Net mass is kilograms.
- **Ordinary OTS detail only**: the actor keeps `SuppressionIndex = 0`
  (excluding HMRC's disclosure-controlled index 2/3 rows) and drops the
  negative commodity IDs that HMRC uses as special aggregates. 2-digit
  chapter-level rows (01-99) are real published trade and are included, so a
  chapter filter returns more than the sum of its CN8 codes. Rows recorded
  at port "Not Collected" / "Estimates" are kept because they carry real
  trade; totals can therefore differ slightly from headline statistics.
- **Not trader-level data.** No business or personal identifier is used.
- Published under the **Open Government Licence v3**, which permits
  commercial reuse with attribution.

Data source: [HMRC UK Trade Info](https://www.uktradeinfo.com/).

# Actor input Schema

## `mode` (type: `string`):

summary = latest month totals by flow; search = OTS detail rows; aggregate = one row per group; months = the published months. Leave blank to auto-route: filters -> search, groupBy -> aggregate, no filters -> summary.

## `month` (type: `string`):

Month in YYYY-MM or YYYYMM (e.g. "2026-08"). Blank = the latest published month.

## `monthFrom` (type: `string`):

First month of a range (YYYY-MM). Use with monthTo. Blank with monthTo set = the 12 months ending at monthTo.

## `monthTo` (type: `string`):

Last month of a range (YYYY-MM). Blank = the latest published month; monthTo alone covers the 12 months ending there.

## `commodity` (type: `string`):

CN8 (8 digits), HS6 (6), HS4 (4) or HS2 (2) code, e.g. "22042110", "220421", "2204" or "22".

## `country` (type: `string`):

ISO alpha-2 code (e.g. "DE", "FR") or an exact country name.

## `flow` (type: `string`):

import = EU + non-EU imports; export = EU + non-EU exports; or one exact flow.

## `port` (type: `string`):

Port ID or port code, e.g. "7" or "DOV" (Dover).

## `groupBy` (type: `string`):

Aggregate dimension. flow = EU/non-EU imports and exports; country / port / commodity / month roll up the selected rows. month defaults to the last 12 published months when no month range is given. Blank defaults to flow.

## `maxResults` (type: `integer`):

Cap the number of search records pushed (0 = the default 50, maximum 5000). Aggregate returns every group.

## Actor input object example

```json
{
  "maxResults": 50
}
```

# Actor output Schema

## `recordsUrl` (type: `string`):

HMRC Overseas Trade Statistics records - as JSON

## `datasetUrl` (type: `string`):

No description

## `runUrl` (type: `string`):

No description

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("j0401/uk-trade-info").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("j0401/uk-trade-info").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 '{}' |
apify call j0401/uk-trade-info --silent --output-dataset

```

## MCP server setup

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

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/Dtimo8ri1KUSFPgLI/builds/0KPTd2Vd8gbD8FRz7/openapi.json
