Skip to content
OSINTtools.io

UN Comtrade Database API

UN database of official import and export statistics by country, commodity code and year, with an API and bulk downloads.

Base URL
https://comtradeapi.un.org/public/v1
Sign-in
No key
Free tier
Free tier
Pricing
Free
Format
REST
Endpoints
8

Compiled by OSINTtools.io editors from comtrade.un.org · updated Nov 29, 2026Work on this API? Claim it to keep these docs currentReport a mistake

Introduction

The UN Comtrade Public API returns international trade statistics published by the UN Statistics Division: imports and exports reported by countries, by partner country, commodity and period, plus data availability, release lists, publication notes and world-share figures. An investigator can use it to check the declared trade between two countries or the reported flows of a commodity.

The public API needs no key and is at https://comtradeapi.un.org/public/v1. Its trade-data previews are limited to 500 records, one period and one commodity code. The other Comtrade APIs (full data, bulk files, large asynchronous queries) need a subscription key sent as the Ocp-Apim-Subscription-Key header or a subscription-key query parameter; a free key is available with any account, while bulk and asynchronous access are premium. Those keyed APIs are not documented here because their reference needs a login.

The docs mention a limit on the number of records and a rate limit on the preview APIs but state no numbers. Reporter, partner and commodity codes come from the Comtrade reference tables. Response bodies are JSON with elapsedTime, count, data and error; the preview example in the docs is cut off, so the fields shown for it are those visible in the docs.

Quick start

  1. No key needed

    The UN Comtrade Database API answers without an account or key.

  2. Make your first request

    Preview final trade data (up to 500 records, one period and one commodity).. Replace the example values and run it in a terminal, or use Try it on the endpoint.

    curl 'https://comtradeapi.un.org/public/v1/preview/C/A/HS'
  3. Read the response

    A 200 response looks like this, shortened.

    {
      "elapsedTime": "1.07 secs",
      "count": 1,
      "data": [
        {
          "typeCode": "C",
          "freqCode": "A",
          "refYear": 2022,
          "period": "2022",
          "reporterCode": 36,
          "reporterISO": null,
          "reporterDesc": null,
          "flowCode": "X",
          "partnerCode": 0,
          "partner2Code": 0,
          "classificationCode": "H6",
          "cmdCode": "TOTAL",
          "customsCode": "C00",
          "motCode": 0,
          "qtyUnitCode": -1,
          "qty": 0,
          "isQtyEstimated": false
        }
      ],
    …

Authentication

No key or account: every endpoint answers without one.

Rate limits and pricing

Preview results are capped at 500 records and a rate limit applies; its value is not stated in the docs

Free tier. Pricing: free.

Errors

StatusMeaning
400Invalid or missing parameters
500Unexpected server error

Trade data

  • Passive: the target is not contacted
  • Plan: No key needed

Returns a limited selection of trade data without a key: at most 500 records, at most 1 period and 1 commodity code. Codes for reporters, partners and commodities are in the Comtrade reference tables.

Path parameters

typeCodestringrequired

C for commodities, S for services

Example: COne of: C, S
freqCodestringrequired

A for annual, M for monthly

Example: AOne of: A, M
clCodestringrequired

Product classification: HS, SITC, BEC (goods) or EBOPS (services)

Example: HSOne of: HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS

Query parameters

reporterCodestring

Reporter code; several codes separated by commas

Example: 36
periodstring

Year (YYYY) or month (YYYYMM); a maximum of 1 period for preview

Example: 2023
partnerCodestring

Partner code; several codes separated by commas

Example: 0
cmdCodestring

Commodity code; a maximum of 1 for preview

Example: TOTAL
flowCodestring

Trade flow code, case-insensitive; several separated by commas; omit to not filter

Example: XOne of: M, X, RX, RM, MIP, XIP, MOP, XOP, MIF, XIF, DX, FM
Response fields · 21Show

elapsedTimestring

Time the server took

countinteger

Number of records returned

errorstring

Error text, empty on success

typeCodestring

C or S

freqCodestring

A or M

periodstring

Period (year or year-month)

refYearinteger

Reference year

reporterCodeinteger

Reporter code

reporterISOstring

Reporter ISO code (null in the preview)

reporterDescstring

Reporter name (null in the preview)

flowCodestring

Trade flow code

partnerCodeinteger

Partner code

partner2Codeinteger

Second partner code

classificationCodestring

Classification edition

cmdCodestring

Commodity code

customsCodestring

Customs procedure code

motCodeinteger

Mode of transport code

qtyUnitCodeinteger

Quantity unit code

qtynumber

Quantity

isQtyEstimatedboolean

Whether the quantity is estimated

altQtynumber

Alternative quantity

curl 'https://comtradeapi.un.org/public/v1/preview/C/A/HS'
No key needed
Response
{
  "elapsedTime": "1.07 secs",
  "count": 1,
  "data": [
    {
      "typeCode": "C",
      "freqCode": "A",
      "refYear": 2022,
      "period": "2022",
      "reporterCode": 36,
      "reporterISO": null,
      "reporterDesc": null,
      "flowCode": "X",
      "partnerCode": 0,
      "partner2Code": 0,
      "classificationCode": "H6",
      "cmdCode": "TOTAL",
      "customsCode": "C00",
      "motCode": 0,
      "qtyUnitCode": -1,
      "qty": 0,
      "isQtyEstimated": false
    }
  ],
  "error": ""
}

Preview tariff-line trade data (limited selection).

GET/previewTariffline/{typeCode}/{freqCode}/{clCode}

  • Passive: the target is not contacted
  • Plan: No key needed

Returns a limited selection of tariff-line records without a key, with optional filters on reporter, period, partner, second partner, commodity, flow, customs code and mode of transport. Several values go in comma-separated.

Path parameters

typeCodestringrequired

C for commodities, S for services

Example: COne of: C, S
freqCodestringrequired

A for annual, M for monthly

Example: AOne of: A, M
clCodestringrequired

Product classification: HS editions (goods)

Example: HSOne of: HS, H6, H5, H4, H3, H2, H1, H0

Query parameters

reporterCodestring

Reporter code(s)

Example: 36
periodstring

Year or month, comma-separated

Example: 2023
partnerCodestring

Partner code(s)

Example: 0
partner2Codestring

Second partner or consignment code(s)

cmdCodestring

Commodity code(s)

Example: TOTAL
flowCodestring

Trade flow code(s)

Example: X
customsCodestring

Customs code(s), C00 to C20

motCodestring

Mode of transport code(s)

Response fields · 17Show

elapsedTimestring

Time the server took

countinteger

Number of records returned

errorstring

Error text, empty on success

periodinteger

Period

reporterCodeinteger

Reporter code

flowCodestring

Trade flow code

partnerCodeinteger

Partner code

classificationCodestring

Classification edition

cmdCodestring

Commodity code

motCodeinteger

Mode of transport code

qtyUnitCodeinteger

Quantity unit code

qtynumber

Quantity

netWgtnumber

Net weight

grossWgtnumber

Gross weight

cifvaluenumber

CIF value

fobvaluenumber

FOB value

primaryValuenumber

Primary trade value

curl 'https://comtradeapi.un.org/public/v1/previewTariffline/C/A/HS'
No key needed
Response
{
  "elapsedTime": "1.20 secs",
  "count": 1,
  "data": [
    {
      "typeCode": "C",
      "freqCode": "M",
      "refPeriodId": 20230101,
      "period": 202301,
      "reporterCode": 36,
      "flowCode": "X",
      "partnerCode": 344,
      "partner2Code": -1,
      "classificationCode": "H6",
      "cmdCode": "010121",
      "customsCode": "-1",
      "mosCode": "-1",
      "motCode": 9900,
      "qtyUnitCode": 5,
      "qty": 10,
      "netWgt": 0,
      "grossWgt": 5000,
      "cifvalue": 0,
      "fobvalue": 1000,
      "primaryValue": 1000
    }
  ],
  "error": ""
}

Releases and metadata

List recent data releases.

GET/getComtradeReleases

  • Passive: the target is not contacted
  • Plan: No key needed

Lists the most recent dataset releases by reporter.

Response fields · 8Show

elapsedTimestring

Time the server took

countinteger

Number of records returned

errorstring

Error text, empty on success

reporterCodeinteger

Reporter code

flagCodestring

Country flag code

datasetDescstring

Dataset description

nrstring

N for new data

dateReleasestring

Release date and time

curl 'https://comtradeapi.un.org/public/v1/getComtradeReleases'
No key needed
Response
{
  "elapsedTime": "0.33 secs",
  "count": 1,
  "data": [
    {
      "reporterCode": 999,
      "flagCode": "XX",
      "datasetDesc": "Example CA 2023",
      "nr": "N",
      "dateRelease": "2025-01-01T00:00:00"
    }
  ],
  "error": ""
}

Get publication notes and exchange-rate metadata for datasets.

GET/getMetadata/{typeCode}/{freqCode}/{clCode}

  • Passive: the target is not contacted
  • Plan: No key needed

Returns, per dataset, the currency, conversion factors, trade system, valuation, partner-country basis and publication notes.

Path parameters

typeCodestringrequired

C for commodities, S for services

Example: COne of: C, S
freqCodestringrequired

A for annual, M for monthly

Example: AOne of: A, M
clCodestringrequired

Classification

Example: HSOne of: HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS
Response fields · 15Show

elapsedTimestring

Time the server took

countinteger

Number of records returned

errorstring

Error text, empty on success

reporterCodeinteger

Reporter code

periodinteger

Period

datasetCodeinteger

Dataset code

reporterDescriptionstring

Reporter name

currencystring

Currency

importConvFactorstring

Import conversion factor

exportConvFactorstring

Export conversion factor

tradeSystemstring

Trade system, for example General

importValuationstring

Import valuation, for example CIF

exportValuationstring

Export valuation, for example FOB

publicationNotestring

Publication note

publicationDatestring

Publication date and time

curl 'https://comtradeapi.un.org/public/v1/getMetadata/C/A/HS'
No key needed
Response
{
  "elapsedTime": "0.01 secs",
  "count": 1,
  "data": [
    {
      "reporterCode": 999,
      "period": 2022,
      "typeCode": "C",
      "freqCode": "A",
      "datasetCode": 1,
      "notes": [
        {
          "datasetCode": 1,
          "typeCode": "C",
          "freqCode": "A",
          "period": 2022,
          "reporterCode": 999,
          "reporterDescription": "Exampleland",
          "currency": "USD",
          "importConvFactor": "1",
          "exportConvFactor": "1",
          "tradeSystem": "General",
          "classificationCode": "H6",
          "importValuation": "CIF",
          "exportValuation": "FOB",
          "publicationNote": "Example publication note.",
          "publicationDate": "2023-03-09T00:00:00"
        }
      ]
    }
  ],
  "error": ""
}

Data availability

  • Passive: the target is not contacted
  • Plan: No key needed

Lists datasets by reporter and period, with record counts and release times.

Path parameters

typeCodestringrequired

C for commodities, S for services

Example: COne of: C, S
freqCodestringrequired

A for annual, M for monthly

Example: AOne of: A, M
clCodestringrequired

Classification

Example: HSOne of: HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS
Response fields · 12Show

elapsedTimestring

Time the server took

countinteger

Number of records returned

errorstring

Error text, empty on success

datasetCodeinteger

Dataset code

periodinteger

Period

reporterCodeinteger

Reporter code

reporterISOstring

Reporter ISO code

classificationCodestring

Classification edition

totalRecordsinteger

Number of records in the dataset

datasetChecksuminteger

Dataset checksum

firstReleasedstring

First release time

lastReleasedstring

Last release time

curl 'https://comtradeapi.un.org/public/v1/getDA/C/A/HS'
No key needed
Response
{
  "elapsedTime": "0.12 secs",
  "count": 1,
  "data": [
    {
      "datasetCode": 1,
      "typeCode": "C",
      "freqCode": "A",
      "period": 2022,
      "reporterCode": 999,
      "reporterISO": "XXX",
      "reporterDesc": "Exampleland",
      "classificationCode": "H6",
      "totalRecords": 1000,
      "datasetChecksum": 123456,
      "firstReleased": "2023-03-09T00:00:00",
      "lastReleased": "2023-03-09T00:00:00"
    }
  ],
  "error": ""
}

Get which tariff-line datasets are available and when they were released.

GET/getDATariffline/{typeCode}/{freqCode}/{clCode}

  • Passive: the target is not contacted
  • Plan: No key needed

Like getDA, for tariff-line data; it also reports the length of the commodity code.

Path parameters

typeCodestringrequired

C for commodities, S for services

Example: COne of: C, S
freqCodestringrequired

A for annual, M for monthly

Example: AOne of: A, M
clCodestringrequired

Classification

Example: HSOne of: HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS
Response fields · 13Show

elapsedTimestring

Time the server took

countinteger

Number of records returned

errorstring

Error text, empty on success

datasetCodeinteger

Dataset code

periodinteger

Period

reporterCodeinteger

Reporter code

reporterISOstring

Reporter ISO code

classificationCodestring

Classification edition

totalRecordsinteger

Number of records in the dataset

datasetChecksuminteger

Dataset checksum

firstReleasedstring

First release time

lastReleasedstring

Last release time

lengthCmdCodeinteger

Length of the commodity code

curl 'https://comtradeapi.un.org/public/v1/getDATariffline/C/A/HS'
No key needed
Response
{
  "elapsedTime": "0.06 secs",
  "count": 1,
  "data": [
    {
      "datasetCode": 2,
      "typeCode": "C",
      "freqCode": "M",
      "period": 202301,
      "reporterCode": 999,
      "reporterISO": "XXX",
      "classificationCode": "H6",
      "totalRecords": 2500,
      "datasetChecksum": 654321,
      "lengthCmdCode": 6,
      "firstReleased": "2023-04-27T00:00:00",
      "lastReleased": "2024-03-14T00:00:00"
    }
  ],
  "error": ""
}

Analytics

  • Passive: the target is not contacted
  • Plan: No key needed

Returns the world share per reporter and period.

Path parameters

typeCodestringrequired

C for commodities, S for services

Example: COne of: C, S
freqCodestringrequired

A for annual, M for monthly

Example: AOne of: A, M

Query parameters

periodstring

Period(s): YYYY or YYYYMM, comma-separated, or recent

Example: 2023
reporterCodestring

Reporter code(s), comma-separated

Example: 36
Response fields · 11Show

elapsedTimestring

Time the server took

countinteger

Number of records returned

errorstring

Error text, empty on success

periodinteger

Period

datasetDescstring

Dataset description

reporterCodeinteger

Reporter code

reporterISOstring

Reporter ISO code

worldSharenumber

Share of world trade value

isAvailableboolean

Whether data is available

dataCountinteger

Number of data records

updatedstring

Last update time

curl 'https://comtradeapi.un.org/public/v1/getWorldShare/C/A'
No key needed
Response
{
  "elapsedTime": "0.12 secs",
  "count": 1,
  "data": [
    {
      "typeCode": "C",
      "freqCode": "A",
      "period": 2022,
      "year": 2022,
      "datasetDesc": "Example CA 2022",
      "reporterCode": 999,
      "reporterISO": "XXX",
      "reporterDesc": "Exampleland",
      "worldShare": 0.01,
      "isAvailable": true,
      "dataCount": 1,
      "updated": "2025-01-01T00:00:00"
    }
  ],
  "error": ""
}
  • Passive: the target is not contacted
  • Plan: No key needed

Historical series of total trade value (T35) and conversion factors (T38). Output is JSON by default, or CSV or TXT with format.

Query parameters

series_typestring

Table, frequency, measure and currency

Example: T35.A.V.$One of: T35.Q.V.$, T35.A.V.$, T38.Q.CF., T38.A.CF., T35.M.V.$, T38.M.CF.
yearstring

Reference year(s)

Example: 2023
country_codestring

Country code(s), comma-separated

Example: 36
periodstring

Year or month, comma-separated

Example: 2023
period_typestring

Dataset frequency: A annual, Q quarterly, M monthly

Example: AOne of: A, Q, M
table_typestring

MBS table number

Example: T35One of: T35, T38
formatstring

Output format; json by default

One of: csv, txt, json
Response fields · 15Show

elapsedTimestring

Time the server took

countinteger

Number of records returned

errorstring

Error text, empty on success

series_Typestring

Series type

table_Typestring

Table, T35 or T38

country_Codeinteger

Country code

country_English_Namestring

Country name

yearinteger

Year

period_Typestring

A, Q or M

trade_Flowstring

Trade flow code

partner_Country_Codeinteger

Partner code

currency_Typestring

Currency

valuenumber

Value

value_Unitstring

Unit of the value, for example M for millions

estimation_Type_Descstring

Actual or estimated

curl 'https://comtradeapi.un.org/public/v1/getMBS'
No key needed
Response
{
  "elapsedTime": "1.72 secs",
  "count": 1,
  "data": [
    {
      "series_Type": "T35.A.V.$",
      "table_Type": "T35",
      "country_Code": 999,
      "country_English_Name": "Exampleland",
      "year": 2022,
      "period_Type": "A",
      "trade_Flow": "X",
      "partner_Country_Code": 0,
      "partner_Country_English_Name": "World",
      "currency_Type": "$",
      "value": 1000.5,
      "value_Unit": "M",
      "value_Type": "V",
      "estimation_Type": "A",
      "estimation_Type_Desc": "Actual"
    }
  ],
  "error": ""
}