How to Query for Specific Data

This is the basic call structure for returning JSON from the data API:
/ CLASSIFICATION / TRADE_FLOW / YEAR / ORIGIN / DESTINATION / PRODUCT /

Code Description
hs92 Uses the 1992 HS (Harmonized System) trade classification.
hs96 Uses the 1996 HS (Harmonized System) trade classification.
hs02 Uses the 2002 HS (Harmonized System) trade classification.
hs07 Uses the 2007 HS (Harmonized System) trade classification.
sitc Uses the SITC trade classification.
Code Description
export Change direction of trade flow to show export values.
import Change direction of trade flow to show import values.
Code Description
#### Any year between 1962 and 2015.
####.#### A range of years, separated by a comma. For example, 2002.2005 would return data for 2002, 2003, 2004, and 2005.
Code Description
show Keyword used to show all bilateral countries.
all Keyword to use all bilateral countries in the query.
3_character_id Search:
Code Description
show Keyword to show all products in the result.
all Keyword to use all products in the query.
4_digit_id Search:
http://atlas.media.mit.edu/hs92/export/2010/usa/all/show/
  {
    "data": [
      {
        "export_rca": 2.31506,
        "export_val": 391879514.8,
        "hs92_id": "010101",
        "import_rca": 0.953058,
        "import_val": 247872199.21,
        "origin_id": "nausa",
        "year": 2010.0
      },
      {
        "export_rca": 0.219569,
        "export_val": 132221725.59,
        "hs92_id": "010102",
        "import_rca": 1.74591,
        "import_val": 1615371811.24,
        "origin_id": "nausa",
        "year": 2010.0
      },
      ...
    ]
  }

How to Embed Visualizations

To embed a visualization, you need to use the same URI parameters as in the data calls, in a slightly different order, with an additional parameter specifying the visualization type. Here is the variable order, which for a visualization in English, would follow /en/explore/embed/:

/ VISUALIZATION / CLASSIFICATION / TRADE_FLOW / ORIGIN / DESTINATION / PRODUCT / YEAR /

Code Description
tree_map Rectangles used to represent data as shares of a whole.
stacked A stacked area graph showing share over time.
network The Product Space, showing products connected by a country's probability of co-exporting both products.
rings A focused view of the Product Space, showing only primary and secondary connections of a specific product.
compare A scatter plot that allows comparing a country's complexity (ECI) to it's GDP.
geo_map A world map that shows which countries export a specific product.
  <iframe src="/en/visualize/embed/tree_map/hs92/export/usa/all/show/2010/" width=600 height=400></iframe>  

Attribute Lookups

To save both bandwidth and reduce repition in our data calls, the attributional data for countries and products are separated out into a different call structure. By using these attribute calls in conjunction with the data calls one can retrive both the full names, keywords and descriptions of products and countries as well as their data.

Key Description
borders_land Array of IDs for countries that it borders by land.
borders_maritime Array of IDs for countries that it borders by sea (within a reasonable distance).
color Color used in visualizations, which is unique for each continent.
comtrade_name Full name of the country, as reported by COMTRADE.
display_id 3-digit standard ISO ID, used in all of our URLs.
icon For countries, this is the country's flag. For continents, this is the shape of the continent.
id ID used in our databases, which encodes the continent's ID as the first 2 digits (helps with nested visualizations).
id_2char 2-digit standard ISO ID.
id_num Numeric values which match to the raw data we injest from CEPII.
image_author Name of the Flickr user who took the photo used in the profile's header.
image_link Direct link to the profile header image's Flickr page.
name Simplified human-readable name used throughout this site.
palette Array of colors extracted from the profile header image.

Example JSON

  {
    "data": [
      ...
      {
        "borders_land": "['nacan', 'namex']",
        "borders_maritime": "['nabhs']",
        "color": "#0b1097",
        "comtrade_name": "USA|USA (before 1981)|United States",
        "display_id": "usa",
        "icon": "/static/img/icons/country/country_nausa.png",
        "id": "nausa",
        "id_2char": "us",
        "id_num": "840|841|842",
        "image_author": "Aurelien Guichard",
        "image_link": "https://flic.kr/p/8CZkZ7",
        "name": "United States",
        "palette": "[\"#020102\",\"#877b6f\",\"#c3ac8f\",\"#dde6ed\",\"#878b93\"]"
      },
      ...
    ]
  }
Key Description
color Color used in visualizations, which is unique for each parent grouping.
display_id The main ID, with the parent grouping's 2-digit prefix stripped out, which maps directly to the source data.
icon An icon representing the 2-digit parent grouping.
id ID used in our databases, which encodes the parent grouping's ID as the first 2 digits (helps with nested visualizations).
image_author Name of the Flickr user who took the photo used in the profile's header.
image_link Direct link to the profile header image's Flickr page.
keywords Comma-separated list of common keywords used to aid search.
name Simplified human-readable name used throughout this site.
palette Array of colors extracted from the profile header image.

Example JSON

  {
    "data": [
      ...
      {
        "color": "#FFE999",
        "display_id": "0101",
        "icon": "/static/img/icons/hs/hs_01.png",
        "id": "010101",
        "image_author": "James Marvin Phelps",
        "image_link": "https://flic.kr/p/gMG1YC",
        "keywords": "equine, zebra, ass, donkey, mules",
        "name": "Horses",
        "palette": "[\"#e7f9fa\",\"#533127\",\"#907b65\",\"#713928\",\"#b66b48\"]"
      },
      ...
    ]
  }