Skip to content
Docs
Get API key
Comtrade

Comtrade Snapshot of Latest Values

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

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 countries

Using Requests:

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

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

Text
https://api.tradingeconomics.com/comtrade/country/{country}/{country}?c={your_api_key}&f=json
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"
  }
]

Import or Export by country

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

Using Requests:

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

Or using our package:

Import

Python
te.getCmtCountryByCategory(country = 'India', type = 'import')

Export

Python
te.getCmtCountryByCategory(country = 'India', type = 'export')
Text
https://api.tradingeconomics.com/comtrade/{type}/{country}?c={your_api_key}&f=json
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"
  }
]

Import or Export by country and category

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

Using Requests:

Python
import requests
your_api_key = 'your_api_key'
url = f'https://api.tradingeconomics.com/comtrade/import/united%20kingdom/Coffee,%20tea,%20mate%20and%20spices?c={your_api_key}'
data = requests.get(url).json()
print(data)

Or using our package:

Import

Python
te.getCmtCountryByCategory(country = 'United Kingdom', type = 'import',
 category='Coffee, tea, mate and spices')

Export

Python
te.getCmtCountryByCategory(country = 'United Kingdom', type = 'export',
 category='Coffee, tea, mate and spices')
Text
https://api.tradingeconomics.com/comtrade/{type}/{country}/{category}?c={your_api_key}&f=json
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"
  }
]

Total imports and exports by country

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

Using Requests:

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

Or using our package:

Import

Python
te.getCmtTotalByType(country = 'India', type = 'import')

Export

Python
te.getCmtTotalByType(country = 'India', type = 'export')
Text
https://api.tradingeconomics.com/comtrade/{type}/{country}/totals?c={your_api_key}&f=json
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"
  }
]

Trade between countries

Using Requests:

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

Or using our package:

Python
te.getCmtTwoCountries(country1 ='portugal', country2 ='spain')
Text
https://api.tradingeconomics.com/comtrade/country/{country_1}/{country_2}?c={your_api_key}&f=json
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"
  }
]

Trade between countries by type

type = (import or export)

Using Requests:

Python
import requests
your_api_key = 'your_api_key'
url = f'https://api.tradingeconomics.com/comtrade/country/portugal/spain?type=import&c={your_api_key}'
data = requests.get(url).json()
print(data)

Or using our package:

Import

Python
te.getCmtCountryFilterByType(country1 ='portugal', country2 ='spain',
 type='import')

Export

Python
te.getCmtCountryFilterByType(country1 ='portugal', country2 ='spain',
 type='export')
Text
https://api.tradingeconomics.com/comtrade/country/{country_1}/{country_2}?c={your_api_key}&type={type}&f=json
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"
  }
]

Updates by country and date

Using Requests:

Python
import requests
your_api_key = 'your_api_key'
url = f'https://api.tradingeconomics.com/comtrade/updates/country/mexico?from=2020-01-01&c={your_api_key}'
data = requests.get(url).json()
print(data)

Or using our package:

Python
te.getCmtLastUpdates(country = 'mexico', start_date = '2020-01-01')
Text
https://api.tradingeconomics.com/comtrade/updates/country/{country}?c={your_api_key}&from={yyyy-mm-dd}&f=json
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"
  }
]

Response fields

FieldTypeDescriptionExample
SymbolstringUnique symbol used by Trading Economics“MWIBEL85173”
Country1stringReporting Country“Malawi”
Country2stringTrading Partner“Belgium”
ValuenumberTrade value in the specified unit17219
DatenumberYear of the data observation2022
TypestringTrade type (e.g., Export, Import, Re-Export)“Re-Export”
CategorystringProduct category name“Pepper, genus piper, genus capsicum or pimenta”
URLstringHyperlink at Trading Economics“/portugal/exports/aruba”
TitlestringTitle describing the trade flow“Portugal exports to Aruba”
StartDatenumberStarting year of the data series“2023-04-05T00:03:00”
lastupdatestringTimestamp of the last data update“2023-04-05T00:03:00”

Notes

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