See NYT for data: https://github.com/nytimes/covid-19-data
npm install covid-usa
or
"dependencies": {
"covid-usa": "2.1.1"
}
var covidData = require("covid-usa");
// latest state level by date
covidData.stateData(stateDate => {
console.log(stateData["2020-03-20"]["California"].cases);
console.log(stateData["2020-03-20"]["California"].deaths);
console.log(stateData["2020-03-20"]["California"].fid);
console.log(stateData["2020-03-20"]["Massachusetts"]["Middlesex"].cases);
});
// list of all states in dataset
covidData.allStates(states => {
...
});
// map of each state to list of counties in dataset
covidData.countiesByState(countiesByState => {
console.log(countiesByState["California"])
});
// list of all counties in a state in the dataset
covidData.allCounties("California", counties => {
...
});
// county level data by date
covidData.countyData(countyData => {
console.log(countyData["2020-03-10"]["Middlesex"].cases);
});
// cached APIs to avoid redownloading latest data from NYT
var cachedStateData = covidData.stateDataCached();
var cachedCountyData = covidData.countyDataCached();