Comtrade is a UN based comprehensive trade data collection and dissemination platform maintained and owned by The United Nations Statistics Division (UNSD). From the FAO building, everyone has full access to all Comtrade services. All information is available on the Comtrade website https://comtrade.un.org/.

In Comtrade there are few main options of data access:


Data availability in Comtrade

To save time before starting analysis, it is always good to know data availability in Comtrade. There are two interfaces for data availability analysis:

It is also possible to access data availability for the Bulk download. This data is available at the address line call: http://comtrade.un.org/api//refs/da/view?parameters. More information here.


Regular download in Comtrade

Source

Regular downloads is available here: https://comtrade.un.org/data/. This is a query based approach to load Comtrade data selecting a specific range of parameters. With the regular download is it possible to obtain a CSV file, which can be analyzes in excel, R, Stata and other tools.

How to access data

For an extensive overview, see the tutorial video below (https://www.youtube.com/watch?v=oflKZUj2BgE).

The most common query that will return data that we need in 90% of our analysis is the following:

Data response

Normally, data is returned in the long format with the variables describing main data dimensions selected above and variables with Trade quantities, Trade value, and units of measurement.


Bulk download in Comtrade

Comtrade bulk download is available at the web page https://comtrade.un.org/data/bulk.

There are two options how to access bulk data in Comtrade:

Web based bulk query

Source

Web based query for accessing Comtrade bulk data in the browser is available here: https://comtrade.un.org/data/bulk.

First time you need to access it from the FAO buildings in order to authorize your email. Insert your email in the “Enter your email” field and press “Authenticate my IP”. After that your email will be saved in the Comtrade database and you will be grated with the access to the bulk download interface (same address https://comtrade.un.org/data/bulk).

How to access data

In order to access Comtrade bulk data on the bulk data access page select required set of parameters. For example, to download bulk commodity statistics for France, select:

  • Type of product: Goods;
  • Frequency: Annual;
  • HS: As reported;
  • Period: All;
  • Reporter: France (or All - all reporters in one file or any single reporter that you needed);
  • Publication data: keep unchanged.

After clicking “Preview” yo will be returned with the list of all bulk data files available for your selection. Clicking on any of them will run the file, clicking on “Show API link” will provide you with the API data request command (see the next subsection) for returning a bulk data file. Be aware that any bulk data file could range in size from 1 to 500 megabyte.

Data response

Your browser will download one zip archive with data for a selected country (all countries), period and classification.

Attention! Data files could be very. In zipped format file size may range from 1 to 500 megabyte. Un extracted format, file size could be up to 9 gigabytes.

API bulk query

Source

If you do not want to click in the browser, you can use the API for accessing Comtrade data. Extensive explanation about the Comtrade API tools is available here https://comtrade.un.org/data/doc/api/bulk/.

How to access data

To access Comtrade bulk data with API, we need to construct a request, insert it to the browser command line and run it.

To request a bulk data file we need to use the specific format explained here. The main idea is to construct a request based on the template http://comtrade.un.org/api/get/bulk/{type}/{freq}/{ps}/{r}/{px}?{token=} specifying correct parameters:

  • type - trade type C - Commodities of S - Services;
  • freq - frequency A - Annual or M - Monthly;
  • ps - period coverage for annual data ps=YYYY - e.g. ps=2010, for monthly ps=YYYY or ps=YYYYMM;
  • r - reporter area code - e.g. r=804 or r=All. Extensive list available here;
  • px - classification, available values are: HS - Harmonized System (HS) as reported, H0-HS 1992, H1-HS 1996, H2-HS 2002, H3-HS 2007, H4-HS 2012 and others see;
  • token - optional parameter for data from outside of the authorized network.

For example, we want to request monthly data freq=M of commodities trade type=C for All reporters r=ALL for period January, 2017 ps=201701, in the HS as reporter classification px=HS. The request is http://comtrade.un.org/api/get/bulk/C/M/201701/ALL/HS. We insert this request to the browser adders line and download the file.

Data response

Your browser will download one zip archive with data for a selected country (all countries), period and classification.

Attention! Data files could be very. In zipped format file size may range from 1 to 500 megabyte. Un extracted format, file size could be up to 9 gigabytes.

Token for data access

To generate an authentication token for the UN Comtrade from the registered IP range (i.e. from the FAO headquarters), we first need to go to the UN Comtrade authentication page and insert our email into the Sign in using: > IP Authentication: field. Pressing Authenticate my IP will ensure we are registered in the UN Comtrade system. Please note, you need to do this only once.

Subsequently we need to go to comtradePlus.APIand select /getSubUserToken in the Auth section . After inserting the email, which you used to register above, into the corresponding field, press “try it out”:

In Response Headers the token will appear as a long string of symbols and characters. This token is to be copied to a secure place and used to access data in some programming cases or in the World Bank WITS database.


Data visualization options

UN Comtrade lists several visualization platforms on the page https://comtrade.un.org/labs/. Here, we will discuss some of them in more details.

Comtrade data-explorer

Comtrade data explorer https://comtrade.un.org/labs/data-explorer/ (unfortunately was not working on 2017-08-31). A tool for visualization of the main trade flows between selected reporters and partners of the selected commodity. Here, you will find a .pdf guidelines on how to use Comtrade data-explorer.

Limitations:

  • Commodities are not defined using the HS commodity codes, but as a free text, therefor, it is difficult to understand the meaning behind some commodity names.
  • Options of custom-defined aggregates of countries or commodities are not available.

Bilateral trade exploration tool

BIS trade in goods tool is available at https://comtrade.un.org/labs/BIS-trade-in-goods/ it allow to visualize trade of a selected good from a selected reporter to all or selected partner.

Limitations:

  • Commodity coverage is limited to the 2 digits HS commodity description;
  • Options of custom-defined aggregates of countries or commodities are not available.

Copyright © 2017 Eduard Bukin. All rights reserved.