DEV Community

Russell Yapp
Russell Yapp

Posted on

Finding UK importers of a product by HS code with HMRC's open data

Not affiliated with HMRC. The data comes from HMRC UK Trade Info, published under the Open Government Licence v3.0.

If you sell something, source something or research a market, a common question is who in the UK already imports or exports it. HMRC publishes monthly lists of importers and exporters by commodity code, but the raw files are awkward: one file per month, codes at several lengths, and names mixed with sole traders.

This post goes from a product to a list of UK traders using HS and CN8 codes. It covers choosing a code, searching by code, flow and month, and reading the output in Python. The rows come from an Apify Actor I built, UK Importers and Exporters: HMRC Trade Data. It returns one row per trader, flow and month, with the outward code of the postcode only and no address. A name is kept only if it carries an organisation marker such as Limited, Ltd, PLC or LLP, so sole traders are left out. Pricing is pay per event: $0.005 a run plus $0.002 per trader row.

This is a list of companies from public records. It tells you nothing about volumes or values.

To follow along without running anything, there is a free 20-row sample on Kaggle (HS 8419, August 2026). The rows are in name order from the start of the list, so it is not a random or representative sample of the month. If you want to run a search yourself, there is a ready-made example Task: HS 8419, imports, 20 rows.

1. What the rows contain, and what they do not

Each row says that a trader dealt in goods under some commodity codes in a given month, in one flow: imports or exports. The row carries the 8-, 6- and 4-digit commodity codes that trader dealt in, and the outward code of its postcode (for example the first half of a postcode, not the whole thing).

There are no address lines, no full postcodes, and no trade values or volumes. The rows say who traded under a code, not how much.

2. From a product to a code

HS codes classify goods. The first two digits give a chapter, four digits a heading, six digits a subheading. UK trade statistics use eight digits (CN8), which narrow the subheading further. The sample above uses the four-digit heading 8419.

Pick the longest code you are sure of. A short code is broader, so it brings back more traders; a long one is narrower. If you search on a shorter code, traders whose rows carry a longer code beneath it are included. That is why each row lists its codes at several lengths (hs4Codes, hs6Codes, cn8Codes): you can check which code a trader actually matched on.

To find a code for a product, look it up in the UK Trade Tariff and note it at the length you can defend.

3. Running a search

The input takes the commodity codes, whether you want imports, exports or both, and a month range. The quickest way to see it work is the example Task linked above, which is set up for HS 8419 imports and 20 rows. Run it, open the dataset, and you have the same kind of rows described here. The Kaggle sample has both flows; the example Task is imports only, so the two will not be identical.

A run is charged at $0.005 plus $0.002 per trader row, so a 20-row search comes to about $0.045.

4. Reading the rows in Python

Export the dataset as JSON from the Apify Console and load it. This snippet counts rows by flow, lists traders that appear in both flows, and shows the most common postcode districts.

import json
from collections import Counter

with open("traders.json", encoding="utf-8") as f:
    rows = json.load(f)

print(Counter(r["flow"] for r in rows))

imports = {r["name"] for r in rows if r["flow"] == "imports"}
exports = {r["name"] for r in rows if r["flow"] == "exports"}
print("In both flows:", sorted(imports & exports))

print(Counter(r["postcodeDistrict"] for r in rows).most_common(10))
Enter fullscreen mode Exit fullscreen mode

A row looks like this (illustrative only: the name is an invented example and the code lists are shortened):

{"name": "Example Trading Limited", "postcodeDistrict": "EX2", "flow": "imports", "month": "2026-09", "hs6Codes": ["..."]}
Enter fullscreen mode Exit fullscreen mode

Other fields include traderId, traderKey, cn8Codes, hs4Codes, otherCodes, source, publishedAt and matchType.

5. Looking up a named company, and watching a code

The same Actor can look up a named company and can alert you to traders that are new to a code. The Actor page describes how to set either up.

6. Limits

  • Postcode district only: no address lines and no full postcodes.
  • Sole traders are left out, but the name rule is not a guarantee. If you see a name that should not be there, or you want a business removed, email info@yappman.com with the name as it appears in the data. I reply within one month.
  • No trade values or volumes.
  • HMRC publishes the lists monthly, so the data trails the month it describes. The Kaggle sample covers August 2026.
  • Names and codes are as published; I do not correct them.

7. Licence and credit

The data is published under the Open Government Licence v3.0, which does not cover personal data; that is why names without an organisation marker are withheld. Keep this credit line with any copy or use:

Contains public sector information licensed under the Open Government Licence v3.0 (HMRC, UK Trade Info).

Compiled by Yappman Data. Not affiliated with HMRC.

8. Cost

$0.005 a run plus $0.002 per trader row. The 20-row example costs about $0.045. Pay-per-event pricing means a larger search costs in proportion to the rows it returns.

Try it

I built the Actor and publish the sample. Corrections and questions: info@yappman.com.

Top comments (0)