Snapshot
The Snapshot endpoint offers a momentary view of data, capturing specific information at a particular point in time. It generally includes details such as date, units, and general information, providing a static representation of current data.
By country
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/comtrade/country/china/portugal?c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
import tradingeconomics as te
te.login('your_api_key')
te.getCmtCountry(country = 'Portugal')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/comtrade/country/china/portugal?c=${api_key}`)
console.log(response.data)
})()
Or using our package:
const te = require('tradingeconomics');
te.login('your_api_key');
data = te.getComtrade(country = 'Portugal').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/country/portugal?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.
symbol | country1 | country2 | value | date | type | category | url | title | StartDate | lastupdate | |
---|---|---|---|---|---|---|---|---|---|---|---|
CHNPRT00002 | China | Portugal | 5978101967 | 2022 | Export | /china/exports/portugal | China exports to Portugal | 1992 | 5/4/2023 5:23:00 PM | ||
CHNPRT00001 | China | Portugal | 3036088177 | 2022 | Import | /china/imports/portugal | China imports from Portugal | 1992 | 5/4/2023 5:23:00 PM | ||
CHNPRTXX852 | China | Portugal | 2010403509 | 2022 | Export | “Electrical, electronic equipment” | /china/exports/portugal/electrical-electronic-equipment | “China exports of electrical, electronic equipment to Portugal” | 1992 | 5/4/2023 4:51:00 PM |
/comtrade/country/{country}?f=json
[{"symbol":"CHNPRT00002","country1":"China","country2":"Portugal","value":5978101967,"date":2022,"type":"Export","category":null,"url":"/china/exports/portugal","title":"China exports to Portugal","StartDate":1992,"lastupdate":"2023-05-04T17:23:00"},{"symbol":"CHNPRT00001","country1":"China","country2":"Portugal","value":3036088177,"date":2022,"type":"Import","category":null,"url":"/china/imports/portugal","title":"China imports from Portugal","StartDate":1992,"lastupdate":"2023-05-04T17:23:00"},{"symbol":"CHNPRTXX852","country1":"China","country2":"Portugal","value":2010403509,"date":2022,"type":"Export","category":"Electrical, electronic equipment","url":"/china/exports/portugal/electrical-electronic-equipment","title":"China exports of electrical, electronic equipment to Portugal","StartDate":1992,"lastupdate":"2023-05-04T16:51:00"}]
/comtrade/country/{country}?f=csv
CHNPRT00002,China,Portugal,5978101967,2022,Export,,/china/exports/portugal,China exports to Portugal,1992,5/4/2023 5:23:00 PM
CHNPRT00001,China,Portugal,3036088177,2022,Import,,/china/imports/portugal,China imports from Portugal,1992,5/4/2023 5:23:00 PM
CHNPRTXX852,China,Portugal,2010403509,2022,Export,"Electrical, electronic equipment",/china/exports/portugal/electrical-electronic-equipment,"China exports of electrical, electronic equipment to Portugal",1992,5/4/2023 4:51:00 PM
/comtrade/country/{country}?f=xml
<ArrayOfanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeSnapshot">
<d2p1:StartDate>1992</d2p1:StartDate>
<d2p1:category i:nil="true"/>
<d2p1:country1>China</d2p1:country1>
<d2p1:country2>Portugal</d2p1:country2>
<d2p1:date>2022</d2p1:date>
<d2p1:lastupdate>2023-05-04T17:23:00</d2p1:lastupdate>
<d2p1:symbol>CHNPRT00002</d2p1:symbol>
<d2p1:title>China exports to Portugal</d2p1:title>
<d2p1:type>Export</d2p1:type>
<d2p1:url>/china/exports/portugal</d2p1:url>
<d2p1:value>5978101967</d2p1:value>
</anyType>
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeSnapshot">
<d2p1:StartDate>1992</d2p1:StartDate>
<d2p1:category i:nil="true"/>
<d2p1:country1>China</d2p1:country1>
<d2p1:country2>Portugal</d2p1:country2>
<d2p1:date>2022</d2p1:date>
<d2p1:lastupdate>2023-05-04T17:23:00</d2p1:lastupdate>
<d2p1:symbol>CHNPRT00001</d2p1:symbol>
<d2p1:title>China imports from Portugal</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/china/imports/portugal</d2p1:url>
<d2p1:value>3036088177</d2p1:value>
</anyType>
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeSnapshot">
<d2p1:StartDate>1992</d2p1:StartDate>
<d2p1:category>Electrical, electronic equipment</d2p1:category>
<d2p1:country1>China</d2p1:country1>
<d2p1:country2>Portugal</d2p1:country2>
<d2p1:date>2022</d2p1:date>
<d2p1:lastupdate>2023-05-04T16:51:00</d2p1:lastupdate>
<d2p1:symbol>CHNPRTXX852</d2p1:symbol>
<d2p1:title>China exports of electrical, electronic equipment to Portugal</d2p1:title>
<d2p1:type>Export</d2p1:type>
<d2p1:url>/china/exports/portugal/electrical-electronic-equipment</d2p1:url>
<d2p1:value>2010403509</d2p1:value>
</anyType>
</ArrayOfanyType>
Import or Export by country
Get total type (import or export) by country for all main categories
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/comtrade/import/india?c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
Import
te.getCmtCountryByCategory(country = 'India', type = 'import')
Export
te.getCmtCountryByCategory(country = 'India', type = 'export')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/comtrade/import/india?c=${api_key}`)
console.log(response.data)
})()
Or using our package:
Import
data = te.getCmtCountryByCategory(country = 'india',
type = 'import').then(function(data){
console.log(data)
});
Export
data = te.getCmtCountryByCategory(country = 'India',
type = 'export').then(function(data){
console.log(data)
});
Using Requests:
Import
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/import/india?c=your_api_key"))
Export
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/export/india?c=your_api_key"))
symbol | country | value | date | type | category | url | title | StartDate | lastupdate | |
---|---|---|---|---|---|---|---|---|---|---|
INDWLDXX271 | India | 277238257324 | 2022 | Import | “Mineral fuels, oils, distillation products” | /india/imports/mineral-fuels-oils-distillation-products | “India Imports of Mineral fuels, oils, distillation products” | 1988 | 5/11/2023 9:16:00 AM | |
INDWLDXX711 | India | 78172888292 | 2022 | Import | “Pearls, precious stones, metals, coins” | /india/imports/pearls-precious-stones-metals-coins | “India Imports of Pearls, precious stones, metals, coins” | 1988 | 5/11/2023 9:16:00 AM | |
INDWLDXX851 | India | 69680021840 | 2022 | Import | “Electrical, electronic equipment” | /india/imports/electrical-electronic-equipment | “India Imports of Electrical, electronic equipment” | 1988 | 5/11/2023 9:16:00 AM |
/comtrade/{type}/{country}?f=json
[{"symbol":"INDWLDXX271","country":"India","value":277238257324,"date":2022,"type":"Import","category":"Mineral fuels, oils, distillation products","url":"/india/imports/mineral-fuels-oils-distillation-products","title":"India Imports of Mineral fuels, oils, distillation products","StartDate":1988,"lastupdate":"2023-05-11T09:16:00"},{"symbol":"INDWLDXX711","country":"India","value":78172888292,"date":2022,"type":"Import","category":"Pearls, precious stones, metals, coins","url":"/india/imports/pearls-precious-stones-metals-coins","title":"India Imports of Pearls, precious stones, metals, coins","StartDate":1988,"lastupdate":"2023-05-11T09:16:00"},{"symbol":"INDWLDXX851","country":"India","value":69680021840,"date":2022,"type":"Import","category":"Electrical, electronic equipment","url":"/india/imports/electrical-electronic-equipment","title":"India Imports of Electrical, electronic equipment","StartDate":1988,"lastupdate":"2023-05-11T09:16:00"}]
/comtrade/{type}/{country}?f=csv
INDWLDXX271,India,277238257324,2022,Import,"Mineral fuels, oils, distillation products",/india/imports/mineral-fuels-oils-distillation-products,"India Imports of Mineral fuels, oils, distillation products",1988,5/11/2023 9:16:00 AM
INDWLDXX711,India,78172888292,2022,Import,"Pearls, precious stones, metals, coins",/india/imports/pearls-precious-stones-metals-coins,"India Imports of Pearls, precious stones, metals, coins",1988,5/11/2023 9:16:00 AM
INDWLDXX851,India,69680021840,2022,Import,"Electrical, electronic equipment",/india/imports/electrical-electronic-equipment,"India Imports of Electrical, electronic equipment",1988,5/11/2023 9:16:00 AM
/comtrade/{type}/{country}?f=xml
<ArrayOfanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeImportsExports">
<d2p1:StartDate>1988</d2p1:StartDate>
<d2p1:category>Mineral fuels, oils, distillation products</d2p1:category>
<d2p1:country>India</d2p1:country>
<d2p1:date>2022</d2p1:date>
<d2p1:lastupdate>2023-05-11T09:16:00</d2p1:lastupdate>
<d2p1:symbol>INDWLDXX271</d2p1:symbol>
<d2p1:title>India Imports of Mineral fuels, oils, distillation products</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/india/imports/mineral-fuels-oils-distillation-products</d2p1:url>
<d2p1:value>277238257324</d2p1:value>
</anyType>
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeImportsExports">
<d2p1:StartDate>1988</d2p1:StartDate>
<d2p1:category>Pearls, precious stones, metals, coins</d2p1:category>
<d2p1:country>India</d2p1:country>
<d2p1:date>2022</d2p1:date>
<d2p1:lastupdate>2023-05-11T09:16:00</d2p1:lastupdate>
<d2p1:symbol>INDWLDXX711</d2p1:symbol>
<d2p1:title>India Imports of Pearls, precious stones, metals, coins</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/india/imports/pearls-precious-stones-metals-coins</d2p1:url>
<d2p1:value>78172888292</d2p1:value>
</anyType>
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeImportsExports">
<d2p1:StartDate>1988</d2p1:StartDate>
<d2p1:category>Electrical, electronic equipment</d2p1:category>
<d2p1:country>India</d2p1:country>
<d2p1:date>2022</d2p1:date>
<d2p1:lastupdate>2023-05-11T09:16:00</d2p1:lastupdate>
<d2p1:symbol>INDWLDXX851</d2p1:symbol>
<d2p1:title>India Imports of Electrical, electronic equipment</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/india/imports/electrical-electronic-equipment</d2p1:url>
<d2p1:value>69680021840</d2p1:value>
</anyType>
</ArrayOfanyType>
Import or Export by country and category
Get type (import or export) by country and specific category
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/comtrade/import/united%20kingdom/Coffee,%20tea,%20mate%20and%20spices?c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
Import
te.getCmtCountryByCategory(country = 'United Kingdom', type = 'import',
category='Coffee, tea, mate and spices')
Export
te.getCmtCountryByCategory(country = 'United Kingdom', type = 'export',
category='Coffee, tea, mate and spices')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/comtrade/import/united%20kingdom/Coffee,%20tea,%20mate%20and%20spices?c=${api_key}`)
console.log(response.data)
})()
Or using our package:
Import
data = te.getCmtCountryByCategory(country = 'india', type = 'import',
category='Coffee, tea, mate and spices').then(function(data){
console.log(data)
});
Export
data = te.getCmtCountryByCategory(country = 'india', type = 'export',
category='Coffee, tea, mate and spices').then(function(data){
console.log(data)
});
Using Requests:
Import
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/import/united%20kingdom/Coffee,%20tea,%20mate%20and%20spices?c=your_api_key"))
Export
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/export/united%20kingdom/Coffee,%20tea,%20mate%20and%20spices?c=your_api_key"))
/comtrade/{type}/{country}/{category}
symbol | country1 | country2 | value | date | type | category | url | title | StartDate | lastupdate | |
---|---|---|---|---|---|---|---|---|---|---|---|
GBRWLDXX091 | United Kingdom | World | 2027958871 | 2023 | Import | “Coffee, tea, mate and spices” | /united-kingdom/imports/coffee-tea-mate-spices | “United Kingdom Imports of Coffee, tea, mate and spices” | 1993 | 3/8/2024 9:30:00 AM | |
GBRBRAXX091 | United Kingdom | Brazil | 261221802 | 2023 | Import | “Coffee, tea, mate and spices” | /united-kingdom/imports/brazil/coffee-tea-mate-spices | “United Kingdom Imports from Brazil of Coffee, tea, mate and spices” | 1993 | 3/8/2024 9:35:00 AM | |
GBRCHEXX091 | United Kingdom | Switzerland | 228464421 | 2023 | Import | “Coffee, tea, mate and spices” | /united-kingdom/imports/switzerland/coffee-tea-mate-spices | “United Kingdom Imports from Switzerland of Coffee, tea, mate and spices” | 1993 | 3/8/2024 10:01:00 AM |
/comtrade/{type}/{country}/{category}?f=json
[{"symbol":"GBRWLDXX091","country1":"United Kingdom","country2":"World","value":2027958871,"date":2023,"type":"Import","category":"Coffee, tea, mate and spices","url":"/united-kingdom/imports/coffee-tea-mate-spices","title":"United Kingdom Imports of Coffee, tea, mate and spices","StartDate":1993,"lastupdate":"2024-03-08T09:30:00"},{"symbol":"GBRBRAXX091","country1":"United Kingdom","country2":"Brazil","value":261221802,"date":2023,"type":"Import","category":"Coffee, tea, mate and spices","url":"/united-kingdom/imports/brazil/coffee-tea-mate-spices","title":"United Kingdom Imports from Brazil of Coffee, tea, mate and spices","StartDate":1993,"lastupdate":"2024-03-08T09:35:00"},{"symbol":"GBRCHEXX091","country1":"United Kingdom","country2":"Switzerland","value":228464421,"date":2023,"type":"Import","category":"Coffee, tea, mate and spices","url":"/united-kingdom/imports/switzerland/coffee-tea-mate-spices","title":"United Kingdom Imports from Switzerland of Coffee, tea, mate and spices","StartDate":1993,"lastupdate":"2024-03-08T10:01:00"}]
/comtrade/{type}/{country}/{category}?f=csv
GBRWLDXX091,United Kingdom,World,2027958871,2023,Import,"Coffee, tea, mate and spices",/united-kingdom/imports/coffee-tea-mate-spices,"United Kingdom Imports of Coffee, tea, mate and spices",1993,3/8/2024 9:30:00 AM
GBRBRAXX091,United Kingdom,Brazil,261221802,2023,Import,"Coffee, tea, mate and spices",/united-kingdom/imports/brazil/coffee-tea-mate-spices,"United Kingdom Imports from Brazil of Coffee, tea, mate and spices",1993,3/8/2024 9:35:00 AM
GBRCHEXX091,United Kingdom,Switzerland,228464421,2023,Import,"Coffee, tea, mate and spices",/united-kingdom/imports/switzerland/coffee-tea-mate-spices,"United Kingdom Imports from Switzerland of Coffee, tea, mate and spices",1993,3/8/2024 10:01:00 AM
/comtrade/{type}/{country}/{category}?f=xml
<ArrayOfanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeImportsExportsCountryCat">
<d2p1:StartDate>1993</d2p1:StartDate>
<d2p1:category>Coffee, tea, mate and spices</d2p1:category>
<d2p1:country1>United Kingdom</d2p1:country1>
<d2p1:country2>World</d2p1:country2>
<d2p1:date>2023</d2p1:date>
<d2p1:lastupdate>2024-03-08T09:30:00</d2p1:lastupdate>
<d2p1:symbol>GBRWLDXX091</d2p1:symbol>
<d2p1:title>United Kingdom Imports of Coffee, tea, mate and spices</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/united-kingdom/imports/coffee-tea-mate-spices</d2p1:url>
<d2p1:value>2027958871</d2p1:value>
</anyType>
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeImportsExportsCountryCat">
<d2p1:StartDate>1993</d2p1:StartDate>
<d2p1:category>Coffee, tea, mate and spices</d2p1:category>
<d2p1:country1>United Kingdom</d2p1:country1>
<d2p1:country2>Brazil</d2p1:country2>
<d2p1:date>2023</d2p1:date>
<d2p1:lastupdate>2024-03-08T09:35:00</d2p1:lastupdate>
<d2p1:symbol>GBRBRAXX091</d2p1:symbol>
<d2p1:title>United Kingdom Imports from Brazil of Coffee, tea, mate and spices</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/united-kingdom/imports/brazil/coffee-tea-mate-spices</d2p1:url>
<d2p1:value>261221802</d2p1:value>
</anyType>
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeImportsExportsCountryCat">
<d2p1:StartDate>1993</d2p1:StartDate>
<d2p1:category>Coffee, tea, mate and spices</d2p1:category>
<d2p1:country1>United Kingdom</d2p1:country1>
<d2p1:country2>Switzerland</d2p1:country2>
<d2p1:date>2023</d2p1:date>
<d2p1:lastupdate>2024-03-08T10:01:00</d2p1:lastupdate>
<d2p1:symbol>GBRCHEXX091</d2p1:symbol>
<d2p1:title>United Kingdom Imports from Switzerland of Coffee, tea, mate and spices</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/united-kingdom/imports/switzerland/coffee-tea-mate-spices</d2p1:url>
<d2p1:value>228464421</d2p1:value>
</anyType>
</ArrayOfanyType>
Total imports and exports by country
Get total type (export or export) by a specific country
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/comtrade/import/india/totals?c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
Import
te.getCmtTotalByType(country = 'India', type = 'import')
Export
te.getCmtTotalByType(country = 'India', type = 'export')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/comtrade/import/india/totals?c=${api_key}`)
console.log(response.data)
})()
Or using our package:
Import
data = te.getComtradeTotalByType(country = 'India', type = 'import').then(function(data){
console.log(data)
});
Export
data = te.getComtradeTotalByType(country = 'India', type = 'export').then(function(data){
console.log(data)
});
Using Requests:
Import
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/import/india/totals?c=your_api_key"))
Export
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/export/india/totals?c=your_api_key"))
/comtrade/{type}/{country}/totals
symbol | country1 | country2 | value | date | type | category | url | title | StartDate | lastupdate | |
---|---|---|---|---|---|---|---|---|---|---|---|
INDWLD00001 | India | World | 732565993392 | 2022 | Import | /india/imports | India imports | 1988 | 5/11/2023 10:25:00 AM | ||
INDCHN00001 | India | China | 102249179657 | 2022 | Import | /india/imports/china | India imports from China | 1988 | 5/11/2023 10:30:00 AM | ||
INDARE00001 | India | United Arab Emirates | 53851376669 | 2022 | Import | /india/imports/united-arab-emirates | India imports from United Arab Emirates | 1988 | 5/11/2023 10:56:00 AM |
/comtrade/{type}/{country}/totals?f=json
[{"symbol":"INDWLD00001","country1":"India","country2":"World","value":732565993392,"date":2022,"type":"Import","category":null,"url":"/india/imports","title":"India imports","StartDate":1988,"lastupdate":"2023-05-11T10:25:00"},{"symbol":"INDCHN00001","country1":"India","country2":"China","value":102249179657,"date":2022,"type":"Import","category":null,"url":"/india/imports/china","title":"India imports from China","StartDate":1988,"lastupdate":"2023-05-11T10:30:00"},{"symbol":"INDARE00001","country1":"India","country2":"United Arab Emirates","value":53851376669,"date":2022,"type":"Import","category":null,"url":"/india/imports/united-arab-emirates","title":"India imports from United Arab Emirates","StartDate":1988,"lastupdate":"2023-05-11T10:56:00"}]
/comtrade/{type}/{country}/totals?f=csv
INDWLD00001,India,World,732565993392,2022,Import,,/india/imports,India imports,1988,5/11/2023 10:25:00 AM
INDCHN00001,India,China,102249179657,2022,Import,,/india/imports/china,India imports from China,1988,5/11/2023 10:30:00 AM
INDARE00001,India,United Arab Emirates,53851376669,2022,Import,,/india/imports/united-arab-emirates,India imports from United Arab Emirates,1988,5/11/2023 10:56:00 AM
/comtrade/{type}/{country}/totals?f=xml
<ArrayOfanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeImportsExportsCountryCat">
<d2p1:StartDate>1988</d2p1:StartDate>
<d2p1:category i:nil="true"/>
<d2p1:country1>India</d2p1:country1>
<d2p1:country2>World</d2p1:country2>
<d2p1:date>2022</d2p1:date>
<d2p1:lastupdate>2023-05-11T10:25:00</d2p1:lastupdate>
<d2p1:symbol>INDWLD00001</d2p1:symbol>
<d2p1:title>India imports</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/india/imports</d2p1:url>
<d2p1:value>732565993392</d2p1:value>
</anyType>
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeImportsExportsCountryCat">
<d2p1:StartDate>1988</d2p1:StartDate>
<d2p1:category i:nil="true"/>
<d2p1:country1>India</d2p1:country1>
<d2p1:country2>China</d2p1:country2>
<d2p1:date>2022</d2p1:date>
<d2p1:lastupdate>2023-05-11T10:30:00</d2p1:lastupdate>
<d2p1:symbol>INDCHN00001</d2p1:symbol>
<d2p1:title>India imports from China</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/india/imports/china</d2p1:url>
<d2p1:value>102249179657</d2p1:value>
</anyType>
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeImportsExportsCountryCat">
<d2p1:StartDate>1988</d2p1:StartDate>
<d2p1:category i:nil="true"/>
<d2p1:country1>India</d2p1:country1>
<d2p1:country2>United Arab Emirates</d2p1:country2>
<d2p1:date>2022</d2p1:date>
<d2p1:lastupdate>2023-05-11T10:56:00</d2p1:lastupdate>
<d2p1:symbol>INDARE00001</d2p1:symbol>
<d2p1:title>India imports from United Arab Emirates</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/india/imports/united-arab-emirates</d2p1:url>
<d2p1:value>53851376669</d2p1:value>
</anyType>
</ArrayOfanyType>
Trade between countries
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/comtrade/country/portugal/spain?c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
te.getCmtTwoCountries(country1 ='portugal', country2 ='spain')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/comtrade/country/portugal/spain?c=${api_key}`)
console.log(response.data)
})()
Or using our package:
data = te.getComtrade(country = 'portugal', country1 = 'spain').then(function(data){
console.log(data)
});
Using Requests:
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/country/portugal/spain?c=your_api_key"))
/comtrade/country/{country_1}/{country_2}
symbol | country1 | country2 | value | date | type | category | url | title | StartDate | lastupdate | |
---|---|---|---|---|---|---|---|---|---|---|---|
PRTESP00001 | Portugal | Spain | 38348660154 | 2023 | Import | /portugal/imports/spain | Portugal imports from Spain | 1988 | 2/17/2024 9:27:00 AM | ||
PRTESP00002 | Portugal | Spain | 21634181445 | 2023 | Export | /portugal/exports/spain | Portugal exports to Spain | 1988 | 2/17/2024 9:27:00 AM | ||
PRTESPXX871 | Portugal | Spain | 4062012117 | 2023 | Import | “Vehicles other than railway, tramway” | /portugal/imports/spain/vehicles-not-railway-tramway | “Portugal Imports from Spain of Vehicles other than railway, tramway” | 1990 | 2/17/2024 8:56:00 AM |
/comtrade/country/{country_1}/{country_2}?f=json
[{"symbol":"PRTESP00001","country1":"Portugal","country2":"Spain","value":38348660154,"date":2023,"type":"Import","category":null,"url":"/portugal/imports/spain","title":"Portugal imports from Spain","StartDate":1988,"lastupdate":"2024-02-17T09:27:00"},{"symbol":"PRTESP00002","country1":"Portugal","country2":"Spain","value":21634181445,"date":2023,"type":"Export","category":null,"url":"/portugal/exports/spain","title":"Portugal exports to Spain","StartDate":1988,"lastupdate":"2024-02-17T09:27:00"},{"symbol":"PRTESPXX871","country1":"Portugal","country2":"Spain","value":4062012117,"date":2023,"type":"Import","category":"Vehicles other than railway, tramway","url":"/portugal/imports/spain/vehicles-not-railway-tramway","title":"Portugal Imports from Spain of Vehicles other than railway, tramway","StartDate":1990,"lastupdate":"2024-02-17T08:56:00"}]
/comtrade/country/{country_1}/{country_2}?f=csv
PRTESP00001,Portugal,Spain,38348660154,2023,Import,,/portugal/imports/spain,Portugal imports from Spain,1988,2/17/2024 9:27:00 AM
PRTESP00002,Portugal,Spain,21634181445,2023,Export,,/portugal/exports/spain,Portugal exports to Spain,1988,2/17/2024 9:27:00 AM
PRTESPXX871,Portugal,Spain,4062012117,2023,Import,"Vehicles other than railway, tramway",/portugal/imports/spain/vehicles-not-railway-tramway,"Portugal Imports from Spain of Vehicles other than railway, tramway",1990,2/17/2024 8:56:00 AM
/comtrade/country/{country_1}/{country_2}?f=xml
<ArrayOfanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeSnapshot">
<d2p1:StartDate>1988</d2p1:StartDate>
<d2p1:category i:nil="true"/>
<d2p1:country1>Portugal</d2p1:country1>
<d2p1:country2>Spain</d2p1:country2>
<d2p1:date>2023</d2p1:date>
<d2p1:lastupdate>2024-02-17T09:27:00</d2p1:lastupdate>
<d2p1:symbol>PRTESP00001</d2p1:symbol>
<d2p1:title>Portugal imports from Spain</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/portugal/imports/spain</d2p1:url>
<d2p1:value>38348660154</d2p1:value>
</anyType>
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeSnapshot">
<d2p1:StartDate>1988</d2p1:StartDate>
<d2p1:category i:nil="true"/>
<d2p1:country1>Portugal</d2p1:country1>
<d2p1:country2>Spain</d2p1:country2>
<d2p1:date>2023</d2p1:date>
<d2p1:lastupdate>2024-02-17T09:27:00</d2p1:lastupdate>
<d2p1:symbol>PRTESP00002</d2p1:symbol>
<d2p1:title>Portugal exports to Spain</d2p1:title>
<d2p1:type>Export</d2p1:type>
<d2p1:url>/portugal/exports/spain</d2p1:url>
<d2p1:value>21634181445</d2p1:value>
</anyType>
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeSnapshot">
<d2p1:StartDate>1990</d2p1:StartDate>
<d2p1:category>Vehicles other than railway, tramway</d2p1:category>
<d2p1:country1>Portugal</d2p1:country1>
<d2p1:country2>Spain</d2p1:country2>
<d2p1:date>2023</d2p1:date>
<d2p1:lastupdate>2024-02-17T08:56:00</d2p1:lastupdate>
<d2p1:symbol>PRTESPXX871</d2p1:symbol>
<d2p1:title>Portugal Imports from Spain of Vehicles other than railway, tramway</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/portugal/imports/spain/vehicles-not-railway-tramway</d2p1:url>
<d2p1:value>4062012117</d2p1:value>
</anyType>
</ArrayOfanyType>
Trade between countries by type
type = (import or export)
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/comtrade/country/portugal/spain?type=import&c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
Import
te.getCmtCountryFilterByType(country1 ='portugal', country2 ='spain',
type='import')
Export
te.getCmtCountryFilterByType(country1 ='portugal', country2 ='spain',
type='export')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/comtrade/country/portugal/spain?type=import&c=${api_key}`)
console.log(response.data)
})()
Or using our package:
Import
data = te.getComtrade(country = 'portugal', country1 = 'spain',
category='import').then(function(data){
console.log(data)
});
Export
data = te.getComtrade(country = 'portugal', country1 = 'spain',
category='export').then(function(data){
console.log(data)
});
Using Requests:
Import
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/country/portugal/spain?type=import&c=your_api_key"))
Export
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/country/portugal/spain?type=export&c=your_api_key"))
/comtrade/country/{country_1}/{country_2}?type={type}
symbol | country1 | country2 | value | date | type | category | url | title | StartDate | lastupdate | |
---|---|---|---|---|---|---|---|---|---|---|---|
PRTESP00001 | Portugal | Spain | 38348660154 | 2023 | Import | /portugal/imports/spain | Portugal imports from Spain | 1988 | 2/17/2024 9:27:00 AM | ||
PRTESP00002 | Portugal | Spain | 21634181445 | 2023 | Export | /portugal/exports/spain | Portugal exports to Spain | 1988 | 2/17/2024 9:27:00 AM | ||
PRTESPXX871 | Portugal | Spain | 4062012117 | 2023 | Import | “Vehicles other than railway, tramway” | /portugal/imports/spain/vehicles-not-railway-tramway | “Portugal Imports from Spain of Vehicles other than railway, tramway” | 1990 | 2/17/2024 8:56:00 AM |
/comtrade/country/{country_1}/{country_2}?type={type}&f=json
[{"symbol":"PRTESP00001","country1":"Portugal","country2":"Spain","value":38348660154,"date":2023,"type":"Import","category":null,"url":"/portugal/imports/spain","title":"Portugal imports from Spain","StartDate":1988,"lastupdate":"2024-02-17T09:27:00"},{"symbol":"PRTESP00002","country1":"Portugal","country2":"Spain","value":21634181445,"date":2023,"type":"Export","category":null,"url":"/portugal/exports/spain","title":"Portugal exports to Spain","StartDate":1988,"lastupdate":"2024-02-17T09:27:00"},{"symbol":"PRTESPXX871","country1":"Portugal","country2":"Spain","value":4062012117,"date":2023,"type":"Import","category":"Vehicles other than railway, tramway","url":"/portugal/imports/spain/vehicles-not-railway-tramway","title":"Portugal Imports from Spain of Vehicles other than railway, tramway","StartDate":1990,"lastupdate":"2024-02-17T08:56:00"}]
/comtrade/country/{country_1}/{country_2}?type={type}&f=csv
PRTESP00001,Portugal,Spain,38348660154,2023,Import,,/portugal/imports/spain,Portugal imports from Spain,1988,2/17/2024 9:27:00 AM
PRTESP00002,Portugal,Spain,21634181445,2023,Export,,/portugal/exports/spain,Portugal exports to Spain,1988,2/17/2024 9:27:00 AM
PRTESPXX871,Portugal,Spain,4062012117,2023,Import,"Vehicles other than railway, tramway",/portugal/imports/spain/vehicles-not-railway-tramway,"Portugal Imports from Spain of Vehicles other than railway, tramway",1990,2/17/2024 8:56:00 AM
/comtrade/country/{country_1}/{country_2}?type={type}&f=xml
<ArrayOfanyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeSnapshot">
<d2p1:StartDate>1988</d2p1:StartDate>
<d2p1:category i:nil="true"/>
<d2p1:country1>Portugal</d2p1:country1>
<d2p1:country2>Spain</d2p1:country2>
<d2p1:date>2023</d2p1:date>
<d2p1:lastupdate>2024-02-17T09:27:00</d2p1:lastupdate>
<d2p1:symbol>PRTESP00001</d2p1:symbol>
<d2p1:title>Portugal imports from Spain</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/portugal/imports/spain</d2p1:url>
<d2p1:value>38348660154</d2p1:value>
</anyType>
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeSnapshot">
<d2p1:StartDate>1988</d2p1:StartDate>
<d2p1:category i:nil="true"/>
<d2p1:country1>Portugal</d2p1:country1>
<d2p1:country2>Spain</d2p1:country2>
<d2p1:date>2023</d2p1:date>
<d2p1:lastupdate>2024-02-17T09:27:00</d2p1:lastupdate>
<d2p1:symbol>PRTESP00002</d2p1:symbol>
<d2p1:title>Portugal exports to Spain</d2p1:title>
<d2p1:type>Export</d2p1:type>
<d2p1:url>/portugal/exports/spain</d2p1:url>
<d2p1:value>21634181445</d2p1:value>
</anyType>
<anyType xmlns:d2p1="http://schemas.datacontract.org/2004/07/APILib.DB" i:type="d2p1:Markets.ComtradeSnapshot">
<d2p1:StartDate>1990</d2p1:StartDate>
<d2p1:category>Vehicles other than railway, tramway</d2p1:category>
<d2p1:country1>Portugal</d2p1:country1>
<d2p1:country2>Spain</d2p1:country2>
<d2p1:date>2023</d2p1:date>
<d2p1:lastupdate>2024-02-17T08:56:00</d2p1:lastupdate>
<d2p1:symbol>PRTESPXX871</d2p1:symbol>
<d2p1:title>Portugal Imports from Spain of Vehicles other than railway, tramway</d2p1:title>
<d2p1:type>Import</d2p1:type>
<d2p1:url>/portugal/imports/spain/vehicles-not-railway-tramway</d2p1:url>
<d2p1:value>4062012117</d2p1:value>
</anyType>
</ArrayOfanyType>
Updates by country and date
Using Requests:
import requests
api_key = 'YOUR_API_KEY'
url = f'https://api.tradingeconomics.com/comtrade/updates/country/mexico?from=2020-01-01&c={api_key}'
data = requests.get(url).json()
print(data)
Or using our package:
te.getCmtLastUpdates(country = 'mexico', start_date = '2020-01-01')
Using Requests:
const axios = require('axios');
(async () => {
const api_key = 'YOUR_API_KEY'
const response = await axios.get(`https://api.tradingeconomics.com/comtrade/updates/country/mexico?from=2020-01-01&c=${api_key}`)
console.log(response.data)
})()
Or using our package:
data = te.getCmtLastUpdates(country = 'mexico', start_date='2020-01-01').then(function(data){
console.log(data)
});
Using Requests:
using (var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.tradingeconomics.com/comtrade/updates/country/mexico?from=2020-01-01&c=your_api_key"))
/comtrade/updates/country/{country}?from={yyyy-mm-dd}
symbol | country1 | country2 | value | date | type | category | url | title | StartDate | lastupdate | |
---|---|---|---|---|---|---|---|---|---|---|---|
MEXCAN29372 | Mexico | Canada | 0 | Export | “Hormons and Their Derivatives, Other Steroids Used Primarily as Hormone” | /mexico/exports/canada/hormones-steroids-used-hormones | “Mexico exports of hormons and their derivatives, other steroids used primarily as hormone to Canada” | 1990 | 2/2/2024 7:21:00 AM | ||
MEXHKG29371 | Mexico | Hong Kong | 0 | Import | “Hormons and Their Derivatives, Other Steroids Used Primarily as Hormone” | /mexico/imports/hong-kong/hormones-steroids-used-hormones | “Mexico Imports from Hong Kong of Hormons and Their Derivatives, Other Steroids Used Primarily as Hormone” | 1992 | 1/29/2024 7:09:00 AM | ||
MEXHKG85081 | Mexico | Hong Kong | 0 | Import | “Electromechanical tools, working in hand, parts” | /mexico/imports/hong-kong/electromechanical-tools-working-hand-parts | “Mexico Imports from Hong Kong of Electromechanical tools, working in hand, parts” | 1990 | 1/29/2024 7:09:00 AM |
/comtrade/updates/country/{country}?from={yyyy-mm-dd}&f=json
[{"symbol":"MEXCAN29372","country1":"Mexico","country2":"Canada","value":null,"date":0,"type":"Export","category":"Hormons and Their Derivatives, Other Steroids Used Primarily as Hormone","url":"/mexico/exports/canada/hormones-steroids-used-hormones","title":"Mexico exports of hormons and their derivatives, other steroids used primarily as hormone to Canada","StartDate":1990,"lastupdate":"2024-02-02T07:21:00"},{"symbol":"MEXHKG29371","country1":"Mexico","country2":"Hong Kong","value":null,"date":0,"type":"Import","category":"Hormons and Their Derivatives, Other Steroids Used Primarily as Hormone","url":"/mexico/imports/hong-kong/hormones-steroids-used-hormones","title":"Mexico Imports from Hong Kong of Hormons and Their Derivatives, Other Steroids Used Primarily as Hormone","StartDate":1992,"lastupdate":"2024-01-29T07:09:00"},{"symbol":"MEXHKG85081","country1":"Mexico","country2":"Hong Kong","value":null,"date":0,"type":"Import","category":"Electromechanical tools, working in hand, parts","url":"/mexico/imports/hong-kong/electromechanical-tools-working-hand-parts","title":"Mexico Imports from Hong Kong of Electromechanical tools, working in hand, parts","StartDate":1990,"lastupdate":"2024-01-29T07:09:00"}]
/comtrade/updates/country/{country}?from={yyyy-mm-dd}&f=csv
symbol,country1,country2,value,date,type,category,url,title,StartDate,lastupdate
MEXCAN29372,Mexico,Canada,,0,Export,"Hormons and Their Derivatives, Other Steroids Used Primarily as Hormone",/mexico/exports/canada/hormones-steroids-used-hormones,"Mexico exports of hormons and their derivatives, other steroids used primarily as hormone to Canada",1990,2/2/2024 7:21:00 AM
MEXHKG29371,Mexico,Hong Kong,,0,Import,"Hormons and Their Derivatives, Other Steroids Used Primarily as Hormone",/mexico/imports/hong-kong/hormones-steroids-used-hormones,"Mexico Imports from Hong Kong of Hormons and Their Derivatives, Other Steroids Used Primarily as Hormone",1992,1/29/2024 7:09:00 AM
MEXHKG85081,Mexico,Hong Kong,,0,Import,"Electromechanical tools, working in hand, parts",/mexico/imports/hong-kong/electromechanical-tools-working-hand-parts,"Mexico Imports from Hong Kong of Electromechanical tools, working in hand, parts",1990,1/29/2024 7:09:00 AM
/comtrade/updates/country/{country}?from={yyyy-mm-dd}&f=xml
<ArrayOfMarkets.ComtradeSnapshot xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/APILib.DB">
<Markets.ComtradeSnapshot>
<StartDate>1990</StartDate>
<category>Hormons and Their Derivatives, Other Steroids Used Primarily as Hormone</category>
<country1>Mexico</country1>
<country2>Canada</country2>
<date>0</date>
<lastupdate>2024-02-02T07:21:00</lastupdate>
<symbol>MEXCAN29372</symbol>
<title>Mexico exports of hormons and their derivatives, other steroids used primarily as hormone to Canada</title>
<type>Export</type>
<url>/mexico/exports/canada/hormones-steroids-used-hormones</url>
<value i:nil="true"/>
</Markets.ComtradeSnapshot>
<Markets.ComtradeSnapshot>
<StartDate>1992</StartDate>
<category>Hormons and Their Derivatives, Other Steroids Used Primarily as Hormone</category>
<country1>Mexico</country1>
<country2>Hong Kong</country2>
<date>0</date>
<lastupdate>2024-01-29T07:09:00</lastupdate>
<symbol>MEXHKG29371</symbol>
<title>Mexico Imports from Hong Kong of Hormons and Their Derivatives, Other Steroids Used Primarily as Hormone</title>
<type>Import</type>
<url>/mexico/imports/hong-kong/hormones-steroids-used-hormones</url>
<value i:nil="true"/>
</Markets.ComtradeSnapshot>
<Markets.ComtradeSnapshot>
<StartDate>1990</StartDate>
<category>Electromechanical tools, working in hand, parts</category>
<country1>Mexico</country1>
<country2>Hong Kong</country2>
<date>0</date>
<lastupdate>2024-01-29T07:09:00</lastupdate>
<symbol>MEXHKG85081</symbol>
<title>Mexico Imports from Hong Kong of Electromechanical tools, working in hand, parts</title>
<type>Import</type>
<url>/mexico/imports/hong-kong/electromechanical-tools-working-hand-parts</url>
<value i:nil="true"/>
</Markets.ComtradeSnapshot>
</ArrayOfMarkets.ComtradeSnapshot>
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’.