Snapshot

UN Comtrade Database consists of around 19 million data series with detailed harmonized global trade data divided into categories and countries.

Latest updated

Get the latest updated indicators

/comtrade/updates

te.getCmtUpdates(output_type = 'df')
data = te.getComtrade(category = 'updates').then(function(data){
    console.log(data)     
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/updates?c=guest:guest");

By country

Get Comtrade snapshot of data by country or between countries

/comtrade/country/{country}

te.getCmtCountry(country = 'Portugal', output_type = 'df')
te.getCmtCountry(country = ['China','Portugal'], output_type = 'df')
data = te.getComtrade(country = 'Portugal').then(function(data){
    console.log(data)     
});
data = te.getComtrade(country = 'china', country1 = 'portugal').then(function(data){
  console.log(data)     
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/country/portugal?c=guest:guest");
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/country/china/portugal?c=guest:guest");

Import or Export by country

Get total type (import or export) by country for all main categories

/comtrade/import/{country}

te.getCmtCountryByCategory(country = 'India', type = 'import', output_type = 'df')
data = te.getCmtCountryByCategory(country = 'india', type = 'import').then(function(data){
    console.log(data)      
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/import/india?c=guest:guest");

/comtrade/export/{country}

te.getCmtCountryByCategory(country = 'United States', type = 'export',
 output_type = 'df')
data = te.getCmtCountryByCategory(country = 'United States',
 type = 'export').then(function(data){
    console.log(data)      
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/export/united%20states?c=guest:guest");

Import or Export by country and category

Get type (import or export) by country and specific category

/comtrade/import/{country}/{category}

te.getCmtCountryByCategory(country = 'United Kingdom', type = 'import',
 category='Coffee, tea, mate and spices', output_type = 'df')
data = te.getCmtCountryByCategory(country = 'United kingdom', type = 'import',
 category='Coffee, tea, mate and spices').then(function(data){
    console.log(data)      
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/import/united%20kingdom/Coffee,%20tea,%20mate%20and%20spices?c=guest:guest");

/comtrade/export/{country}/{category}

te.getCmtCountryByCategory(country = 'India', type = 'export',
 category='Live animals', output_type = 'df')
data = te.getCmtCountryByCategory(country = 'india', type = 'export',
 category='Live animals').then(function(data){
    console.log(data)      
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/export/india/live%20animals?c=guest:guest");

Total imports and exports by country

Get total type (export or export) by a specific country

/comtrade/import/{country}/totals

te.getCmtTotalByType(country = 'United States', type = 'import', output_type = 'df')
data = te.getComtradeTotalByType(country = 'United States', type = 'import').then(function(data){
    console.log(data)     
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/import/united%20states/totals?c=guest:guest");

/comtrade/export/{country}/totals

te.getCmtTotalByType(country = 'India', type = 'export', output_type = 'df')
data = te.getComtradeTotalByType(country = 'India', type = 'export').then(function(data){
    console.log(data)     
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/export/india/totals?c=guest:guest");

List Category

To also list the category column in the response fields

/comtrade/country/{country}?type={type}

te.getCmtSnapshotByType(country = 'portugal', type = 'export', output_type = 'df')
data = te.getCmtCountryFilterByType(country1 = 'portugal', type = 'export').then(function(data){
  console.log(data)     
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/country/portugal?type=export&c=guest:guest");

Trade

Get snapshot of trade between two countries

/comtrade/country/{country_1}/{country_2}

te.getCmtTwoCountries(country1 ='portugal', country2 ='spain', output_type = 'df')
data = te.getComtrade(country = 'portugal', country1 = 'spain').then(function(data){
    console.log(data)     
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/country/portugal/spain?c=guest:guest");

By type

Get snapshot of trade between two countries filtered by type (import or export)

/comtrade/country/{country_1}/{country_2}?type={type}

te.getCmtCountryFilterByType(country1 ='portugal', country2 ='spain',
 type='import', output_type='df')
data = te.getComtrade(country = 'portugal', country1 = 'spain',
 category='import').then(function(data){
  console.log(data)     
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/country/portugal/spain?type=import&c=guest:guest");

Response fields

FieldTypeDescriptionExample
SymbolstringUnique symbol used by Trading Economics“MWIBEL85173”
Country1stringFirst country name“Malawi”
Country2*stringSecond country name“Belgium”
ValuenumberTrade Value17219
DatenumberYear of the updated series2022
TypestringTrade type“Re-Export”
CategorystringCategory name“Pepper, genus piper, genus capsicum or pimenta”
URLstringHyperlink at Trading Economics“/portugal/exports/aruba”
TitlestringTrade title“Portugal exports to Aruba”
StartDatenumberStart Year of the data series“2023-04-05T00:03:00”
lastupdatestringTime when new data was inserted or changed“2023-04-05T00:03:00”

Notes

*Country2 is not used for ‘Import or Export by country’.