Microproduct data guideintermediate

UN Comtrade

Official merchandise trade statistics for building partner and commodity monitors from a bounded Comtrade extract.

At a glance

Difficulty
Intermediate — some data preparation helps
Size
Medium · ≤1 GB
Formats
JSON, CSV
Access
API or Download
API key
Not required
Provider
United Nations Statistics Division
Updates
Monthly

From source to product signal

Test a product idea in four steps

Comtrade preview returns up to 500 trade records without a key. Start with one reporter, one year, and total merchandise trade. Mirror statistics disagree, confidential HS lines are suppressed, and a preview is not a complete bulk extract.

1

Check the setup

  • Python 3.10 or newer
  • A notebook environment such as Jupyter or Google Colab
  • An internet connection
2

Access the data

  1. 1.Open Comtrade Plus and note the preview API for unauthenticated queries.
  2. 2.Request one reporter, one period, and HS total trade with a small record limit.
  3. 3.Keep reporter, partner, flow, and primary value.
Open official source
3

Run the Python example

Install the packages, then run the notebook cell.

python -m pip install pandas requests

import pandas as pd
import requests

response = requests.get(
    "https://comtradeplus.un.org/api/preview/C/A/HS",
    params={
        "reporterCode": 842,
        "period": 2023,
        "partnerCode": 0,
        "cmdCode": "TOTAL",
        "flowCode": "X,M",
        "maxRecords": 100,
    },
    timeout=60,
)
response.raise_for_status()
payload = response.json()
trade = pd.DataFrame(payload.get("data", payload))
trade["retrieved_at_utc"] = pd.Timestamp.now(tz="UTC")
print(trade.head())
4

Test a useful signal

Compare U.S. total merchandise exports and imports

Test whether a preview extract can power a bounded trade-balance sketch.

  1. 01Keep reporter, period, flow, and primary value from the preview response.
  2. 02Compare export and import totals for the selected year.
  3. 03Explain that preview rows are capped, partners can be aggregated, and confidential commodities are omitted.

Dataset details

United Nations Statistics Division is an intergovernmental source. Last verified 2026-08-18. Temporal coverage: reporter-specific annual and monthly trade statistics.

Theme

Markets & Economics

Domains

International EconomicsTradeCommodities

Data types

Time SeriesTabular

Tasks

Trade MonitoringCountry ComparisonMarket Analysis

Geography

Global

Formats

JSONCSV

Provider

United Nations Statistics Division

Data terms

United Nations website terms of use