
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: https://corona-stats.online/
Alternatively, you could try using the curl utility against the API from a CLI terminal with the following command:
curl https://corona-stats.online/
Source code for the API is available on GitHub at: https://github.com/sagarkarira/coronavirus-tracker-cli
There is a help endpoint that documents that functionality of the API fairly well: https://corona-stats.online/help
Try to limit that data by accessing a path defined by a country. For example, to limit the results to “just” the United States: https://corona-stats.online/US

For statistics about the United Kingdom, try: https://corona-stats.online/UK
It you only wanted statistics about Italy: https://corona-stats.online/italy
Confirmed Cases Graph
If you prefer a visual representation of the data, as opposed to table driven data, you can use:
https://corona-status.online/[countryName]/graph
or https://corona-status.online/[countryCode/graph
.
For example, the following link will return graph data for the United States: https://corona-stats.online/us/graph

corona-stats.online 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: https://corona-stats.online?top=25 Similarly, to return only the top 10 countries infected with the corona virus, you would query: https://corona-stats.online?source=1&top=10
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:
- John Hopkins University – Source 1 table: https://corona-stats.online?source=1
- WorldoMeters Data API (https://www.worldometers.info/coronavirus/) – Source 2: https://coronoa-stats.online?source=2
How does an API work?
Consider what happened when you made that “click”:
BROWSER coronoa-stats.online API
HTTPS GET / ----------------->
<----------------- 200 + HTML Table Data
First, your client (in this case, your browser) sends an HTTP GET to the corona-stats.online 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
- Corona Stats Online Help – https://corona-stats.online/help
- World Health Organization (WHO) – Coronavirus disease (COVID-19) Pandemic – https://www.who.int/emergencies/diseases/novel-coronavirus-2019
- Interacting with NASA APIs with Python – https://rzfeeser.com/2019/11/22/python-tutorial-interacting-with-nasa-restful-apis/
Recent Comments