Microproduct Data GuideIntermediate

UN Comtrade

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

Report a Problem

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
Last Verified
Aug 18, 2026
Source Type
Intergovernmental Source
  • Python Syntax Checked

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.

Geography

Formats

Provider

United Nations Statistics Division

Data Terms

United Nations website terms of use

Send Feedback