The New DHS Program API: What Non-Developers Should Know

Written by: Erica Nybro

12 Aug, 2014

Don’t let the technical acronym scare you! While application developers and computer programmers are usually the direct users of APIs, the DHS API is a great tool for program managers and researchers.

What is an API?

An Application Programming Interface, or API, provides software developers with direct access to a database.  Developers can use the data in the database to populate websites and applications.  These applications can include data visualizations, tabular data for dissemination of information to specific stakeholders, or analysis.

How can the DHS API be used?

The DHS API connects users directly to the STATcompiler database of aggregated indicators.  That is, total fertility rates, mortality rates, and all of the almost 1500 indicators found in the STATcompiler for 90 countries over 30 years.   A developer at a maternal health project could select the maternal health indicators from a sub-sample of countries to populate a web page on key DHS data for the areas in which the project works.   Or a mobile app developer could use the DHS API to link STATcompiler data with other global health data and create a global development data visualization tool.

The API can also be used by analysts, as data can be returned in Stata-readable format, allowing for instant integration of indicator-level data into your Stata analysis.  The API website has a simple Stata Example page. It is also possible to open aggregated indicator data directly in Excel through the API, using the CSV format output.

We at The DHS Program will be using the Indicator Data API to populate statistics on our own website and our own mobile app, but we look forward to seeing other creative uses of DHS data.

How does the DHS API work?

The basic workings of the API are very simple, even for a non-developer.  A single URL contains all the information the database needs to return data.  For example, try copying the following URL into your browser:

http://api.dhsprogram.com/rest/dhs/data?breakdown=national&indicatorIds=20171000&countryIds=BF,BU,CM&f=html

This URL contains all the information the API needs to create a table about a given indicator (in this case Indicator ID – 20171000, which is total fertility rate) and three countries: Burkina Faso (BF), Burundi (BU), and Cameroon (CM).  The resulting web page gives us exactly that:  the Total Fertility rate for the three selected countries as well as some additional information about those surveys.    Don’t have time to search the documentation for country and indicator codes? The query builder allows users to select indicators and countries of interest, preview the output, and obtain the specific API call, that is, the URL needed to request those specific indicators and countries.  If you want a full list of the indicators, try this link.

What are the advantages to using an API?

Connecting to DHS data through the API ensures that you have up-to-date data, even as new countries and indicators are added or data are adjusted.   And while we think STATcompiler and DHS Mobile app are great, they aren’t customized to YOUR work.   The API will allow you to build interactive tools to showcase the data for the countries and areas you work in.

How do I start?

Visit http://api.dhsprogram.com/ for sample data calls, code samples, and all of the survey, country, and indicator documentation needed to communicate with the DHS API.  If you register to be an official DHS API partner you will receive an API key, allowing you a larger number of entries returned per page.  We may also be able to provide assistance in application development, promotion of the apps created by your team, and ongoing communication, allowing your feedback to influence future API development.

Details for developers:

The DHS API uses both a RESTful interface as well as a query-based interface. The API supports JSON, XML, HTML and CSV output formats. For more details, visit the DHS API website or follow our Twitter (@DHSprogramAPI).

Author

3 thoughts on “The New DHS Program API: What Non-Developers Should Know

  1. Using a browser is one way to look at the data that the API can provide. However, most developers will write code in something else to access the data from the API and would never need a browser. For example, I can open API data directly in Excel without needing a browser, or I can access data directly in Stata without using a browser, or in one of many other programming languages.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to The DHS Program Blog:

* = required field

Anthropometry measurement (height and weight) is a core component of DHS surveys that is used to generate indicators on nutritional status. The Biomarker Questionnaire now includes questions on clothing and hairstyle interference on measurements for both women and children for improved interpretation.

Subscribe to The DHS Program Blog:

* = required field