Skip to content

Repository files navigation

NovelCovid

(aka covidapi)
A JavaScript Wrapper for the novelCOVID API

GitHub top languageSnyk Vulnerabilities for npm scoped packageGitHub package.json versionGitHub last commit
npm bundle sizenpm
GitHub issuesLicenseProfile visits


Disclaimer

This wrapper is only for COVID-19 related data from the Open Disease API.

Installation

NPM

Using NPM:

npm i -s novelcovid

Remarks

This wrapper uses the '@aero/centra' package to send requests. It is way faster than any other request package other than 'http.request' package.

The allowNull parameter is now available for the all, countries, continents, states and gov endpoints.

Usage

All shown examples use Promises but can also await/async to fetch data using NovelCovid.

Add to project

constapi=require('novelcovid');// you can choose which URL to use, this will not change the behaviour of the APIapi.settings({baseUrl: 'https://disease.sh'|'https://api.caw.sh'|'https://corona.lmao.ninja'})

Summary

// this prints a summary of global dataapi.all().then(console.log)// this prints a summary of global data with yesterdays dataapi.yesterday.all().then(console.log)// this prints a summary of global data with data from two days agoapi.twoDaysAgo.all().then(console.log)

Countries

// this prints an array of call infected countriesapi.countries().then(console.log)// this prints an array of call infected countries sorted by casesapi.countries({sort:'cases'}).then(console.log)// this prints a specified countryapi.countries({country:'austria'}).then(console.log)// this prints an array of specified countriesapi.countries({country:['austria','china']}).then(console.log)

Yesterday (Countries)

// this prints an array of all infected countries with yesterdays dataapi.yesterday.countries().then(console.log)// this prints an array of all infected countries with yesterdays data sorted by todays casesapi.yesterday.countries({sort:'cases'}).then(console.log)// this prints a specified country with yesterdays dataapi.yesterday.countries({country:'austria'}).then(console.log)// this prints an array of specified countries with yesterdays dataapi.yesterday.countries({country:['austria','china']}).then(console.log)

Two Days Ago (Countries)

// this prints an array of all infected countries with data from two days agoapi.twoDaysAgo.countries().then(console.log)// this prints an array of all infected countries with data from two days ago sorted by todays casesapi.twoDaysAgo.countries({sort:'cases'}).then(console.log)// this prints a specified country with data from two days agoapi.twoDaysAgo.countries({country:'austria'}).then(console.log)// this prints an array of specified countries with data from two days agoapi.twoDaysAgo.countries({country:['austria','china']}).then(console.log)

Continents

// this prints an array of all infected continentsapi.continents().then(console.log)// this prints an array of all infected continents sorted by casesapi.continents({sort:'cases'}).then(console.log)// this prints a specified continentapi.continents({continent:'europe'}).then(console.log)

Yesterday (Continents)

// this prints an array of all infected continents with yesterdays dataapi.yesterday.continents().then(console.log)// this prints an array of all infected continents with yesterdays data sorted by todays casesapi.yesterday.continents({sort:'cases'}).then(console.log)// this prints a specified continent with yesterdays dataapi.yesterday.continents({continent:'europe'}).then(console.log)

Two Days Ago (Continents)

// this prints an array of all infected continents with data from two days agoapi.twoDaysAgo.continents().then(console.log)// this prints an array of all infected continents with data from two days ago sorted by todays casesapi.twoDaysAgo.continents({sort:'cases'}).then(console.log)// this prints a specified continent with data from two days agoapi.twoDaysAgo.continents({continent:'europe'}).then(console.log)

States

// this prints an array of US states and their dataapi.states().then(console.log)// this prints an array of US states and their data sorted by casesapi.states({sort:'cases'}).then(console.log)// this prints a specified state and its dataapi.states({state:'michigan'}).then(console.log)// this prints an array of specified states and their dataapi.states({state:['michigan','new york']}).then(console.log)

Yesterday (States)

// this prints an array of US states with yesterdays dataapi.yesterday.states().then(console.log)// this prints an array of US states with yesterdays data sorted by casesapi.yesterday.states({sort:'cases'}).then(console.log)// this prints a specified state with yesterdays dataapi.yesterday.states({state:'michigan'}).then(console.log)// this prints an array of specified states with yesterdays dataapi.yesterday.states({state:['michigan','new york']}).then(console.log)

JHUCSSE

// this prints an array of infected countriesapi.jhucsse.all().then(console.log)// this prints an array of infected US counties api.jhucsse.counties().then(console.log)// this prints an array of infected provinces of a specified US county api.jhucsse.counties({county:'abbeville'}).then(console.log)// this prints an object with the counties provinces as arraysapi.jhucsse.counties({county:['abbeville','acadia']}).then(console.log)

Historical

// this prints the global timelineapi.historical.all().then(console.log)// this prints the global timeline for the last 10 days (use -1 to get all data)api.historical.all().then(console.log)// this prints an array of infected countries and their timelineapi.historical.countries().then(console.log)// this prints a specified country and its timelineapi.historical.countries({country:'china'}).then(console.log)// this prints a specified country and its timeline for the last 10 days (use -1 to get all data)api.historical.countries({country:'china',days:10}).then(console.log)// this prints a specified province of a specified country and its timelineapi.historical.countries({country:'china',province:'hubei'}).then(console.log)// this prints a specified province of a specified country and its timelineapi.historical.countries({country:'china',province:['hubei','anhui']}).then(console.log)

New York Times Data (USA)

// this prints a timeline of data from the USapi.nyt.usa().then(console.log)// this prints an array of timelines of all infected US statesapi.nyt.states().then(console.log)// this prints a timeline of a specified US stateapi.nyt.states({state:'illinois'}).then(console.log)// this prints an array of timelines all infected US countiesapi.nyt.counties().then(console.log)// this prints an array of timelines of states of a specified US countyapi.nyt.counties({county:'cook'}).then(console.log)

Mobility Data (Apple)

// this prints a list of available country namesapi.apple.countries().then(console.log)// this prints a list of available subregions for a specified countryapi.apple.subregions('austria').then(console.log)// this prints mobility data for a specified subregion of a country, all is used to query total dataapi.apple.mobilityData({country:'austria',subregion:'all'}).then(console.log)// this prints mobility data for multiple specified subregions of a countryapi.apple.mobilityData({country:'austria',subregion:['vienna','salzburg']}).then(console.log)

Official Government Data

// this prints a list of available country namesapi.gov().then(console.log)// this prints the data for a specified countryapi.gov('austria').then(console.log)

About

A JavaScript API Wrapper for NovelCOVID/API

Topics

Resources

Stars

61 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages