Skip to content

UN Comtrade Trade Data Scraper

Try for free

Export and import statistics from UN Comtrade by reporting country, partner country, HS code and year or month: trade value in US dollars, net weight in kg, quantity, HS subheadings and national tariff lines. No login or key needed.

🌍 UN Comtrade Trade Data Scraper

Get official export and import statistics from UN Comtrade as clean rows: for any reporting country, product (HS code) and year or month, the trade value in US dollars, the net weight in kg and the quantity, for every partner country. Go deeper with all 6-digit HS subheadings and the country's own national tariff lines (for example Indonesia's 08109091 for salak). No login or API key needed. $1.70 per 1,000 rows on every plan.

✨ Why use UN Comtrade Trade Data Scraper?

  • 🌐 Every partner in one run — one row per partner country plus the World total, for each year or month and product you ask for.
  • 💵 Value and volume — trade value in USD (FOB for exports, CIF for imports where reported), net weight in kg, quantity with its unit, and whether UN Comtrade estimated the weight or quantity.
  • 🔢 Down to the tariff line — 2-, 4- and 6-digit HS codes, every 6-digit subheading under a heading, and the reporting country's own 8- to 12-digit national tariff lines where it publishes them.
  • 📅 Up to date — when a country has not published annual figures for a year yet (usually the current year), the published months of that year are returned instead, one row per month.
  • 🔗 Traceable — every row carries the UN Comtrade query it came from, the HS classification edition and the dataset's last release date.
  • ✅ Straight from the source — figures are those the countries report to UN Comtrade (United Nations Statistics Division); nothing is estimated or filled in by the scraper.

🎯 Use cases

  • 📈 Export market research — which countries buy a product from a country, how much and at what value per kg, year by year.
  • 🏭 Supplier and sourcing analysis — where a country imports a product from and how the mix changes.
  • 🧾 Trade and policy reports — time series per product and partner for reports, dashboards and models.
  • 🤖 Data pipelines and AI — scheduled runs feeding trade figures into spreadsheets, BI tools or AI agents.

🚀 How to use

  1. Enter one or more Reporting countries (for example Indonesia, IDN or 360).
  2. Enter HS codes (for example 0810 for other fresh fruit, 090111 for coffee, or TOTAL for all goods).
  3. Pick the Trade flow (exports, imports, re-exports, re-imports) and the years.
  4. Optionally limit Partner countries, add 6-digit subheadings or national tariff lines, and click Start.
  5. Open the Trade records view or export the data as JSON, CSV or Excel.

📥 Input

FieldWhat it does
reportersReporting countries: name, ISO code or UN M49 code
hsCodesHS codes (2, 4 or 6 digits), TOTAL, or a national tariff line (8+ digits)
flowsX exports, M imports, RX re-exports, RM re-imports (default exports)
yearFrom / yearToYears to read (default: the last five years)
frequencyannual (default) or monthly
monthlyWhenNoAnnualUse the published months for years without annual figures yet (default on)
partnersOnly these partner countries (default: all)
includeWorldAlso the World total row (default on)
includeSubheadingsAlso every 6-digit subheading under 2- and 4-digit codes
includeNationalTariffLinesAlso the reporting country's national tariff lines
maxItemsStop after this many rows (empty = all)

Example: Indonesia's exports of other fresh fruit (HS 0810) to every country, 2020 to 2026, with subheadings and national tariff lines:

{
  "reporters": ["Indonesia"],
  "hsCodes": ["0810"],
  "flows": ["X"],
  "yearFrom": 2020,
  "yearTo": 2026,
  "includeSubheadings": true,
  "includeNationalTariffLines": true
}

📤 Output

One row per reporting country, partner, flow, period and product code:

{
  "reporter": "Indonesia",
  "reporterCode": 360,
  "reporterIso": "IDN",
  "partner": "Malaysia",
  "partnerCode": 458,
  "partnerIso": "MYS",
  "flow": "Export",
  "flowCode": "X",
  "year": 2024,
  "month": null,
  "period": "2024",
  "frequency": "annual",
  "hsCode": "08109091",
  "hsDescription": null,
  "codeLevel": "national",
  "parentHsCode": "081090",
  "parentHsDescription": "Fruit, edible; fruits n.e.c. in heading no. 0801 to 0810, fresh",
  "classification": "HS 2022",
  "tradeValueUsd": 1022449.122,
  "fobValueUsd": 1022449.122,
  "cifValueUsd": null,
  "netWeightKg": 2309738.436,
  "quantity": 2309738.436,
  "quantityUnit": "kg",
  "transportModes": ["Sea", "Road"],
  "datasetReleased": "2026-03-14",
  "source": "UN Comtrade (United Nations Statistics Division)",
  "sourceUrl": "https://comtradeapi.un.org/public/v1/previewTariffline/C/A/HS?reporterCode=360&period=2024&cmdCode=0810&flowCode=X"
}
FieldMeaning
reporter, reporterCode, reporterIsoThe reporting country
partner, partnerCode, partnerIsoDestination (exports) or origin (imports); World = total over all partners
flow, flowCodeExport, Import, Re-export or Re-import
year, month, period, frequencyThe period; month is set for monthly rows
hsCode, hsDescription, codeLevelProduct code, its name and level (HS2, HS4, HS6, total or national)
parentHsCode, parentHsDescriptionFor national tariff lines: the 6-digit HS code they belong to
classificationHS edition the country reported in (e.g. HS 2017, HS 2022)
tradeValueUsdTrade value in US dollars (the value UN Comtrade lists first for the flow)
fobValueUsd, cifValueUsdFOB and CIF values where reported
netWeightKgNet weight in kg; empty when the country did not report it
quantity, quantityUnitQuantity in the product's unit; empty when not reported
netWeightEstimated, quantityEstimatedTrue when UN Comtrade estimated the figure
transportModesNational tariff lines: modes of transport the line was reported under (their figures are summed)
datasetReleasedLast release date of the country's dataset for that period
sourceUrlThe UN Comtrade query the row came from

The run's OUTPUT record lists every query, the periods used, and notes such as years without published data or queries without any trade.

💰 Pricing

$1.70 per 1,000 rows ($0.0017 per row) on every plan, platform usage included. A product with ~40 partners over five years is about 200 rows, roughly $0.34. Set Max results or a maximum charge per run to cap the cost.

⚠️ Limits

  • UN Comtrade's public data service answers at most 500 records per query. The scraper reads one country, one period and one product code per query, and repeats a query in partner groups when it reaches 500 records, so normal requests are complete. If a single partner group still reaches 500 records, the run notes say so.
  • Countries publish annual figures months after the year ends; the current year is usually only available as monthly figures (see monthlyWhenNoAnnual).
  • National tariff lines exist only for countries that send them to UN Comtrade; their names are the country's own and are not in UN Comtrade's HS list, so the row names the 6-digit parent code. They have no World total row.
  • Figures are as reported by each country; UN Comtrade revises them when countries send corrections. A partner a country did not report trade with simply has no row.

❓ FAQ

Do I need a UN Comtrade account or key? No. The scraper uses UN Comtrade's public data service, which needs no key.

Why is the current year monthly? Most countries publish annual totals only after the year is complete. Until then, the scraper returns the months that are published (turn this off with monthlyWhenNoAnnual).

Why do two countries' figures for the same trade differ? Exports reported by one country and imports reported by its partner rarely match exactly (valuation FOB vs CIF, timing, partner attribution). Read the reporter whose view you need.

Where is the data from? UN Comtrade, United Nations Statistics Division (comtradeplus.un.org).

Related actors

//From the blog\\

Latest articles

All articles

The internet is full of data.
Start owning yours.

Scrape.ly gives you the infrastructure, the tooling, and the team to extract, process, and operationalize web data at any scale. Setup takes minutes.

No credit card. No setup calls.