/covid-usa

USA data for coronavirus from NYT CSV as a JS library

Primary LanguageJavaScriptMIT LicenseMIT

Build NPM version NPM Downloads

covid-usa

Import the latest US Covid data in JS

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