UPDATES TO THIS PROJECT ENDED 2020-07-08

covid19js

Latest data

Coronavirus COVID-19 outbreak data with zero dependencies, for web developers.

Data is generated from 2019 Novel Coronavirus COVID-19 (2019-nCoV) Data Repository by Johns Hopkins CSSE

Updated often and easy to use.

View on Github

Getting Started

Include this line in the head of your html page:

<script src="https://covid19js.com/dist/covid19.js"></script>

Afterwards you can use the covid19 data in your javascript

var data = covid19.data();
data.latest().totals();

Use covid19.data() to create a new clean copy of the data

var data = covid19.data();

Use latest() to get data for the most recent date

data.latest();

List of dates, continents, countryRegions, locations

var data = covid19.data();

Filter as you would with any javascript array

data.latest().filter(x=>x.country_region==="US");
data.latest().filter(x=>x.country_region==="US").totals();

Filter for leaflet map bounds

var bounds = L.latLngBounds(
        L.latLng(6.7499552751, 36.619987291),
        L.latLng(18.4802470232, 47.1153931748));
data.filter(x=>bounds.contains(L.latLng(x.lat,x.lng)));

Group by continent (must filter to a single date first)

data.latest().groupByContinent();

Group by country (must filter to a single date first)

data.latest().groupByCountryRegion();

Group by date with or without filtering first

data.filter(x=>x.country_region==="US").groupByDate();
data.groupByDate();

Promise based refresh to get updated data from server

Max once per minute, reasonably efficient by fetching change timestamp first.

covid19.refresh().then(data=>{
    console.log(covid19.last_updated);
    console.log(data.latest().groupByLocation())
});