Comtrade Categories and Countries

The United Nations Comtrade database is recognized as the world’s most comprehensive global trade data platform, providing detailed trade statistics by product and trading partner. It serves governments, academia, and enterprises globally, covering around 200 countries and representing over 99% of the world’s merchandise trade. This extensive database offers valuable insights for various sectors and industries.

List categories

Using Requests:

import requests
your_api_key = 'your_api_key'
url = f'https://api.tradingeconomics.com/comtrade/categories?c={your_api_key}'
data = requests.get(url).json()
print(data)

Or using our package:

import tradingeconomics as te
te.login('your_api_key')
te.getCmtCategories()

Using Requests:

const axios = require('axios');
(async () => {
    const your_api_key = 'your_api_key'
    const response = await axios.get(`https://api.tradingeconomics.com/comtrade/categories?c=${your_api_key}`)
    console.log(response.data)
})()

Or using our package:

const te = require('tradingeconomics');
te.login('your_api_key');
data = te.getComtrade(category = 'categories').then(function(data){
  console.log(data)       
});

Using Requests:

using (var httpClient = new HttpClient())
{
    using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/categories?c=your_api_key"))
    {
        request.Headers.TryAddWithoutValidation("Upgrade-Insecure-Requests", "1");
        var response = await httpClient.SendAsync(request);
        if (response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync(); 
            Console.WriteLine(content);
        }
    }
}

The response data format can be configured by appending the &f= parameter to the URL request.

https://api.tradingeconomics.com/comtrade/categories?c={your_api_key}&f=json
[
  {
    "id": "01",
    "name": "Live animals",
    "parentId": "a1",
    "pretty_name": "Live animals"
  },
  {
    "id": "0101",
    "name": "Horses, asses, mules and hinnies, live",
    "parentId": "01",
    "pretty_name": "Horses, asses, mules and hinnies, live"
  },
  {
    "id": "0102",
    "name": "Bovine animals, live",
    "parentId": "01",
    "pretty_name": "Bovine animals, live"
  }
]
https://api.tradingeconomics.com/comtrade/categories?c={your_api_key}&f=csv
id,name,parentId,pretty_name
01,Live animals,a1,Live animals
0101,"Horses, asses, mules and hinnies, live",01,"Horses, asses, mules and hinnies, live"
0102,"Bovine animals, live",01,"Bovine animals, live"
https://api.tradingeconomics.com/comtrade/categories?c={your_api_key}&f=xml
<ArrayOfMarkets.ComtradeCategories xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/APILib.DB">
<Markets.ComtradeCategories>
<id>01</id>
<name>Live animals</name>
<parentId>a1</parentId>
<pretty_name>Live animals</pretty_name>
</Markets.ComtradeCategories>
<Markets.ComtradeCategories>
<id>0101</id>
<name>Horses, asses, mules and hinnies, live</name>
<parentId>01</parentId>
<pretty_name>Horses, asses, mules and hinnies, live</pretty_name>
</Markets.ComtradeCategories>
<Markets.ComtradeCategories>
<id>0102</id>
<name>Bovine animals, live</name>
<parentId>01</parentId>
<pretty_name>Bovine animals, live</pretty_name>
</Markets.ComtradeCategories>
</ArrayOfMarkets.ComtradeCategories>
https://api.tradingeconomics.com/comtrade/categories?c={your_api_key}
idnameparentIdpretty_name
01Live animalsa1Live animals
0101“Horses, asses, mules and hinnies, live”01“Horses, asses, mules and hinnies, live”
0102“Bovine animals, live”01“Bovine animals, live”

List countries

Using Requests:

import requests
your_api_key = 'your_api_key'
url = f'https://api.tradingeconomics.com/comtrade/countries?c={your_api_key}'
data = requests.get(url).json()
print(data)

Or using our package:

te.getCmtCountry()

Using Requests:

const axios = require('axios');
(async () => {
    const your_api_key = 'your_api_key'
    const response = await axios.get(`https://api.tradingeconomics.com/comtrade/countries?c=${your_api_key}`)
    console.log(response.data)
})()

Or using our package:

data = te.getComtrade(category = 'countries').then(function(data){
  console.log(data)       
});

Using Requests:

using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/countries?c=your_api_key"))
https://api.tradingeconomics.com/comtrade/countries?c={your_api_key}&f=json
[
  {
    "id": "100",
    "name": "Bulgaria",
    "region": "Europe",
    "subregion": "Eastern Europe",
    "iso": "BGR",
    "year": "2023"
  },
  {
    "id": "104",
    "name": "Myanmar",
    "region": "Asia",
    "subregion": "South-Eastern Asia",
    "iso": "MMR",
    "year": "2023"
  },
  {
    "id": "108",
    "name": "Burundi",
    "region": "Africa",
    "subregion": "Western Africa",
    "iso": "BDI",
    "year": "2022"
  }
]
https://api.tradingeconomics.com/comtrade/countries?c={your_api_key}&f=csv
id,name,region,subregion,iso,year
100,Bulgaria,Europe,Eastern Europe,BGR,2023
104,Myanmar,Asia,South-Eastern Asia,MMR,2023
108,Burundi,Africa,Western Africa,BDI,2022
https://api.tradingeconomics.com/comtrade/countries?c={your_api_key}&f=xml
<ArrayOfMarkets.ComtradeCountries xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/APILib.DB">
<Markets.ComtradeCountries>
<id>100</id>
<iso>BGR</iso>
<name>Bulgaria</name>
<region>Europe</region>
<subregion>Eastern Europe</subregion>
<year>2023</year>
</Markets.ComtradeCountries>
<Markets.ComtradeCountries>
<id>104</id>
<iso>MMR</iso>
<name>Myanmar</name>
<region>Asia</region>
<subregion>South-Eastern Asia</subregion>
<year>2023</year>
</Markets.ComtradeCountries>
<Markets.ComtradeCountries>
<id>108</id>
<iso>BDI</iso>
<name>Burundi</name>
<region>Africa</region>
<subregion>Western Africa</subregion>
<year>2022</year>
</Markets.ComtradeCountries>
<ArrayOfMarkets.ComtradeCountries xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/APILib.DB">
https://api.tradingeconomics.com/comtrade/countries?c={your_api_key}
idnameregionsubregionisoyear
100BulgariaEuropeEastern EuropeBGR2023
104MyanmarAsiaSouth-Eastern AsiaMMR2023
108BurundiAfricaWestern AfricaBDI2022

Response fields

Fields in ‘List categories’

FieldTypeDescriptionExample
IdstringUnique Comtrade identifier for the category“01”
NamestringOfficial category name“Live animals”
ParentIdstringIdentifier of the parent category (if applicable)“a1”
Pretty_NamestringHuman-readable or display-friendly category name“Agricultural for Soil Preparation”

Fields in ‘List countries’

FieldTypeDescriptionExample
IdstringUnique Comtrade identifier“01”
NamestringCountry name“Mexico”
RegionstringRegion where the country is located“Europe”
SubregionstringSubregion where the country is located“Eastern Europe”
ISOstringThree-letter ISO country code“BGR”
YearstringMost recent year of data update“2021”