Snapshot
UN Comtrade Database consists of around 19 million data series with detailed harmonized global trade data divided into categories and countries.
By country
Get Comtrade snapshot of data by country or between countries
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)
});
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
te.getCmtCountryByCategory(country = 'India', type = 'import')
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");
te.getCmtCountryByCategory(country = 'United States', type = 'export')
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')
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')
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')
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')
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')
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')
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')
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");
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)
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/updates/country/mexico?from=2020-01-01&c=guest:guest");
Latest updated
Get the latest updated indicators
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)
});
WebRequest request = WebRequest.Create("https://api.tradingeconomics.com/comtrade/updates?c=guest:guest");
Response fields
Field | Type | Description | Example |
---|---|---|---|
Symbol | string | Unique symbol used by Trading Economics | “MWIBEL85173” |
Country1 | string | First country name | “Malawi” |
Country2* | string | Second country name | “Belgium” |
Value | number | Trade Value | 17219 |
Date | number | Year of the updated series | 2022 |
Type | string | Trade type | “Re-Export” |
Category | string | Category name | “Pepper, genus piper, genus capsicum or pimenta” |
URL | string | Hyperlink at Trading Economics | “/portugal/exports/aruba” |
Title | string | Trade title | “Portugal exports to Aruba” |
StartDate | number | Start Year of the data series | “2023-04-05T00:03:00” |
lastupdate | string | Time 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’
Field | Type | Description | Example |
---|---|---|---|
country | string | Country name | “Mexico” |
reportYear | string | Report year | “2020” |
lastupdate | string | Time when new data was inserted or changed | “7/5/2023 8:20:00 AM” |