Welcome to World Bank API’s documentation!¶
Contents:
About¶
This is an Orange plugin for accessing Indicator API from world bank data.
This plugin is an extension of the simple_wbd API helper.
The API in this plugin is made to fetch data as easily as possible, for that some advanced API filters are disabled. The goal here is to get as much data with as little code as possible. For a more comprehensive API helper for World Bank Data see wbpy and wbdata.
Installation¶
With pip¶
pip install orange3-datasets
With gui¶
You can install this plugin by going to Options > Add-ons... and selecting Orange3-DataSets
Installing from source¶
This is mostly useful for development or if you need to tweak a few lines. Make sure you have git installed on your system.
git clone https://github.com/zidarsk8/orange3-data-sets.git
cd orange3-data-sets
pip install -e .
# for running tests, linters and generating docs you can also run
pip install -r requirements.txt
Usage CLI¶
This plugin is an extension of the simple_wbd API helper. For more information look at the original source.
Starting¶
This is a starting point for all code snippets below.
from orangecontrib.wbd import api_wrapper
api = api_wrapper.IndicatorAPI()
Getting countries¶
You can filter the final dataset by specific countries. But the World Bank Data API includes aggregate regions and some non standard ISO country codes. You can get all possible codes with
api.get_countries()
This will return a list of all country data. When writing the query you can use the alpha-2 or alpha-3 country code.
Getting indicators¶
There are around 18k indicators currently on World Band Data API. Since most of them do not have any data in, the default indicator filter is set for Common. You can also fetch all and featured indicators.
# get all common indicators
indicators = api.get_indicators()
featured_indicators = api.get_indicators(filter_="featured")
all_indicators = api.get_indicators(filter_=None)
Fetching data¶
Fetching data for a single indicator¶
dataset = api.get_dataset("some.indicator.id")
dataset = api.get_dataset(["some.indicator.id"]) # this is the same call
The API will return our modified Indicator dataset that can generate an Orange table.
# Get indicator data with countries in rows and dates in columns.
dataset.as_orange_table()
# Get time series data where dates are in rows and each column
# represents data for one country.
dataset.as_orange_table(timeseries=True)
Fetching data for multiple indicators¶
dataset = api.get_dataset([
"some.indicator.id",
"some.indicator.id.2",
"some.indicator.id.XYZ",
])
You can get an Orange table same as with single indicator, the only difference here is that column headers will have indicator prefix. So in this case, each column would appear 3 times with a different indicator prefix and data.
Usage GUI¶
Todo: write doc