Snapshot

By country

Get Comtrade snapshot of data by country or between countries

/comtrade/country/{country}

te.getCmtCountry(country = 'Portugal')
te.getCmtCountry(country = ['China','Portugal'])
data = te.getComtrade(country = 'Portugal').then(function(data){
    console.log(data)     
});
data = te.getComtrade(country = 'china', country1 = 'portugal').then(function(data){
  console.log(data)     
});
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/country/portugal?c=guest:guest");
new HttpRequestMessage(new HttpMethod("GET"), "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')
data = te.getCmtCountryByCategory(country = 'india', type = 'import').then(function(data){
    console.log(data)      
});
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/import/india?c=guest:guest");

/comtrade/export/{country}

te.getCmtCountryByCategory(country = 'United States', type = 'export')
data = te.getCmtCountryByCategory(country = 'United States',
 type = 'export').then(function(data){
    console.log(data)      
});
new HttpRequestMessage(new HttpMethod("GET"), "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')
data = te.getCmtCountryByCategory(country = 'United kingdom', type = 'import',
 category='Coffee, tea, mate and spices').then(function(data){
    console.log(data)      
});
new HttpRequestMessage(new HttpMethod("GET"), "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')
data = te.getCmtCountryByCategory(country = 'india', type = 'export',
 category='Live animals').then(function(data){
    console.log(data)      
});
new HttpRequestMessage(new HttpMethod("GET"), "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')
data = te.getComtradeTotalByType(country = 'United States', type = 'import').then(function(data){
    console.log(data)     
});
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/import/united%20states/totals?c=guest:guest");

/comtrade/export/{country}/totals

te.getCmtTotalByType(country = 'India', type = 'export')
data = te.getComtradeTotalByType(country = 'India', type = 'export').then(function(data){
    console.log(data)     
});
new HttpRequestMessage(new HttpMethod("GET"), "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')
data = te.getCmtCountryFilterByType(country1 = 'portugal', type = 'export').then(function(data){
  console.log(data)     
});
new HttpRequestMessage(new HttpMethod("GET"), "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')
data = te.getComtrade(country = 'portugal', country1 = 'spain').then(function(data){
    console.log(data)     
});
new HttpRequestMessage(new HttpMethod("GET"), "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')
data = te.getComtrade(country = 'portugal', country1 = 'spain',
 category='import').then(function(data){
  console.log(data)     
});
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/country/portugal/spain?type=import&c=guest:guest");

Updates by country and date

Check comtrade updates by country and date

/comtrade/updates/country/{country}

te.getCmtLastUpdates(country = 'mexico', start_date = '2020-01-01')
data = te.getCmtLastUpdates(country = 'mexico', start_date='2020-01-01').then(function(data){
    console.log(data)     
});
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/updates/country/mexico?from=2020-01-01&c=guest:guest");

Latest updated

Get the latest updated indicators

/comtrade/updates

import tradingeconomics as te
te.login('your_api_key')
te.getCmtUpdates()
const te = require('tradingeconomics');
te.login('your_api_key');
data = te.getComtrade(category = 'updates').then(function(data){
    console.log(data)     
});
new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/updates?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’.

Fields in ‘Updates by country and date’

FieldTypeDescriptionExample
countrystringCountry name“Mexico”
reportYearstringReport year“2020”
lastupdatestringTime when new data was inserted or changed“7/5/2023 8:20:00 AM”