JSON Ebola2014 Data Found on the Web

JohnTigue edited this page Dec 28, 2014 · 23 revisions

This page provides a technical analysis of the 4 know JSON feeds of Ebola2014 data found on the Web. This was done in order to ensure that the Outbreak Time Series Specification would serve potential adopters well.

Arguably any machine readable structured data could be called an API. The JSON data feeds discussed on this page could be called APIs. They are private APIs, though, in that they were (I assume) banged out simply to get Ebola2014 outbreak data from a particular Web server to one of the site's pages running JavaScript in a Web browser.

The goal of the Outbreak Time Series Specification is to have a public API, and that it not be Ebola2014 specific. Also, the API will be used by servers, such at node.js based server, not just browsers. HDX is obviously heading in the direction of a public API as well. John Tigue is approach them to see if they might consider the Outbreak Time Series Specification defined in this project.

Table of contents


For more on the HDX repository, see HDX Repository.

HDX API experiment

On 2014-11-12 CJ Hendrix blogged about ebola data API experiments going on at HDX An API for Ebola Data. This is a high level API which does not cover the information modeled in this Outbreak Time Series Specification. Hopefully, we can work with the on deploying the Outbreak Dashboard API there.

As CJ Hendrix wrote:

HDX maintains a dataset of top line figures for the Ebola crisis. It contains information for six indicators:
Cumulative Cases of Ebola
Cumulative Deaths from Ebola
Open Ebola Treatment Centers
People Receiving Food Aid
Appeal Coverage
Currently Affected Countries

A link to the HTML page of an example dataset is provided. Look for the "DATA API" button for more info. There the following text can be found.

Query (via SQL)	http://data.hdx.rwlabs.org/api/action/datastore_search_sql
Query example (via SQL statement)
http://data.hdx.rwlabs.org/api/action/datastore_search_sql?sql=SELECT * from "a02903a9-022b-4047-bbb5-45127b591c85" WHERE title LIKE 'jones'

Yowza! That looks dangerous. A malicious hacker might want to know about that!

Moving on. Sample code is provided that demonstrates hot to use the API in JavaScript.

A simple ajax (JSONP) request to the data API using jQuery.
  var data = {
    resource_id: 'a02903a9-022b-4047-bbb5-45127b591c85', // the resource id
    limit: 5, // get 5 results
    q: 'jones' // query for 'jones'
    url: 'http://data.hdx.rwlabs.org/api/action/datastore_search',
    data: data,
    dataType: 'jsonp',
    success: function(data) {
      alert('Total results found: ' + data.result.total)

To fetch the full 6 values:


This URL will fetch just the appeal coverage:

http://data.hdx.rwlabs.org/api/action/datastore_search?resource_id=a02903a9-022b-4047-bbb5-45127b591c85&q=appeal coverage

The heart of that response looks like (heavily edited down):

"title":"Appeal Coverage",
"source":"OCHA FTS",

So, basically an association of Simon Johnson's Ebola Financial Tracking Dashboard and the source of the data for that dashboard.

The HDX ebola dashboard

URL: https://data.hdx.rwlabs.org/ebola
GitHub repo: https://github.com/OCHA-DAP/hdxviz-ebola-cases-total

Internally the visualization app is called ebolaVizApp. AngularJS and C3.js (et ergo D3.js) are used.

The ebolaVizApp's code is at:

The raw JSON data that ebolaVizApp reads is at


The SQL seems to be:

SELECT \"Indicator\", \"Date\", \"Country\", value FROM \"f48a3cf9-110e-4892-bedf-d4c1d725a7d1\" 
WHERE \"Indicator\"='Cumulative number of confirmed, probable and suspected Ebola deaths' OR \"Indicator\"='Cumulative number of confirmed, probable and suspected Ebola cases' 
ORDER BY \"Date\"

i.e. for case and deaths, get Indicator(text), Date(timestamp), Country(text)

The data is fetched via HTTP POST. Here's the curl command for that:

curl 'https://data.hdx.rwlabs.org/api/3/action/datastore_search_sql' --data $'%7B%22sql%22%3A%22SELECT%20%5C%22Indicator%5C%22%2C%20%5C%22Date%5C%22%2C%20%5C%22Country%5C%22%2C%20value%20FROM%20%5C%22f48a3cf9-110e-4892-bedf-d4c1d725a7d1%5C%22%20WHERE%20%5C%22Indicator%5C%22%3D\'Cumulative%20number%20of%20confirmed%2C%20probable%20and%20suspected%20Ebola%20deaths\'%20OR%20%5C%22Indicator%5C%22%3D\'Cumulative%20number%20of%20confirmed%2C%20probable%20and%20suspected%20Ebola%20cases\'%20ORDER%20BY%20%5C%22Date%5C%22%22%7D' 

That can be run through Apache Spark to detect the schema:

scala> :paste
val aSqlContext = new org.apache.spark.sql.SQLContext( sc )
val hdxData = aSqlContext.jsonFile( "hdx_ebola_dashboard_data.json" )
 |-- help: string (nullable = true)
 |-- result: struct (nullable = true)
 |    |-- fields: array (nullable = true)
 |    |    |-- element: struct (containsNull = false)
 |    |    |    |-- id: string (nullable = true)
 |    |    |    |-- type: string (nullable = true)
 |    |-- records: array (nullable = true)
 |    |    |-- element: struct (containsNull = false)
 |    |    |    |-- Country: string (nullable = true)
 |    |    |    |-- Date: string (nullable = true)
 |    |    |    |-- Indicator: string (nullable = true)
 |    |    |    |-- value: double (nullable = true)
 |    |-- sql: string (nullable = true)
 |-- success: boolean (nullable = true)

Where Indicator will be either:

  • "Cumulative number of confirmed, probable and suspected Ebola cases"
  • "Cumulative number of confirmed, probable and suspected Ebola deaths"

So, essentially it returns a flat list in the form of:

  "Indicator":"Cumulative number of confirmed, probable and suspected Ebola cases",
  "Indicator":"Cumulative number of confirmed, probable and suspected Ebola deaths",

That is, for each (country,day) there are two objects, one for deaths and one for cases. There is only one date per week, so this is a weekly report.

The server code that generates this data fetches is from scraperwiki.com:

Simon Johnson

Simon's work is some of the very best on the Web for ebola outbreak and response.

For The Ebola Timeline Map he used JSON.


var totalCasesAndDeaths = [{"Date":"31/03/2014","newCases":46,"newDeaths":25},


var regionCases = [	

Liberia's site


This is good work. This is an excellent example for how this should be done. The map is implemented via CartoDB, an high quality service.

The interesting part: they have a separate counter for "hcw" i.e. Health Care Workers. This brings in a whole new dimension to the data, sub-sets of a population. The API will need to handle this in an expandable way. For example, perhaps the breakdown is "male" and "female" and "child." Point is the API needs to be able to allow use of arbitrary labels for subsets. (Call these "population-id" or such? Dunno.)

They also have percentage change fields, e.g. 'pct_change_death_hcw'. Herm, that seems like a derivable number. Not sure if that should go in the API.

One of the maps on that site seems to use this dataset: https://unc-crisis-team.cartodb.com/viz/374d1302-3140-11e4-9ca7-0edbca4b5057/public_map

The datafeed URL is http://ebolainliberia.org/data/export_main_weekly.json. That returns a JSON object for each weekly situation report. Pretty printed, each looks like:

cases_cum_probable: 2104,
deaths: 16,
hc_workers: null,
total_deaths_suspected: 658,
auto_new_deaths: null,
hcw_cases_cum: 226,
sit_rep__day_of_year: 291,
CFR: "66",
new_weekly_deaths: 280,
new_deaths_confirmed: null,
location__slug: "national",
new_deaths_probable: null,
total_deaths_confirmed: 1235,
total_deaths_probable: 801,
hcw_deaths_cum: 101,
total_deaths_all: 2694,
pct_change_cases: 55.56,
cases_cum_confirmed: 959,
new_weekly_deaths_hcw: 8,
location__name: "National",
cases_cum_suspected: 1594,
hcw_cases_new: 2,
new_weekly_cases_hcw: 20,
sit_rep__date: "2014-10-18",
pct_change_death: 30.23,
new_weekly_cases: 448,
pct_change_death_hcw: 700,
cases_new_confirmed: 7,
cases_new_suspected: 37,
new_deaths_suspected: null,
cases_cum: 4657,
hcw_deaths_new: 0,
cases_new_total: 64,
pct_change_cases_hcw: 25,
cases_new_probable: 20

They also have JSON for a weekly drilldown:

This has detailed data for each county, for example

new_weekly_cases: [
cases_cum: 2073,
location__name: "Montserrado County",
hcw_cases_cum: 94,
hcw_deaths_cum: 34,
total_deaths_all: 1369,
new_weekly_deaths: [

New York Times

The New York Times ebola visualization uses 3 URLs for JSON data about the outbreak.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.