Skip to main content

API Wrapper for The Observatory for Economic Complexity

Project description

Python Wrapper for The Observatory for Economic Complexity API

Language: Python 3
Data Source: Observatory for Economic Complexity (OEC)

Installation

pip install oec

Usage

See the OEC website for details about acceptable parameters for an API call: https://atlas.media.mit.edu/api/

Check out help.txt or run pydoc oec to view function-level documentation.

Get data from the OEC website

import oec

# Set parameters in accordance with API documentation
params = {'classification': 'hs92',
		  'trade_flow': 'export',
		  'year': 2015,
		  'origin': 'egy',
		  'destination': 'all',
		  'product': 'show'}

list_of_countries = oec.get_countries()
list_of_products = oec.get_products(params['classification'])
list_of_exports = oec.get_trade(**params)

These functions each return lists of dictionaries. Each of these dictionaries represents a "row" of data (e.g. one country or product). The fields of these dictionaries represent "columns" of data. This is easier to visualize if you output your data to a CSV file.

Output data to a CSV file

oec.data_to_csv(list_of_dictionaries, 'results.csv')

These CSV files can then be opened up in the spreadsheet editor of your choice for further analysis.

Display visualizations

>>> oec.url_visual(**params)
'http://atlas.media.mit.edu/en/visualize/tree_map/hs92/export/egy/all/show/2015/'
>>> oec.embed_visual(**params)
'<iframe src="http://atlas.media.mit.edu/en/visualize/embed/tree_map/hs92/export/egy/all/show/2015/" width=930 height=400></iframe>'
>>> oec.url_visual(**params, language='fr')
'http://atlas.media.mit.edu/fr/visualize/tree_map/hs92/export/egy/all/show/2015/'

Acknowledgements

Credits to Alex Simoes for the development of The Observatory for Economic Complexity. This module was developed by Yahia Ali, who is not affiliated in any way with the OEC team.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oec-0.2.3.tar.gz (4.0 kB view details)

Uploaded Source

File details

Details for the file oec-0.2.3.tar.gz.

File metadata

  • Download URL: oec-0.2.3.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for oec-0.2.3.tar.gz
Algorithm Hash digest
SHA256 dc7354a80e6075ecf3bfcbbcf95a1ea5414db02e555cc00e80d922358db1e015
MD5 1d2441971889a9a51123e857f95363b7
BLAKE2b-256 522fd84793c5287313e99fac9b96efba4947d69917878290fc2fa3f81860ffbc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page