COVID-19 Time Series API

This API was originally developed to show a JSON representation of the Johns Hopkins time series CSVs, located here. As JHU changed course several times, causing problems for developers everywhere, other humans rose to the challenge to maintain the original data in the same format. However, that proved to also be challenging, as recovery data is not reliable or being reported at all in some areas, making tracking active cases very difficult.

After many days/nights of fighting to use these publicly available CSVs on the fly, it became clear that the data should be stored locally, and new data scraped nightly from the web-data branch of the JHU repo. That has also come with its own challenges, as some locations are not reporting recovery data at all.

So, how is there recovery data for all locations in this dataset? For the locations that are not reporting recovery data at all, that data is being estimated based on a 21-day recovery time* and factoring in the current mortality rate of the virus for that location.

The data for each location is represented as a time series starting at the first day that location reported data. So, not all locations have the same set of dates/days. Included in the dataset is the date and day number, to make things easier.

For a practical example using this API, check out Comparing the Curve.

All the Data

If you want all countries, and all states/provinces, and all of their data, just grab it here. Please cache this, if you can, as the payload is not small, and will only continue to grow.

/API/All

Wow, That's A Lot

Yeah, it really is. If you are writing an app that just needs the most recent day, and not the whole time series, you can use the following. Please note, though, that this is not real time data, and you're probably best off using the web-data branch of the JHU data to get the most recent data. Theirs is updated throughout each day.

/API/MostRecent

Filtering by Country

There are a couple of ways to filter by Country. First thing you might need is a list of those countries and their states/provinces:

/API/Countries

To filter by country, you can do one of the following:

/API/Filter?country=US
or
/API/Filter/US

Filtering by Country and State/Province

If you want to get the data for a particular state or province only, you can do so like this:

/API/Filter?country=US&state=New+York
or
/API/Filter/US/New%20York

So, what am I looking at?

In general, the API is going to return either an array of JSON Location objects, or a singular JSON Location object, if you are filtering by those. Each Location object will have an array of JSON DateData objects, and, for convenience, a single JSON DateData object for the most recent data. It looks kind of like this:

Location Object

{
  "name": "US",
  "latitude": -74.9481,
  "longitude": 42.1657,
  "isEstimated": true,
  "mostRecent": {DateData},
  "data": [DateData],
  "states": [Location]
}

DateData Object

{
  "date": "2020-03-31T23:54:15.2710123",
  "sDate": "3/31/2020",
  "dayNumber": 66,
  "cases": 8527,
  "newCases": 1099,
  "active": 6834,
  "newActive": 514,
  "changeActive": 0.0813291147,
  "deaths": 101,
  "newDeaths": 13,
  "recoveries": 1592,
  "newRecoveries": 572
}

But, I really liked those CSVs

Yeah, they were really handy when they were consistent. Thankfully, it wasn't too hard to re-generate them, with a bonus one for active cases. Each country (even those that have states) will also have its own line, unlike the original CSVs.

/CSV/Confirmed
/CSV/Deaths
/CSV/Recovered
/CSV/Active

Created By: Kent Pytlik

Data provided by Johns Hopkins University, located here.

*Recoveries are estimated for locations not reporting recovery data based on a 21-day recovery time from a confirmed positive test and factoring in the current mortality rate of the virus for that location. This is obviously a subjective number. It is based on most experts saying the recovery time is somewhere between 2-3 weeks and erring on the side of caution.