Miss any of our Open RFC calls?Watch the recordings here! »

covid-usa

2.1.1 • Public • Published

Build NPM version NPM Downloads

covid-usa

Import the latest US Covid data in JS

See NYT for data: https://github.com/nytimes/covid-19-data

Usage:

Add to package.json

npm install covid-usa

or

"dependencies": {
    "covid-usa": "2.1.1"
}

Access the data

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();

Install

npm i covid-usa

DownloadsWeekly Downloads

2

Version

2.1.1

License

MIT

Unpacked Size

11.8 kB

Total Files

7

Last publish

Collaborators

  • avatar