UN Comtrade Scraper avatar

UN Comtrade Scraper

Pricing

from $3.00 / 1,000 results

Go to Apify Store
UN Comtrade Scraper

UN Comtrade Scraper

Scrape UN Comtrade international trade statistics - bilateral trade flows, commodity data by HS/BEC/SITC codes, import/export values, weights, and quantities for any country pair.

Pricing

from $3.00 / 1,000 results

Rating

5.0

(4)

Developer

Crawler Bros

Crawler Bros

Maintained by Community

Actor stats

4

Bookmarked

2

Total users

1

Monthly active users

a day ago

Last modified

Share

Extract international trade statistics from the United Nations Comtrade database — the world's most comprehensive repository of bilateral trade flow data. Covers 200+ countries, 5,000+ HS commodity codes, and annual/monthly series going back decades.

No API key is required. This actor uses the public preview endpoint.


What Can It Do?

  • Fetch commodity trade flows — imports and exports between any country pair for any HS/BEC/SITC commodity code
  • Get all-commodity totals — aggregate trade value for a country's full trade
  • List reporter countries — get all valid country codes for use in queries
  • Annual & monthly data — choose your time granularity
  • Commodity classification — HS (Harmonized System), BEC, or SITC

Input

FieldTypeDescriptionExample
modeselectgetCommodityTrade or listReportersgetCommodityTrade
typeCodeselectC (Commodity) or S (Service)C
freqCodeselectA (Annual) or M (Monthly)A
clCodeselectHS, BEC, or SITCHS
reporterCodestringNumeric country code (842=USA, 36=AUS, 826=UK)842
partnerCodestringPartner country code; 0 = World0
cmdCodestringHS commodity code or TOTAL8471
periodstringYear (2022) or year-month (202201)2022
maxItemsintegerRecords cap (1–500)100

Common Country Codes

CodeCountry
842United States
36Australia
826United Kingdom
156China
276Germany
392Japan
381Italy
251France
124Canada
356India

Common HS Commodity Codes

CodeDescription
TOTALAll commodities
8471Automatic data processing machines (computers)
2709Crude petroleum oils
8703Passenger motor vehicles
8517Telephones and smartphones
8542Integrated circuits
1001Wheat
2601Iron ores
3004Medicaments
7108Gold

Output

Each record contains:

FieldTypeDescription
periodstringYear (e.g. "2022") or year-month
reporterCodeintegerNumeric country code of reporter
reporterISOstringISO-3 code (e.g. "USA")
reporterDescstringCountry name
flowCodestringM=Import, X=Export, DX=Re-export
flowDescstringHuman-readable flow description
partnerCodeintegerNumeric partner country code
partnerISOstringPartner ISO-3 code
partnerDescstringPartner country name
cmdCodestringHS commodity code
cmdDescstringCommodity description
tradeValuefloatTrade value in USD
netWgtfloatNet weight in kg
grossWgtfloatGross weight in kg
qtyfloatQuantity
qtyUnitCodeintegerQuantity unit code
qtyUnitAbbrstringQuantity unit abbreviation
isReporterbooleanWhether this is a reporter country
sourceUrlstringSource URL
recordTypestring"trade" or "reporter"
scrapedAtstringISO timestamp of scrape

Example Use Cases

1. US Computer Imports from All Partners (2022)

{
"mode": "getCommodityTrade",
"reporterCode": "842",
"partnerCode": "0",
"cmdCode": "8471",
"period": "2022",
"maxItems": 100
}

2. Total Trade for Germany (Annual 2023)

{
"mode": "getCommodityTrade",
"reporterCode": "276",
"cmdCode": "TOTAL",
"period": "2023",
"freqCode": "A"
}

3. Monthly Oil Trade (January 2023)

{
"mode": "getCommodityTrade",
"reporterCode": "842",
"cmdCode": "2709",
"period": "202301",
"freqCode": "M"
}

4. List All Reporter Countries

{
"mode": "listReporters",
"maxItems": 500
}

Frequently Asked Questions

Do I need an API key? No. This actor uses the UN Comtrade public preview endpoint which is free and requires no registration.

How many records can I get? The public API returns up to 500 records per request. Set maxItems accordingly.

What are reporter vs. partner countries? The reporter is the country submitting the trade data (the one whose customs records are used). The partner is the country they traded with.

What does partnerCode=0 mean? Code 0 means "World" — all trade partners aggregated together.

What if data comes back empty? The public preview API has limited coverage. Some country/commodity/period combinations may not be in the preview dataset. Try a more common country like USA (842) or a recent year.

What is the HS classification? The Harmonized System (HS) is an international standard for classifying traded goods. 6-digit codes identify specific products; 2-digit "chapters" group related goods.

Can I get service trade data? Yes, set typeCode to S. Service data is less granular than commodity data.


Data Source

Data comes from the UN Comtrade database, maintained by the United Nations Statistics Division. It is the largest repository of international merchandise trade data.