# UN Comtrade Database API reference

> 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…

Source: https://osinttools.io/apis/un-comtrade/ (Markdown view of an OSINTtools.io page; append `.md` to any page URL for this format).

Compiled by OSINTtools.io editors from the vendor's docs, updated Nov 29, 2026. Listing: https://osinttools.io/tools/un-comtrade/

- Base URL: https://comtradeapi.un.org/public/v1
- Authentication: No key needed.
- Free tier: yes
- Pricing: Free
- Rate limits: Preview results are capped at 500 records and a rate limit applies; its value is not stated in the docs
- Vendor docs: https://comtrade.un.org/en/api-docs

## Overview

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.

## Errors

| Status | Meaning |
| --- | --- |
| 400 | Invalid or missing parameters |
| 500 | Unexpected server error |

## Trade data

### Preview final trade data (up to 500 records, one period and one commodity).

`GET /preview/{typeCode}/{freqCode}/{clCode}`

- Footprint: 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.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `typeCode` | path | string | yes | C for commodities, S for services Example: C One of: C, S |
| `freqCode` | path | string | yes | A for annual, M for monthly Example: A One of: A, M |
| `clCode` | path | string | yes | Product classification: HS, SITC, BEC (goods) or EBOPS (services) Example: HS One of: HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS |
| `reporterCode` | query | string | no | Reporter code; several codes separated by commas Example: 36 |
| `period` | query | string | no | Year (YYYY) or month (YYYYMM); a maximum of 1 period for preview Example: 2023 |
| `partnerCode` | query | string | no | Partner code; several codes separated by commas Example: 0 |
| `cmdCode` | query | string | no | Commodity code; a maximum of 1 for preview Example: TOTAL |
| `flowCode` | query | string | no | Trade flow code, case-insensitive; several separated by commas; omit to not filter Example: X One of: M, X, RX, RM, MIP, XIP, MOP, XOP, MIF, XIF, DX, FM |

Response fields:

- `elapsedTime` (string): Time the server took
- `count` (integer): Number of records returned
- `error` (string): Error text, empty on success
- `data[].typeCode` (string): C or S
- `data[].freqCode` (string): A or M
- `data[].period` (string): Period (year or year-month)
- `data[].refYear` (integer): Reference year
- `data[].reporterCode` (integer): Reporter code
- `data[].reporterISO` (string): Reporter ISO code (null in the preview)
- `data[].reporterDesc` (string): Reporter name (null in the preview)
- `data[].flowCode` (string): Trade flow code
- `data[].partnerCode` (integer): Partner code
- `data[].partner2Code` (integer): Second partner code
- `data[].classificationCode` (string): Classification edition
- `data[].cmdCode` (string): Commodity code
- `data[].customsCode` (string): Customs procedure code
- `data[].motCode` (integer): Mode of transport code
- `data[].qtyUnitCode` (integer): Quantity unit code
- `data[].qty` (number): Quantity
- `data[].isQtyEstimated` (boolean): Whether the quantity is estimated
- `data[].altQty` (number): Alternative quantity

```bash
curl 'https://comtradeapi.un.org/public/v1/preview/C/A/HS'
```

Example response (200):

```json
{
  "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}`

- Footprint: 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.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `typeCode` | path | string | yes | C for commodities, S for services Example: C One of: C, S |
| `freqCode` | path | string | yes | A for annual, M for monthly Example: A One of: A, M |
| `clCode` | path | string | yes | Product classification: HS editions (goods) Example: HS One of: HS, H6, H5, H4, H3, H2, H1, H0 |
| `reporterCode` | query | string | no | Reporter code(s) Example: 36 |
| `period` | query | string | no | Year or month, comma-separated Example: 2023 |
| `partnerCode` | query | string | no | Partner code(s) Example: 0 |
| `partner2Code` | query | string | no | Second partner or consignment code(s) |
| `cmdCode` | query | string | no | Commodity code(s) Example: TOTAL |
| `flowCode` | query | string | no | Trade flow code(s) Example: X |
| `customsCode` | query | string | no | Customs code(s), C00 to C20 |
| `motCode` | query | string | no | Mode of transport code(s) |

Response fields:

- `elapsedTime` (string): Time the server took
- `count` (integer): Number of records returned
- `error` (string): Error text, empty on success
- `data[].period` (integer): Period
- `data[].reporterCode` (integer): Reporter code
- `data[].flowCode` (string): Trade flow code
- `data[].partnerCode` (integer): Partner code
- `data[].classificationCode` (string): Classification edition
- `data[].cmdCode` (string): Commodity code
- `data[].motCode` (integer): Mode of transport code
- `data[].qtyUnitCode` (integer): Quantity unit code
- `data[].qty` (number): Quantity
- `data[].netWgt` (number): Net weight
- `data[].grossWgt` (number): Gross weight
- `data[].cifvalue` (number): CIF value
- `data[].fobvalue` (number): FOB value
- `data[].primaryValue` (number): Primary trade value

```bash
curl 'https://comtradeapi.un.org/public/v1/previewTariffline/C/A/HS'
```

Example response (200):

```json
{
  "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`

- Footprint: passive (the target is not contacted)
- Plan: No key needed

Lists the most recent dataset releases by reporter.

Response fields:

- `elapsedTime` (string): Time the server took
- `count` (integer): Number of records returned
- `error` (string): Error text, empty on success
- `data[].reporterCode` (integer): Reporter code
- `data[].flagCode` (string): Country flag code
- `data[].datasetDesc` (string): Dataset description
- `data[].nr` (string): N for new data
- `data[].dateRelease` (string): Release date and time

```bash
curl 'https://comtradeapi.un.org/public/v1/getComtradeReleases'
```

Example response (200):

```json
{
  "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}`

- Footprint: 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.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `typeCode` | path | string | yes | C for commodities, S for services Example: C One of: C, S |
| `freqCode` | path | string | yes | A for annual, M for monthly Example: A One of: A, M |
| `clCode` | path | string | yes | Classification Example: HS One of: HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS |

Response fields:

- `elapsedTime` (string): Time the server took
- `count` (integer): Number of records returned
- `error` (string): Error text, empty on success
- `data[].reporterCode` (integer): Reporter code
- `data[].period` (integer): Period
- `data[].datasetCode` (integer): Dataset code
- `data[].notes[].reporterDescription` (string): Reporter name
- `data[].notes[].currency` (string): Currency
- `data[].notes[].importConvFactor` (string): Import conversion factor
- `data[].notes[].exportConvFactor` (string): Export conversion factor
- `data[].notes[].tradeSystem` (string): Trade system, for example General
- `data[].notes[].importValuation` (string): Import valuation, for example CIF
- `data[].notes[].exportValuation` (string): Export valuation, for example FOB
- `data[].notes[].publicationNote` (string): Publication note
- `data[].notes[].publicationDate` (string): Publication date and time

```bash
curl 'https://comtradeapi.un.org/public/v1/getMetadata/C/A/HS'
```

Example response (200):

```json
{
  "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

### Get which trade datasets are available and when they were released.

`GET /getDA/{typeCode}/{freqCode}/{clCode}`

- Footprint: passive (the target is not contacted)
- Plan: No key needed

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

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `typeCode` | path | string | yes | C for commodities, S for services Example: C One of: C, S |
| `freqCode` | path | string | yes | A for annual, M for monthly Example: A One of: A, M |
| `clCode` | path | string | yes | Classification Example: HS One of: HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS |

Response fields:

- `elapsedTime` (string): Time the server took
- `count` (integer): Number of records returned
- `error` (string): Error text, empty on success
- `data[].datasetCode` (integer): Dataset code
- `data[].period` (integer): Period
- `data[].reporterCode` (integer): Reporter code
- `data[].reporterISO` (string): Reporter ISO code
- `data[].classificationCode` (string): Classification edition
- `data[].totalRecords` (integer): Number of records in the dataset
- `data[].datasetChecksum` (integer): Dataset checksum
- `data[].firstReleased` (string): First release time
- `data[].lastReleased` (string): Last release time

```bash
curl 'https://comtradeapi.un.org/public/v1/getDA/C/A/HS'
```

Example response (200):

```json
{
  "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}`

- Footprint: 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.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `typeCode` | path | string | yes | C for commodities, S for services Example: C One of: C, S |
| `freqCode` | path | string | yes | A for annual, M for monthly Example: A One of: A, M |
| `clCode` | path | string | yes | Classification Example: HS One of: HS, H6, H5, H4, H3, H2, H1, H0, S4, S3, S2, S1, BE, BE5, EB, EB10, EB02, EBS |

Response fields:

- `elapsedTime` (string): Time the server took
- `count` (integer): Number of records returned
- `error` (string): Error text, empty on success
- `data[].datasetCode` (integer): Dataset code
- `data[].period` (integer): Period
- `data[].reporterCode` (integer): Reporter code
- `data[].reporterISO` (string): Reporter ISO code
- `data[].classificationCode` (string): Classification edition
- `data[].totalRecords` (integer): Number of records in the dataset
- `data[].datasetChecksum` (integer): Dataset checksum
- `data[].firstReleased` (string): First release time
- `data[].lastReleased` (string): Last release time
- `data[].lengthCmdCode` (integer): Length of the commodity code

```bash
curl 'https://comtradeapi.un.org/public/v1/getDATariffline/C/A/HS'
```

Example response (200):

```json
{
  "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

### Get each reporter's share of world trade, including estimates.

`GET /getWorldShare/{typeCode}/{freqCode}`

- Footprint: passive (the target is not contacted)
- Plan: No key needed

Returns the world share per reporter and period.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `typeCode` | path | string | yes | C for commodities, S for services Example: C One of: C, S |
| `freqCode` | path | string | yes | A for annual, M for monthly Example: A One of: A, M |
| `period` | query | string | no | Period(s): YYYY or YYYYMM, comma-separated, or recent Example: 2023 |
| `reporterCode` | query | string | no | Reporter code(s), comma-separated Example: 36 |

Response fields:

- `elapsedTime` (string): Time the server took
- `count` (integer): Number of records returned
- `error` (string): Error text, empty on success
- `data[].period` (integer): Period
- `data[].datasetDesc` (string): Dataset description
- `data[].reporterCode` (integer): Reporter code
- `data[].reporterISO` (string): Reporter ISO code
- `data[].worldShare` (number): Share of world trade value
- `data[].isAvailable` (boolean): Whether data is available
- `data[].dataCount` (integer): Number of data records
- `data[].updated` (string): Last update time

```bash
curl 'https://comtradeapi.un.org/public/v1/getWorldShare/C/A'
```

Example response (200):

```json
{
  "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": ""
}
```

### Get Monthly Bulletin of Statistics time series (tables T35 and T38).

`GET /getMBS`

- Footprint: 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.

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `series_type` | query | string | no | 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. |
| `year` | query | string | no | Reference year(s) Example: 2023 |
| `country_code` | query | string | no | Country code(s), comma-separated Example: 36 |
| `period` | query | string | no | Year or month, comma-separated Example: 2023 |
| `period_type` | query | string | no | Dataset frequency: A annual, Q quarterly, M monthly Example: A One of: A, Q, M |
| `table_type` | query | string | no | MBS table number Example: T35 One of: T35, T38 |
| `format` | query | string | no | Output format; json by default One of: csv, txt, json |

Response fields:

- `elapsedTime` (string): Time the server took
- `count` (integer): Number of records returned
- `error` (string): Error text, empty on success
- `data[].series_Type` (string): Series type
- `data[].table_Type` (string): Table, T35 or T38
- `data[].country_Code` (integer): Country code
- `data[].country_English_Name` (string): Country name
- `data[].year` (integer): Year
- `data[].period_Type` (string): A, Q or M
- `data[].trade_Flow` (string): Trade flow code
- `data[].partner_Country_Code` (integer): Partner code
- `data[].currency_Type` (string): Currency
- `data[].value` (number): Value
- `data[].value_Unit` (string): Unit of the value, for example M for millions
- `data[].estimation_Type_Desc` (string): Actual or estimated

```bash
curl 'https://comtradeapi.un.org/public/v1/getMBS'
```

Example response (200):

```json
{
  "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": ""
}
```

---

Listings on OSINTtools.io are reviewed by editors and re-verified on a schedule; check pricing and availability on the vendor's site before relying on them, and use OSINT tools only with a lawful basis.
Site index for agents: https://osinttools.io/llms.txt · Full catalog: https://osinttools.io/llms-full.txt · MCP server (Streamable HTTP, no auth): https://osinttools.io/mcp/
