@justalk/covid19ph-api
v3.1.0
Published
API for COVID 19 Cases in the Philippines
Downloads
8
Maintainers
Readme
API for COVID 19 Cases in the Philippines from DOH last update. Get all the informations about the cases in the Philippines in a JSON format. A running live version of the system is available here : Live Version
Features
DOH data download: Download automatically the latest datas from DOH
Powerfull API: Complete and fast API for the covid in Philippines
Flexible API: With many parameter, it's easy to build your application around it
API
| method | url | description | example | | :--- | :---- | :---------- | :------ | | GET | /cases | Return the list of all cases | Live Version | | GET | /cases/total | Return the total number of cases in Philippines | Live Version | | GET | /cases/cities/available | Return the list of all cities affected | Live Version | | GET | /cases/regions/available | Return the list of all region affected | Live Version | | GET | /cases/status/available | Return the list of all status possible | Live Version |
The parameter are query parameter. They can be chain as the example under :
http://13.250.29.32:5000/cases?limit=1&age_lower=20&status=RECOVERED
| params | type | description | example | | :--- | :---- | :---------- | :------ | | limit | number | the limit of the result | Live Version | | skip | number | skip a number of result | Live Version | | sort_key | number | the key use for sorting the result (can only work if sort_order is also defined) | Live Version | | sort_order | number | the order of the result : 1 for ascending or -1 for descending (can only work if sort_key is also defined) | Live Version | | age | number | the exact age of the cases | Live Version | | age_upper | number | Upper limit for age | Live Version | | age_lower | number | Lower limit for age | Live Version | | sex | string | All the cases with a certain sex : 'M' or 'F' | Live Version | | pregnant | boolean | All the cases pregnant : true or false | Live Version | | quarantined | boolean | All the cases quarantined : true or false | Live Version | | status | string | All the cases with the same status : List of status available | Live Version | | city | string | All the cases in the same city : List of city available | Live Version | | region | string | All the cases in the same region : List of region available | Live Version | | date_start_case | date (format: MM/DD/YYYY) | All the cases started at an exact date | Live Version | | date_start_case_before | date (format: MM/DD/YYYY) | All the cases started before an exact date | Live Version | | date_start_case_after | date (format: MM/DD/YYYY) | All the cases started after an exact date | Live Version | | date_result_release | date (format: MM/DD/YYYY) | All the cases with the result released at an exact date | Live Version | | date_result_release_before | date (format: MM/DD/YYYY) | All the cases with the result released before an exact date | Live Version | | date_result_release_after | date (format: MM/DD/YYYY) | All the cases with the result released after an exact date | Live Version | | date_result_positive | date (format: MM/DD/YYYY) | All the cases with a positive result at an exact date | Live Version | | date_result_positive_before | date (format: MM/DD/YYYY) | All the cases with a positive result before an exact date | Live Version | | date_result_positive_after | date (format: MM/DD/YYYY) | All the cases with a positive result after an exact date | Live Version | | date_recover | date (format: MM/DD/YYYY) | All the cases who recover at an exact date | Live Version | | date_recover_before | date (format: MM/DD/YYYY) | All the cases who recover before an exact date | Live Version | | date_recover_after | date (format: MM/DD/YYYY) | All the cases who recover after an exact date | Live Version | | date_died | date (format: MM/DD/YYYY) | All the cases who died at an exact date | Live Version | | date_died_before | date (format: MM/DD/YYYY) | All the cases who died before an exact date | Live Version | | date_died_after | date (format: MM/DD/YYYY) | All the cases who recover after an exact date | Live Version |
- The live version has a limit of 1000 cases showing by default. The limit can be change to higher value by setting the value parameter.
- The sort_key and sort_order has to be use together for working.
- The parameters can be mixed together for mixing your particular query.
- The datas are updated every week.
- Some datas fields can be empty because the datas from DOH are let with empty field.
How does it work ?
The cron has been set in the crontab with this setting :
crontab -e
0 0 * * * curl http://0.0.0.0:5000/cron/cases
- Download the notice PDF from DOH : http://bit.ly/DataDropPH
- Parse the file for finding the link of the google drive where the datas are uploaded
- Download the csv file with the data
- Fill up the database used by the API
- The api first check what is the parameter send and if it's a valid parameter (libs)
- The api then build the filter that gonna be use by mongodb (services)
- The api then return the result (dbs)
How to install the development version ?
- Cloning the repository
git cloning https://github.com/JustalK/COVID19PH-API.git
- Install all the dependencies
npm install
- Create an environnement file and fill up the information missing depending of your system
NODE_ENV=production
API_NAME=COVID19-PH
HOST=localhost
PORT=5000
CASES_LIMIT_GETTER=1000
DB_NAME=
DB_URI_DATA=
DB_URI_LOG=
DB_USER_DATA=
DB_PASS_DATA=
DB_HOST_LOG=
DB_PORT_LOG=
DB_NAME_LOG=
DB_USER_LOG=
DB_PASS_LOG=
- NODE_ENV: The type of the environnement file
- API_NAME: The name of the API
- HOST: The host of the API
- PORT: The port of the API
- CASES_LIMIT_GETTER: The limit of cases that can be fetch without params
- DB_NAME: The name of the database
- DB_URI_DATA: The url of the database
- DB_URI_LOG: The url of the log of the database
- DB_USER_DATA: The user of the database
- DB_PASS_DATA: The pass of the database
- Create a google credential secret file form the developer file :
{
"type": "service_account",
"project_id": "",
"private_key_id": "",
"private_key": "",
"client_email": "",
"client_id": "",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": ""
}
For not sending the key to everyone, I am using the secrethub, so the file is not present inside the repository.
- Activate on the google console the google drive API
License
MIT - Copyright © JUSTAL Kevin