Skip to content

amazingshellyyy/covid19-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Covid19 Open API (Stop updating on Sep 16th)

Covid19 Open API

This API currently collects California, New York, Washington states' counties' data with confirmed cases and deaths numbers. We are working on datas for other states' county as well.

*2020 Mar 30 updates: start collecting US states data which includes 50 U.S states, 1 federal disctrict, and 5 inhabited territories.

  • County Data is updated twice every day at 9am UCT and 3pm UCT!
  • State Data is updated everyday at 12pm UCT!

⭐Please star this repo to support my effort! Thank you so much!⭐

For state timeseries data:

  • Request method: GET
  • Endpoint:
https://amazingshellyyy.com/covid19-api/<country-code>/statesTimeseries.json

For county timeseries data:

  • Request method: GET
  • Endpoint:
https://amazingshellyyy.com/covid19-api/<country-code>-<subvisions-code>/countyTimeseries.json

List

Specifications

< country-code>

< subdivisions-code>

Using axios

import axios from 'axios';
axios.get('https://amazingshellyyy.com/covid19-api/US-CA/countyTimeseries.json')
      .then(res => {
        console.log('covid CA County data',res.data)
      })
      .catch(err => {
        console.log(err)
      })

Sample Data

Sample | State Timeseries data:

The JSON contains timeStamp (stored in milliseconds) and array of states' cases with objects of each state and its name, cases, and deaths.

[
  {
    "timeStamp": 1585618844246,
    "data": [
      {
        "state": "Alabama",
        "case": 827,
        "death": 4
      },
      {
        "state": "Alaska",
        "case": 102,
        "death": 2
      },
      {
        "state": "American Samoa",
        "case": 0,
        "death": 0
      },
      ...
    ]
  }
  ...
]

Sample | County Timeseries data:

The JSON contains timeStamp (stored in milliseconds) and array of counties' cases with objects of each county and its name, cases, and deaths.

[
  {
    "timeStamp": 1584367447000,
    "data": [
      {
        "county": "Santa Clara",
        "case": 114,
        "death": 2
      },
      {
        "county": "Los Angeles",
        "case": 69,
      "death": 1
      },
      {
        "county": "San Francisco",
        "case": 37,
        "death": 0
      },
      ...
    ]
  }
  ...
}

Notes

  • US state wide data is missing on Mar 26th. Be awared that there might be a gap.
  • In California county data, Yuba and Sutter reported their cases together at one resource before March 25 so part of the data look like this:
      ...
      {
        "county": "Yuba/Sutter",
        "case": 3,
        "death": 0
      },
      ...
  • some data in Washinton State is hasn't been assigned to any county therefore the county name will be "(Unassigned)":
      ...
      {
        "county": "(Unassigned)",
        "case": 160,
        "death": 0
      }
      ...

Some visualization done with this API

Mapitout: https://mapitout.github.io/#/covid19

*Please submit an issue if you would like to put your project here. :)

resource

Contribute to data collecting

  1. Run the following command at the root level
  • replace stateCode to the state's Code you want to create
$ mkdir ./docs/US-<stateCode>
$ touch ./docs/US-<stateCode>/countyTimeseries.json
$ echo "[]" >> ./docs/US-<stateCode>/countyTimeseries.json
  1. Run the following command to test with the getDataTest() function. getDataTest(stateCode, url, selector, countyIndex, caseIndex, deathIndex)
  • e.g.
    • for NJ Data:
      getCountyData('NJ','https://en.wikipedia.org/wiki/2020_coronavirus_pandemic_in_New_Jersey', '.sortable tbody tr[class!=sortbottom]', 1,3,5);
    • for NY Data:
      getCountyData('NY','https://en.wikipedia.org/wiki/2020_coronavirus_pandemic_in_New_York_(state)', '.sortable tbody tr[class!=sortbottom]', 1,3,5);
$ echo "getCountyData(a,b,c,d,e,f)" >> ./getData/test.js
$ node ./getData/test.js
  1. Check countyTimeseries.json in ./docs/US-stateCode and see if the data is there and correct.

  2. run follow command to remove the testing code from test.

$ echo "const { getCountyData } = require('./getData.js');" > ./getData/test.js
  1. call the function in the run file and it will automatically run every hour.
$ echo "getCountyData(a,b,c,d,e,f).then(successCallback, failureCallback);" >> ./getData/run.js