This is an API for the Novel Coronavirus (COVID-19) Statistics.
Source of data for this API is Johns Hopkins University Center for Systems Science and Engineering (JHU CSSE) Github Repository.
Using API, you can search COVID-19 confirmed, death and recovered cases all around the world.
API is hosted with support of Heroku and MongoDB Atlas at https://covid19-stats-api.herokuapp.com . First API call takes time as Heroku moves inactive apps into sleep mode.
- Docker
- Docker Compose
- Internet connection
-
Navigate to the project root directory where
docker-compose.yml
file is present. -
Run the following command in the same folder via terminal. It deploys the server using
docker-compose
.docker-compose up -d --force-recreate
Where:
- up creates and starts containers
- -d daemon mode
- --force-recreate Re-creates containers if there any
-
Your server would be running at port
3000
onlocalhost
- docker-compose logs shows logs from all containers
- docker logs <container_name> shows logs from selected container
- docker-compose down <container_name> removes existing containers
- Node (Tested with v12.13.1)
- MongoDB (Tested with v4.2)
- Internet connection
For MongoDB, I have used official Docker image, you can either use the same or install direcly on your system. Default configuration used in project assumes everything default with the Docker image, if you want to change any configuration, change it in your environment specific file in config
folder.
"dbHost": "production-db-host",
"dbPort": "production-db-port",
"dbName": "production-db-name",
"dbUsername": "production-db-username",
"dbPassword": "production-db-password"
MongoDB configuration can also be provided by environment variable db_connection_string
. If this is provided we skip all the above defined config variables.
There is no need to configure any collection and documents in MongoDB. To start the server, please run following command while being at root of project
npm install
node index.js
This will start a server at port 3000
on localhost
.
If you want to use different port or any other configuration, you can update the same in config file under config
folder. Here each file represents different config sets and can be chosen by setting NODE_ENV
environment variable before starting the server. for e.g.
NODE_ENV=development node index.js
-
Make GET request to below url via Postman, for more details visit below section. You can also get this data via opening this link in browser.
http://localhost:3000/
-
Populate base data by calling below endpoint
http://localhost:3000/api/v1/refresh
-
To get your data, visit
http://localhost:3000/api/v1/cases
Public Documentation has been made available. Here is a button to import the same and test. Case types are confirmed, deaths and recovered. Open API 3 Spec is present in repo with name open-api-3-spec.yml
.
baseurl = http://localhost:3000/api/v1
-
Get information on all types of cases for all countries
endpoint = /cases
-
Get information on all types of cases for particular country
endpoint = /cases?country=countryname example: /cases?country=India
-
Get information about particular case for all countries
endpoint = /cases/country/:casetype example: /cases/country/confirmed
-
Get information about particular case found in all states of differnt countries
endpoint = /cases/state/:casetype example: /cases/state/confirmed
-
Get information about particular case found in all states of particular countries
endpoint = /cases/state/:casetype?country=countryname example: /cases/state/confirmed?country=India
-
To Refresh COVID-19 server data with latest data provided by JHU CSSE
endpoint = /refresh