COVID-19 virus statistics
Data pulled from on March 29, 2020. Today’s data reflects nearly 150,000 confirmed cases of COVID-19 within the United States. At the moment, everyone in the US has been advised to stay indoors, and promote social distancing.

One of my students showed me an API that returns near real-time data regarding the spread of COVID-19 (the “Corona Virus”). I’m not a medical p professional, but tracking COVID-19 virus statistics with code is a great way to remind yourself to practice good hygiene! In fact, think I might go wash my hands wright now!

Using your browser (client) send an HTTP GET to the API by clicking the link:

Alternatively, you could try using the curl utility against the API from a CLI terminal with the following command:


Source code for the API is available on GitHub at:

There is a help endpoint that documents that functionality of the API fairly well:

Try to limit that data by accessing a path defined by a country. For example, to limit the results to “just” the United States:

COVID-19 virus statistics by country
Data can be returned by the API per country by adding a /country or /countryCode path to the end of the API.

For statistics about the United Kingdom, try:

It you only wanted statistics about Italy:

Confirmed Cases Graph

If you prefer a visual representation of the data, as opposed to table driven data, you can use:[countryName]/graph or[countryCode/graph.

For example, the following link will return graph data for the United States:

COVID-19 virus statistics graph
Data can be returned in a visual graph format by adding /[countryName]/graph or /[countryCode/graph to the end of the API lookup. API Parameters

By using API parameters, COVID-19 virus statistics may be returned in other formats. Parameters also offer the user the ability to limit results. For this API, parameters are handled in a simple key=value fashion, within the GET itself. Unfortunately, at the time of writing, I haven’t been able to get the ?json=true parameter to work. For me, the API still returns HTML table data.

Getting the top N countries is as easy as including, ?top=N at the end of the API. For example, if you wanted to view only the top 25 countries infected with the corona virus, you would query: Similarly, to return only the top 10 countries infected with the corona virus, you would query:

By default, the API has multiple sources of data to draw from (at this time, two sources). A default source is always set, however, you can declare your own source with source=1 or source=2. For example, you can configure which source you want with:

How does an API work?

Consider what happened when you made that “click”:

BROWSER                 API

HTTPS GET /  ----------------->
             <-----------------  200 + HTML Table Data 

First, your client (in this case, your browser) sends an HTTP GET to the API. The API was designed to be ‘listening’ for HTTP GET messages, so the next step is the ‘acceptance’ of the GET by the API. Finally, the API returns an HTTP 200 with the HTML table data attached, populated with the current COVID-19 infection rates.

Links & References