Disclaimer
The old NovelCovid package was deprecated and we are now at version 2.0.0
Typescript support is limited but will be worked on soon!
Installation
Using NPM:
npm i -s novelcovid
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 v2/all
, v2/countries
, v2/continents
, v2/states
and v2/gov
endpoints.
Usage
All shown examples use Promises but can also await/async to fetch data using NovelCovid.
Add to project
const api = require('novelcovid');
api.settings({
baseUrl: 'https://disease.sh' | 'https://api.caw.sh' | 'https://corona.lmao.ninja'
})
Summary
api.all().then(console.log)
api.yesterday.all().then(console.log)
api.twoDaysAgo.all().then(console.log)
Countries
api.countries().then(console.log)
api.countries({sort:'cases'}).then(console.log)
api.countries({country:'austria'}).then(console.log)
api.countries({country:['austria','china']}).then(console.log)
Yesterday (Countries)
api.yesterday.countries().then(console.log)
api.yesterday.countries({sort:'cases'}).then(console.log)
api.yesterday.countries({country:'austria'}).then(console.log)
api.yesterday.countries({country:['austria','china']}).then(console.log)
Two Days Ago (Countries)
api.twoDaysAgo.countries().then(console.log)
api.twoDaysAgo.countries({sort:'cases'}).then(console.log)
api.twoDaysAgo.countries({country:'austria'}).then(console.log)
api.twoDaysAgo.countries({country:['austria','china']}).then(console.log)
Continents
api.continents().then(console.log)
api.continents({sort:'cases'}).then(console.log)
api.continents({continent:'europe'}).then(console.log)
Yesterday (Continents)
api.yesterday.continents().then(console.log)
api.yesterday.continents({sort:'cases'}).then(console.log)
api.yesterday.continents({continent:'europe'}).then(console.log)
Two Days Ago (Continents)
api.twoDaysAgo.continents().then(console.log)
api.twoDaysAgo.continents({sort:'cases'}).then(console.log)
api.twoDaysAgo.continents({continent:'europe'}).then(console.log)
States
api.states().then(console.log)
api.states({sort:'cases'}).then(console.log)
api.states({state:'michigan'}).then(console.log)
api.states({state:['michigan','new york']}).then(console.log)
Yesterday (States)
api.yesterday.states().then(console.log)
api.yesterday.states({sort:'cases'}).then(console.log)
api.yesterday.states({state:'michigan'}).then(console.log)
api.yesterday.states({state:['michigan','new york']}).then(console.log)
JHUCSSE
api.jhucsse.all().then(console.log)
api.jhucsse.counties().then(console.log)
api.jhucsse.counties({county:'abbeville'}).then(console.log)
api.jhucsse.counties({county:['abbeville','acadia']}).then(console.log)
Historical
api.historical.all().then(console.log)
api.historical.all().then(console.log)
api.historical.countries().then(console.log)
api.historical.countries({country:'china'}).then(console.log)
api.historical.countries({country:'china', days:10}).then(console.log)
api.historical.countries({country:'china', province:'hubei'}).then(console.log)
api.historical.countries({country:'china', province:['hubei','anhui']}).then(console.log)
New York Times Data (USA)
api.nyt.usa().then(console.log)
api.nyt.states().then(console.log)
api.nyt.states({state:'illinois'}).then(console.log)
api.nyt.counties().then(console.log)
api.nyt.counties({county:'cook'}).then(console.log)
Mobility Data (Apple)
api.apple.countries().then(console.log)
api.apple.subregions('austria').then(console.log)
api.apple.mobilityData({country:'austria', subregion:'all'}).then(console.log)
api.apple.mobilityData({country:'austria', subregion:['vienna', 'salzburg']}).then(console.log)
Official Government Data
api.gov().then(console.log)
api.gov('austria').then(console.log)