BlogAtlas Vector Search voted most loved vector database in 2024 Retool State of AI reportLearn more >>
MongoDB Developer
Sign in to follow topics
MongoDB Developer Centerchevron-right
Developer Topicschevron-right

A Free REST API for Johns Hopkins University COVID-19 dataset

Maxime Beugnet5 min read • Published Feb 14, 2022 • Updated Nov 16, 2023
ServerlessPostman APIAtlasApp Services
Facebook Icontwitter iconlinkedin icon
Rate this article


Here is the REST API Documentation in Postman.


November 15th, 2023

  • John Hopkins University (JHU) has stopped collecting data as of March 10th, 2023.
  • Here is JHU's GitHub repository.
  • First data entry is 2020-01-22, last one is 2023-03-09.
  • Current REST API is implemented using Third-Party Services which is now deprecated.
  • Hosting the REST API honestly isn't very valuable now as the data isn't updated anymore and the entire cluster is available below.
  • The REST API will be removed on November 1st, 2024; but possibly earlier as it's currently mostly being queried for dates after the last entry.

December 10th, 2020

  • Added 3 new calculated fields:
    • confirmed_daily.
    • deaths_daily.
    • recovered_daily.

September 10th, 2020


There are two big advantages to using this cluster, rather than directly using JHU's CSV files:
  • It's updated automatically every hour so any update in JHU's repo will be there after a maximum of one hour.
  • You don't need to clean, parse and transform the CSV files, our script does this for you!
The MongoDB Atlas cluster is freely accessible using the user readonly and the password readonly using the connection string:
You can use this cluster to build your application, but what about having a nice and free REST API to access this curated dataset?!


You can use the button in the top right corner Run in Postman to directly import these examples in Postman and give them a spin.
Run in Postman button in the Postman documentation website
One important detail to note: I'm logging each IP address calling this REST API and I'm counting the numbers of queries per IP in order to detect abuses. This will help me to take actions against abusive behaviours.
Also, remember that if you are trying to build an application that helps to detect, understand or stop the spread of the COVID-19 virus, we have a FREE MongoDB Atlas credit program that can help you scale and hopefully solve this global pandemic.

But how did I build this?

Simple and easy, I used the MongoDB App Services Third-Party HTTP services to build my HTTP webhooks.
Third-Party Services are now deprecated. Please use custom HTTPS Endpoints instead from now on.
Each time you call an API, a serverless JavaScript function is executed to fetch your documents. Let's look at the three parts of this function separately, for the Global & US webhook (the most detailed cllection!):
  • First, I log the IP address each time a webhook is called. I'm using the IP address for my _id field which permits me to use an upsert operation.
  • Then I retrieve the query parameters and I build the query that I'm sending to the MongoDB cluster along with the projection and sort options.
  • Finally, I build the answer with the documents from the cluster and I'm adding a Contact header so you can send us an email if you want to reach out.
Here is the entire JavaScript function if you want to copy & paste it.
One detail to note: the payload is limited to 1MB per query. If you want to consume more data, I would recommend using the MongoDB cluster directly, as mentioned earlier, or I would filter the output to only the return the fields you really need using the hide_fields parameter. See the documentation for more details.


Here are a couple of example of how to run a query.
  • With this one you can retrieve all the metadata which will help you populate the query parameters in your other queries:
  • The covid19.global_and_us collection is probably the most complete database in this system as it combines all the data from JHU's time series into a single collection. With the following query, you can filter down what you need from this collection:
Again, the REST API documentation in Postman is the place to go to review all the options that are offered to you.

Wrap Up

I truly hope you will be able to build something amazing with this REST API. Even if it won't save the world from this COVID-19 pandemic, I hope it will be a great source of motivation and training for your next pet project.
Send me a tweet with your project, I will definitely check it out!
If you have questions, please head to our developer community website where the MongoDB engineers and the MongoDB community will help you build your next big idea with MongoDB.

Facebook Icontwitter iconlinkedin icon
Rate this article

How to Get MongoDB Data into Parquet in 10 Seconds or Less

Jun 28, 2023 | 5 min read
Code Example


Jul 07, 2022 | 3 min read

Atlas 5-Year Anniversary Podcast Series Episode 1 - Onramp to Atlas

Aug 17, 2023 | 22 min

How to Use Custom Archival Rules and Partitioning on MongoDB Atlas Online Archive

May 31, 2023 | 5 min read
Table of Contents
  • TL;DR