The Global Health Observatory
Explore a world of health data
This module provides a set of examples demonstrating how to make queries against the GHO data webservice, Athena.
http://apps.who.int/gho/athena/api/
http://apps.who.int/gho/athena/api/GHO
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001
COUNTRY:BWAContinuing to build on the query from the previous example, if you wish to see the life expectancy at birth data for Botswana, the query is:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001?filter=COUNTRY:BWAThis query still returns a lof of data, you can filter it further, for example if we wish to know the life expectancy in Botswana for both combined sexes for the year 2011, we will add the following codes to the filter:
YEAR:2011;SEX:BTSXGiving us this query:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001?filter=COUNTRY:BWA;YEAR:2011;SEX:BTSX
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001?format=csvor HTML:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.htmlYou can combine this with the filter parameter, and any other parameter understood by the system to enable download of search results in whichever format you need. The query from example 4, life expectancy data for Botswana, rendered in CSV, becomes:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.csv?filter=COUNTRY:BWA
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.csv?filter=COUNTRY:BWA&profile=text
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.xml?filter=COUNTRY:BWA&profile=excelOn some instances of windows, depending on version and configuration, the above link may not open into Excel and may instead only give you the option to download the file. You can work around this by using the precedence of the format parameter and giving an arbitrary extension to your target. Our query can be modified to look like it is downloading an Excel XLS file by changing the xmlextension to xls and adding the URL query parameter &format=xml:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.xls?filter=COUNTRY:BWA&profile=excel&format=xml
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001,WHOSIS_000015
http://apps.who.int/gho/athena/api/GHO/life_expectancy?target=GHO/WHOSIS_000001,WHOSIS_000015Note that you must still use a dimension code in the URL path in order for the URL to be properly parsed. In this above example with have kept the GHO dimension code but it is in fact a dummy value and any similar text can be used, for example, we can replace the GHO value with the text download:
http://apps.who.int/gho/athena/api/download/life_expectancy?target=GHO/WHOSIS_000001,WHOSIS_000015You can combine the format, profile, and target parameters to make clean download links for constructs like Excel files. Continuing with our current example, this gives the query:
http://apps.who.int/gho/athena/api/download/life_expectancy.xls?target=GHO/WHOSIS_000001,WHOSIS_000015&format=xml&profile=excel
http://apps.who.int/gho/athena/api/?format=jsonYou can query for the codelist of a dimension, as in Example 2. For example, you can retrieve the GHO COUNTRY list with this query:
http://apps.who.int/gho/athena/api/COUNTRY?format=jsonAnd of course you can query for data and obtain the output in json. Continuing with the life expectancy example, we have:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.jsonIn order to use the simplified version of json, set the profile parameter to simple. Note that this only gives you a useful result on data queries, if you are querying for metadata only, you will not receive anything useful. Make a query as follows:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.json?profile=simpleIf you need to use JSONP, so that the json text is wrapped in a function, use the query string parameter callback or jsonp and provide the name of the function you wish to use. to return the above query in a function called search_results use the query:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.json?callback=search_results
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001?filter=COUNTRY:*If we wish to retrieve only regional data for the same indicator, use COUNTRY:-;REGION:* as follows:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001?filter=COUNTRY:-;REGION:*
http://apps.who.int/gho/athena/api/REGIONYou can then use one or more of these codes to restrict query results to countries belonging to the specified region(s). For example, if we to retrieve the life expectancy data for countries in Europe, we use the region code REGION:EUR and also specify COUNTRY:*because we are only interested in the country data itself and not the regional aggregate for this example:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001?filter=COUNTRY:*;REGION:EUR
&filter=DIMENSIONCODE:*,ATTR1=VALUE1[,ATTR2=VALUE2]For example, if you wish to retrieve data, say for life expectancy, for all countries whose ISO code starts with an A, use the following query:
http://apps.who.int/gho/athena/data/GHO/WHOSIS_000001.xml?filter=COUNTRY:*,ISO=A__You must specify attribute codes that are recognized for the dimension you with to use. Several attributes can be specified by seperating them with a comma character. Multiple attributes will be ANDed together in order to derive the final list of dimension member codes for the specified dimension.
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.html?filter=COUNTRY:*&profile=xtab&x-sideaxis=COUNTRY&x-topaxis=GHO;YEAR&x-title=tableNotice that the cells contain more than one value. That's because the data that is retrieved by this query is disaggregated across more dimensions than simply COUNTRY and YEAR. If you click on "Details: off", you will see additional markup showing the extra dimension codes relevant to each fact. You can force the cross table to display in this mode by adding the parameter x-details=true:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.html?filter=COUNTRY:*&profile=xtab&x-sideaxis=COUNTRY&x-topaxis=GHO;YEAR&x-title=table&x-details=trueFor production data such as we are accessing, the PUBLISHSTATE dimension code will always be PUBLISHED. The REGION code is also always linked to the country or if there is no country is data for the specified region. This leaves us the dimension SEX across which we disaggregate the data. We can add this to the top axis:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.html?filter=COUNTRY:*&profile=xtab&x-sideaxis=COUNTRY&x-topaxis=GHO;YEAR;SEX&x-title=table"or if we want, we can add it to the side axis:
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.html?filter=COUNTRY:*&profile=xtab&x-sideaxis=COUNTRY;SEX&x-topaxis=GHO;YEAR&x-title=table"Ordering of the various elements is determined by metadata from the database.
http://apps.who.int/gho/athena/api/GHO/WHOSIS_000001.html?filter=COUNTRY:*&profile=filter&x-format=html&x-profile=xtab&x-sideaxis=COUNTRY&x-topaxis=GHO;YEAR;SEX&x-title=tableThe filter is completely metadata driven and does not require any configuration.