Home

Awesome

Covid-19-API-Philippines-DOH (Beta)

CodeFactor Grade GitHub Workflow Status License Last Commit Stars Forks Tweet

Covid-19 Web API for Philippines from data collected by DOH using Node.js that automatically updates itself.

A Web API doesn't use web scraping to fetch data from DOH website instead it collects the data from the csv file from DOH Google Drive. This means that even if DOH website changes this API will be able to maintain itself.

<br>
<br>

📌 Endpoints

Base URL

(MAIN): https://covid19-api-philippines.herokuapp.com/

(Optional) https://covid19-ph-api.herokuapp.com/ 🆕

Documentation in POSTMAN are available here

<br>

Get list of all possible values for the specified field 🆕

datasets: case_information, facilities_information

(DEFAULT: case_information)

GET api/list-of/:field
GET api/list-of/:field?dataset=case_information

eg:
GET api/list-of/regions
GET api/list-of/age_groups

Case Information

<details> <summary><b><i>View Endpoints </i></b></summary> <br>

Fetching summary

GET api/summary
GET api/summary?region={region}
<details> <summary><i>Example Response</i></summary>
{
  "data": {
    "total": 89374,
    "recoveries": 65064,
    "deaths": 1983,
    "active_cases": 22327,
    "fatality_rate": "2.22",
    "recovery_rate": "72.80"
  }
}
</details> <br>

Fetching Top Regions

GET api/top-regions
<details> <summary><i>Example Response</i></summary>
{
    "data": [
        {
            "region": "ncr",
            "cases": 115906,
            "recovered": 75658,
            "deaths": 1553
        },
        {
            "region": "region iv-a: calabarzon",
            "cases": 30489,
            "recovered": 17281,
            "deaths": 282
        },
        {...},
        {
            "region": "caraga",
            "cases": 490,
            "recovered": 298,
            "deaths": 4
        }
    ]
}
</details> <br>

Fetching No. of Cases Timeline

GET api/timeline
GET api/timeline?region={region_name}
<details> <summary><i>Example Response</i></summary>
{
  "data": [
    {
        "cases": 43,
        "recovered": 38,
        "died": 4,
        "date": "2020-03-01"
    },
    {
        "cases": 18,
        "recovered": 14,
        "died": 4,
        "date": "2020-03-02"
    },
    {...},
    {
        "cases": 2109,
        "recovered": 1992,
        "died": 12,
        "date": "2020-07-17"
    },
  ]
}
</details> <br>
<br>

Fetching raw data (Ordered by case_code) limit cannot exceed 10000

GET api/get?page=1&limit=10000

Fetching raw data by month

GET api/get?month=03

Fetching raw data by specific date

GET api/get?month=03&date=01

Fetching raw data with filters

GET api/get?region_res=ncr&age_group=20-24
<details> <summary><i>Example Response</i></summary>
{
    "data": [
        {
            "case_code": "C100018",
            "age": 53,
            "age_group": "50-54",
            "sex": "female",
            "date_specimen": "2020-04-30",
            "date_result_release": "2020-05-09",
            "date_rep_conf": "2020-05-11",
            "date_died": "",
            "date_recover": "",
            "removal_type": "recovered",
            "admitted": "no",
            "region_res": "Region IV-A: CALABARZON",
            "prov_res": "laguna",
            "city_mun_res": "city of san pedro",
            "city_muni_psgc": "PH043425000",
            "health_status": "recovered",
            "quarantined": "no",
            "date_onset": "",
            "pregnant_tab": "no"
        },
        {...}
    ],
    "pagination": {
        "next_page": 2,
        "limit": 10000,
        "max_page": 10
    },
    "result_count": 10000
}
</details> <br> </details>

Facilities Information <sup>🆕</sup>

<details> <summary><b><i>View Endpoints </i></b></summary> <br>

Fetching facilities summary

GET api/facilities/summary
<details> <summary><i>Example Response</i></summary>
{
    "data": {
        "total_facilities": 1912,
        "occupancy_rate": 0.49,
        "beds": {
            "total_vacant": 9945,
            "total_occupied": 9730,
            "covid": {
                "icu_v": 774,
                "icu_o": 831,
                "isolbed_v": 6638,
                "isolbed_o": 6240,
                "beds_ward_v": 2533,
                "beds_ward_o": 2659
            },
            "non_covid": {
                "icu_v_nc": 3345,
                "icu_o_nc": 2938,
                "nonicu_v_nc": 41335,
                "nonicu_o_nc": 42019
            }
        },
        "equipments": {
            "mechvent_v": 1537,
            "mechvent_o": 607,
            "mechvent_v_nc": 2399,
            "mechvent_o_nc": 2399
        }
    }
}
</details> <br>

Fetching list of facilities

GET api/list-of/hospitals?dataset=facilities_information
<details> <summary><i>Example Response</i></summary>
{
    "data": [
        {
            "name": "a. de la cruz maternity hospital"
        },
        {
            "name": "a. zarate general hospital"
        },
        {...},
        {
            "name": "zone medical and intervention hospital, inc."
        }
    ]
}
</details> <br>

Fetching raw facility/hospital records

GET api/facilities
GET api/facilities?region={region name}
GET api/facilities?hospital_name={hospital name}
<details> <summary><i>Example Response</i></summary>
{
    "data": [
        {
            "hfhudcode": "DOH000000000000410",
            "cf_name": "asian hospital inc.",
            "updated_date": "2020-08-13T16:05:30.000Z",
            "added_date": "2020-08-13T16:05:30.000Z",
            "report_date": "2020-08-13T00:00:00.000Z",
            "icu_v": 0,
            "icu_o": 16,
            "isolbed_v": 0,
            "isolbed_o": 69,
            "beds_ward_v": 0,
            "beds_ward_o": 0,
            "mechvent_v": 18,
            "mechvent_o": 28,
            "icu_v_nc": 10,
            "icu_o_nc": 14,
            "nonicu_v_nc": 72,
            "nonicu_o_nc": 55,
            "mechvent_v_nc": 18,
            "mechvent_o_nc": 28,
            "q_nurse": 37,
            "q_doctor": 7,
            "q_other": 68,
            "nurse_adm": 0,
            "doctor_adm": 1,
            "other_adm": 2,
            "susp_asym": 0,
            "susp_mild": 18,
            "susp_severe": 1,
            "susp_crit": 1,
            "susp_died": 0,
            "prob_asym": 0,
            "prob_mild": 1,
            "prob_severe": 0,
            "prob_crit": 0,
            "prob_died": 0,
            "conf_asym": 0,
            "conf_mild": 50,
            "conf_severe": 0,
            "conf_crit": 15,
            "conf_died": 1,
            "t_patient_adm": 2,
            "t_patient_er": 2,
            "t_patient_icu": 2,
            "trans_ttmf": 2,
            "discharged": 2,
            "region": "national capital region (ncr)",
            "region_psgc": "PH130000000",
            "province": "ncr, fourth district (not a province)",
            "province_psgc": "PH137600000",
            "city_mun": "city of muntinlupa",
            "city_mun_psgc": "PH137603000",
            "north_coord": "0.0",
            "east_coord": "0.0"
        },
        {...}
    ]
}
</details> <br> </details> <br>
<br>

Field and Values Reference

FieldTypeValuesCan be empty?
case_codeString(7)UNIQUE ID String with length of 7NO
ageInteger(3)1 - 3 digitsNO
age_groupString0-4, 5-9, 10-14, 15-19, 20-24, 25-29, 30-34, 35-39, 40-44, 45-49, 50-54, 55-59, 60-64, 65-69, 70-74, 75-79, 80+YES
sexStringmale, femaleNO
date_specimenDate(YYYY-MM-DD)Date(YYYY-MM-DD)YES
date_result_releaseDate(YYYY-MM-DD)Date(YYYY-MM-DD)YES
date_rep_confDate(YYYY-MM-DD)Date(YYYY-MM-DD)NO
date_diedDate(YYYY-MM-DD)Date(YYYY-MM-DD)YES
date_recoverDate(YYYY-MM-DD)Date(YYYY-MM-DD)YES
removal_typeStringrecovered, diedYES
admittedStringyes, noYES
region_res/regionStringBARMM, CAR, CARAGA, NCR, Region I: Ilocos Region, Region II: Cagayan Valley, Region III: Central Luzon, Region IV-A: CALABARZON, Region IV-B: MIMAROPA, Region IX: Zamboanga Peninsula, Region V: Bicol Region, Region VI: Western Visayas, Region VII: Central Visayas, Region VIII: Eastern Visayas, Region X: Northern Mindanao, Region XI: Davao Region, Region XII: SOCCSKSARGEN, REPATRIATEYES
prov_resStringabra, agusan del norte, agusan del sur, aklan, albay, antique, apayao, aurora, basilan, bataan, batangas, benguet, biliran, bohol, bukidnon, bulacan, cagayan, camarines norte, camarines sur, camiguin, capiz, catanduanes, cavite, cebu, city of isabela (not a province), cotabato (north cotabato) cotabato city (not a province), davao de oro, davao del norte, davao del sur, davao occidental, davao oriental, eastern samar, guimaras, ifugao, ilocos norte, ilocos sur, iloilo, isabela, kalinga, la union, laguna, lanao del norte, lanao del sur, leyte, maguindanao, marinduque, masbate, misamis occidental, misamis oriental, mountain province, ncr, negros occidental, negros oriental, northern samar, nueva ecija, nueva vizcaya, occidental mindoro, oriental mindoro, palawan, pampanga, pangasinan, quezon, rizal, romblon, samar (western samar), sarangani, siquijor, sorsogon, south cotabato, southern leyte, sultan kudarat, sulu, surigao del norte, surigao del sur, tarlac, tawi-tawi, zambales, zamboanga del norte, zamboanga del sur, zamboanga sibugay,YES
city_mun_resStringhttps://pastebin.com/EmP2MQDHYES
city_muni_psgcStringUnique ID (eg: PH012802000)YES
health_statusStringasymptomatic, critical, died, mild, recovered, severeNO
quarantinedStringyes, noYES
date_onsetDate(YYYY-MM-DD)Date(YYYY-MM-DD)YES
pregnant_tabStringyes, noYES
<br>
<br>

🔨 Installation

Prerequisites

Steps

  1. run the command:
$ npm install
  1. Create a Service Account and download the key.

  2. copy .env.example to .env and paste the service key and database credentials respectively

  3. Run the project in development:

$ npm run dev
  1. Done

NOTE: You use /api/updatedatabase to manually update database (in development mode)

<br>

API documentation:

Documentation in POSTMAN are available here

<br>
<br>

📄 About the Data

Where does the data come from?

<br>

🔧 Built With

<br>

Authors

<br>

Acknowledgments

<br>

Donate