Specifications
Web service provides a simple query interface to the World Health Organization's data and statistics content. This document describes version 5.0.0.75 of the API.
- Data Warehouse (DW)
is a central repository of health data from multiple data sources.
- API
Application programming interface (API) defines a way through which it is possible to interact with data stored in DW. WHO Europe API uses HTTP as a transport protocol and JSON (CSV) format for a response object.
- JSON
JavaScript Object Notation (JSON) is an open standard format that uses human-readable text to represent data objects consisting of attribute-value pairs.
- CSV
Comma-separated values (CSV) is a format that uses plain text to represent tabular data using rows and columns that are separated by commas.
- Indicator
observed value of a variable, quantifiable characteristics which describes the health of a population.
- Measure
set of facts with unique code and bilingual name that are defining an indicator.
- Metadata
defines WHO Europe DW data structure including Measures, Attributes, Measure-Attribute Codes, Fact-Attribute Codes and Notes.
- Fact
the set of attribute codes that belongs to measured value and value itself.
- Attribute
there are fact and measure related attributes. Fact attribute can be related to one of 3 main dimensions: Place, Time or Person. Measure attribute describes entire measure (EXTERNID, DATA_SOURCE) or is common for all facts (UNIT_TYPE).
- Code
unique short name that is used for identifying entity in the DW. Usually upper case with Latin letters, numbers and underscore.
- Data source
is measure attribute that defines the area (division?) that data comes from.
- Data set
set of measures that are used for whatever purpose: visualization, data mining, investigations, ...
- Note
is plain text or HTML data related to Measures or Data sources that are collected in the DW.
http://HOST[:PORT]/api/v5/CONTROLLER[/CODE][?QUERY_PARAMETERS]
Without any of the optional components, the following URL structure:
http://HOST/api/v5/CONTROLLER
Returns a list of the available instances for the specified controller.
If you specify a code of the instance you will get detailed information about specified instance. Specifying query parameters allows you to specify language of the response, filter data (either in instance list or data in the instance itself) or to select which parts of the instance to return.
-
HOST -
This is the domain of the web service. To access the API use
https://dw.euro.who.int -
PORT -
This is the port number for the web service. You can leave this out, or set it to the default HTTP port
80 -
CONTROLLER -
This is a code of the controller to retrieve data from. Available controllers are:
countriescountry_groupsdata_setsmeasuresversionexportexport_metadataexport_data_setclassificationscategories
Each controller returns different kind of data.
-
CODE -
This is the code of the instance that you want to get
-
QUERY_PARAMETERS -
This is additional query parameters. Possible parameters are:
-
lang— language of the response. Can be set either toENfor English or toRUfor Russian. Default language in English. -
filter— can be used for filtering either measures or facts within a certain measure.filtervalue is a semicolon separated list of tokens in formATTRIBUTE:CODES_LIST.CODES_LISTis:-
a comma separated list of codes,
-
"
*" - any specified value, -
"
$blank" - unspecified value, -
ranges like
1999-2004(ifATTRIBUTEis integer valued), -
"
~[year]" or "[year]~" - nearest available year filter, where "~" character specifies in which direction data should be searched, e.g.:~2001- if data for the2001year is missing, then data from the nearest previous year is returned.
Codes within the same
ATTRIBUTEare logically ORed. DifferentATTRIBUTESare logically ANDed.COUNTRYattribute supportsCOUNTRY_GRPcodes asCODES_LISTvalues meaning countries in specified country groups. -
-
output— can be used inmeasuresandcategoriescontrollers to select which part or parts of the object should be returned. Possible values are:data,metadata,attributes,notes,classificationsfor measures andmeasures,subtreefor categories.outputparameter can be set to either of these values or to a comma separated list of them. -
updated_since— useful for retrieving information about measures and data sources that were changed since certain date. -
dataState— allows you to download codes and labels for measures and classifications that are currently unpublished in Data Warehouse. -
format— defines format of the files that are exported by the API. Used only for data export and can be set to eitherxlsxorcsv.
-
The API provides data in JSON format. For each specific CONTROLLER structure of the returned object is different. See examples for more clarification.
- Example 1 — Getting API version
- Example 2 — Retrieving a list of instances
- Example 3 — Retrieving detailed information about an instance
- Example 4 — Selecting the language of the response
- Example 5 — Selecting measure's object parts
- Example 6 — Filtering data
- Example 7 — Filtering by country
- Example 8 — Exporting data
- Example 9 — Exporting metadata
- Example 10 — Retrieving hierarchical measure structure
- Example 11 — Data sets
Example 1 — Getting API version
To get current version of the API use the following URL: /api/v5/version.
Example 2 — Retrieving a list of instances
To get a list of instances use one of the following URLs:
/api/v5/countriesto get a list of countries./api/v5/country_groupsto get a list of country groups./api/v5/data_setsto get a list of data sets./api/v5/measuresto get a list of measures.
Example 3 — Retrieving detailed information about an instance
To get detailed information about an instance you should specify code of the instance to get:
/api/v5/countries/UKRreturns information about Ukraine./api/v5/country_groups/EU_MEMBERSreturns information aboutEU_MEMBERScountry group which is the European Union./api/v5/measures/H2020_1returns information aboutH2020_1measure.
Specifying instance code in the API URL makes API return detailed information about this instance. For example, detailed information about country contains a list of country_groups that it belongs to; detailed information about measure contains list of metadata, attributes, facts, notes and classifications related to this measure.
Example 4 — Selecting the language of the response
To select the language of the response lang parameter is used. It can be set to either EN or RU for English or Russian respectively:
/api/v5/countries?lang=ENreturns information in English./api/v5/country_groups/CIS?lang=RUreturns information in Russian./api/v5/measures/H2020_1?lang=ruis also OK; language parameter is case insensitive.
Default language is English so if lang parameter is not specified English response is returned.
Example 5 — Selecting measure's object parts
To select which part of measure object the API should return set output parameter to either attributes, metadata, data, notes, classifications, data_sets or dimensions or to a comma separated list of them:
/api/v5/measures/H2020_1?output=datareturns onlydataof the measure./api/v5/measures/H2020_1?output=metadatareturns onlymetadataof the measure./api/v5/measures/H2020_1?output=data,attributesreturnsattributesanddataof the measure omitting itsmetadata.
Example 6 — Filtering data
The only two instances that can be filtered are measures and measure's facts. Measures are filtered by their metadata attributes:
/api/v5/measures?filter=DATA_SOURCE:HFAreturns measures that haveHFADATA_SOURCE/api/v5/measures?filter=UNIT_TYPE:NUM_BEDS,NUM_DAYSreturns measures that haveUNIT_TYPEeitherNUM_BEDSorNUM_DAYS./api/v5/measures?filter=DATA_SOURCE:HFA,ENHIS;UNIT_TYPE:KM2returns measures that haveDATA_SOURCEeitherH2020orENHISandUNIT_TYPEKM2.
Facts are filtered by attributes:
/api/v5/measures/HFA_1?filter=SEX:FEMALE,MALEreturnsHFA_1facts that haveSEXattribute set toFEMALEorMALE.-
/api/v5/measures/H2020_1?filter=YEAR:2004-2007,2011returnsH2020_1facts that haveYEARattribute set to2004,2005,2006,2007or2011. /api/v5/measures/H2020_1?filter=YEAR:~2050returnsH2020_1facts for2050or if the value is missing then facts from the closest year before2050./api/v5/measures/H2020_1?filter=YEAR:2000~returnsH2020_1facts for the2000year or if they are missing then facts from the closest year with data after the2000year./api/v5/measures/H2020_1?filter=COUNTRY:ALB;YEAR:2002,2003;MEASURE_TYPE:AGE_STD_RATEreturnsH2020_1facts that haveCOUNTRYset toALB,YEARset to either2002or2003andMEASURE_TYPEset toAGE_STD_RATE./api/v5/measures/HFAMDB_1?filter=SUBNATIONAL_MDB:*returnsHFAMDB_1facts that haveSUBNATIONAL_MDBattribute specified./api/v5/measures/HFAMDB_1?filter=SUBNATIONAL_MDB:$blank;SEX:ALLreturnsHFAMDB_1facts that haveSUBNATIONAL_MDBattributed unspecified andSEXset toALL.
You can also filter measures and data sets by last updated date:
/api/v5/data_sets?updated_since=2015-12-27returns list of data set codes that were updated after 27 Dec 2015/api/v5/measures?updated_since=2015-12-01returns list of measure codes that were updated after 01 Dec 2015/api/v5/measures?updated_since=2015-12-18T19:00returns list of measure codes that were updated after 18 Dec 2015 19:00
Request for certain data set or measure with updated_since parameter returns true if this data set or measure was updated since certain date and false otherwise:
/api/v5/data_sets/HBSC?updated_since=2016-01-05returnstruehenceHBSCdata set was updated after 05 Jan 2016/api/v5/data_sets/H2020?updated_since=2015-12-11T15:00returnsfalsehenceH2020data set wasn't updated after 11 Dec 2015 15:00/api/v5/measures/H2020_10?updated_since=2015-12-27returnsfalsebecauseH2020_10measure wasn't updated after 27 Dec 2015
Example 7 — Filtering by country
You can filter measure's facts by country:
/api/v5/measures/H2020_1?filter=COUNTRY:BGR,AUT,UKRreturnsH2020_1facts that haveCOUNTRYattribute set toBGR,AUTorUKR./api/v5/measures/H2020_1?filter=COUNTRY:*returnsH2020_1facts that haveCOUNTRYattribute specified./api/v5/measures/H2020_1?filter=COUNTRY:$blank;YEAR:2003returnsH2020_1facts that haveCOUNTRYattributed unspecified andYEARset to2003.
There are some exceptions in the logic of filtering when applied to attributes COUNTRY and COUNTRY_GRP. Some examples:
/api/v5/measures/H2020_1?filter=COUNTRY_GRP:EU_MEMBERSreturnsH2020_1facts that haveCOUNTRY_GRPequalEU_MEMBERS./api/v5/measures/H2020_1?filter=COUNTRY_GRP:EU_MEMBERS;COUNTRY:ITAreturnsH2020_1facts that have eitherCOUNTRY_GRPattribute setEU_MEMBERSorCOUNTRYattribute set toITA./api/v5/measures/H2020_1?filter=COUNTRY:ITAreturnsH2020_1facts that haveCOUNTRYset toITA./api/v5/measures/H2020_1?filter=COUNTRY:ALB,EU_MEMBERSreturnsH2020_1facts that haveCOUNTRYset toALBor any country inEU_MEMBERScountry group.
Example 8 — Exporting data
You can export measure data in csv or excel format. Export the data when you need to work in an application that is not connected to the API, for example in Excel or other applications. Excel is the default format when exporting measures.
Each export request (for a measure or data set) returns a JSON response.
/api/v5/export/H2020_1 returns H2020_1 measure data.
{
"status": "InQueue",
"time_elapsed_seconds": 0,
"check_status_url":"/api/v5/export/status/c2df1c001eb64309b12f97a920bc3ecc"
}
The first property is the status code of the export process. Possible status codes are:
- “InQueue” - file is waiting in queue to be processed,
- “Processing” - file generation has started,
- “Generated” - file processing completed and available for download,
- “Failed” - file processing failed.
Second property "time_elapsed_seconds" is the number of seconds since the file has been requested. It is only present if status property is “InQueue” or “Processing”. The property "check_status_url" provides URL to check the export process during a status of “InQueue” or “Processing”.
When the file processing is completed and available for download, the following response is displayed:
{
"status": "Generated",
"generated_time": "2018-01-21T13:45:21.2249016",
"file_size_kb": 59,
"download_url":"/api/v5/export/download/6522933299f54d20b58dd013b506dd2"
}
The property "generated_time" is the date and time in ISO format, and shows when the file was processed. The property "file_size_kb" shows the size of the processed file in kilobytes. The property "download_url" displays the URL for a direct download of the processed file.
Here are examples of export URLs with various filters:
/api/v5/export/H2020_1exports excel file withH2020_1measure data./api/v5/export/H2020_1?format=xlsxexports excel file withH2020_1measure data./api/v5/export/H2020_1?format=csv&lang=ruexports csv file withH2020_1measure data in Russian.
You can also export multiple measures in one file:
/api/v5/export?code=H2020_1,H2020_2exports data forH2020_1andH2020_2measures in one xlsx file./api/v5/export?code=HFA_1,ENHIS_12,ENHIS_32&format=csv&lang=ruexports zip file that contains three csv files forHFA_1,ENHIS_13andENHIS_32measures in Russian.
It is also possible to export data set entirely or only some of the measures of the dataset:
/api/v5/export_data_set/H2020exports zip file containing metadata and data of measures that belong toH2020data set./api/v5/export_data_set/H2020?measures=H2020_1,H2020_2,H2020_3exports zip file containing metadata and data ofH2020_1,H2020_2andH2020_3measures ofH2020data set
You can also filter exported measures facts by some attribute:
/api/v5/export/HFAMDB_1?filter=SUBNATIONAL_MDB:$blankexports excel file withHFAMDB_1measure facts that haveSUBNATIONAL_MDBattribute unspecified./api/v5/export/HFAMDB_1?filter=SUBNATIONAL_MDB:*&format=csv&lang=ruexports Russian csv file withHFAMDB_1measure facts that haveSUBNATIONAL_MDBattribute specified./api/v5/export_data_set/H2020?filter=COUNTRY_GRP:NORDICexports zip file containing metadata and data of measures that belong toH2020data set. Only measures facts that haveCOUNTRY_GRPequalNORDICwill be present./api/v5/export_data_set/H2020?measures=H2020_1,H2020_2,H2020_3&filter=COUNTRY:UKRexports zip file containing metadata and data ofH2020_1,H2020_2andH2020_3measures ofH2020data set. Only measures facts that haveCOUNTRYattribute set toUKRwill be present.
Example 9 — Exporting metadata
You can export metadata in excel format:
/api/v5/export_metadataexports file with entire metadata./api/v5/export_metadata?dataState=unpublishedexports file with unpublished measures and classifications/api/v5/export_metadata?dataState=allexports file with all measures and classifications from the Data Warehouse/api/v5/export_metadata/measureexports file with measures metadata.
Example 10 — Retrieving hierarchical measure structure
To get available measure classifications you can use classifications request:
/api/v5/classificationsreturns list of measure classifications
To get detailed information about classifications like sub-categories or measures assigned to subcategories use categories controller:
/api/v5/categories/Dreturns whole classification tree with categories, sub-categories, sub-sub-categories (if exist) and measures related to them for classificationD/api/v5/categories/D03_00returns measures assigned to categoryD03_00and its sub-categories (if exist)/api/v5/categories/D03_00?output=measuresreturns measures assigned to categoryD03_00without its sub-categories/api/v5/categories/D03_00?output=subtreereturns sub-categories of categoryD03_00without measures assigned to it/api/v5/categoriesreturns entire classification tree for all classifications with measures assigned to each category/api/v5/categories?output=subtreereturns classification tree for all classifications without measures/api/v5/measures/HFA_1?output=classificationseach measure hasclassificationsproperty that contains list of categories that the measure is assigned to grouped by classifications. This can be used for getting a list of categories that the measure is assigned to and then getting related measures
Example 11 — Data sets
To get list of data sets or list of data set measures:
/api/v5/data_setsreturns list of all available data sets/api/v5/data_sets/H2020returns list of all measures of the data set
To get measure data in context of certain data set:
/api/v5/data_sets/H2020/H2020_1returnsH2020_1measure data in context ofH2020data set with data set specific country list, data set notes etc.