3.1.0 • Published 4 years ago

@justalk/covid19ph-api v3.1.0

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Alt text

Last version npm Last version Node version Travis Coverage Status Dependency status Last version XO code style

Star the project

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

methodurldescriptionexample
GET/casesReturn the list of all casesLive Version
GET/cases/totalReturn the total number of cases in PhilippinesLive Version
GET/cases/cities/availableReturn the list of all cities affectedLive Version
GET/cases/regions/availableReturn the list of all region affectedLive Version
GET/cases/status/availableReturn the list of all status possibleLive 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
paramstypedescriptionexample
limitnumberthe limit of the resultLive Version
skipnumberskip a number of resultLive Version
sort_keynumberthe key use for sorting the result (can only work if sort_order is also defined)Live Version
sort_ordernumberthe order of the result : 1 for ascending or -1 for descending (can only work if sort_key is also defined)Live Version
agenumberthe exact age of the casesLive Version
age_uppernumberUpper limit for ageLive Version
age_lowernumberLower limit for ageLive Version
sexstringAll the cases with a certain sex : 'M' or 'F'Live Version
pregnantbooleanAll the cases pregnant : true or falseLive Version
quarantinedbooleanAll the cases quarantined : true or falseLive Version
statusstringAll the cases with the same status : List of status availableLive Version
citystringAll the cases in the same city : List of city availableLive Version
regionstringAll the cases in the same region : List of region availableLive Version
date_start_casedate (format: MM/DD/YYYY)All the cases started at an exact dateLive Version
date_start_case_beforedate (format: MM/DD/YYYY)All the cases started before an exact dateLive Version
date_start_case_afterdate (format: MM/DD/YYYY)All the cases started after an exact dateLive Version
date_result_releasedate (format: MM/DD/YYYY)All the cases with the result released at an exact dateLive Version
date_result_release_beforedate (format: MM/DD/YYYY)All the cases with the result released before an exact dateLive Version
date_result_release_afterdate (format: MM/DD/YYYY)All the cases with the result released after an exact dateLive Version
date_result_positivedate (format: MM/DD/YYYY)All the cases with a positive result at an exact dateLive Version
date_result_positive_beforedate (format: MM/DD/YYYY)All the cases with a positive result before an exact dateLive Version
date_result_positive_afterdate (format: MM/DD/YYYY)All the cases with a positive result after an exact dateLive Version
date_recoverdate (format: MM/DD/YYYY)All the cases who recover at an exact dateLive Version
date_recover_beforedate (format: MM/DD/YYYY)All the cases who recover before an exact dateLive Version
date_recover_afterdate (format: MM/DD/YYYY)All the cases who recover after an exact dateLive Version
date_dieddate (format: MM/DD/YYYY)All the cases who died at an exact dateLive Version
date_died_beforedate (format: MM/DD/YYYY)All the cases who died before an exact dateLive Version
date_died_afterdate (format: MM/DD/YYYY)All the cases who recover after an exact dateLive 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
  1. Download the notice PDF from DOH : http://bit.ly/DataDropPH
  2. Parse the file for finding the link of the google drive where the datas are uploaded
  3. Download the csv file with the data
  4. Fill up the database used by the API
  1. The api first check what is the parameter send and if it's a valid parameter (libs)
  2. The api then build the filter that gonna be use by mongodb (services)
  3. The api then return the result (dbs)

How to install the development version ?

  1. Cloning the repository
git cloning https://github.com/JustalK/COVID19PH-API.git
  1. Install all the dependencies
npm install
  1. 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
  1. 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.

  1. Activate on the google console the google drive API

License

MIT - Copyright © JUSTAL Kevin