Sign inSign up

jessestuart/covid-api

By jessestuart

Updated over 6 years ago

Image
0

5.6K

jessestuart/covid-api repository overview

All Contributors

Join our Server!

Discord server

Partners with PrimedHosting

Great and affordable prices! Starting at $0.75. Get started here Join the Discord server

API

API for Current cases and more stuff about COVID-19 or the Novel Coronavirus Strain https://corona.lmao.ninja/

Endpoints v2

GET RequestOutput
https://corona.lmao.ninja/v2/historicalGet historical data from the start of 2020. (JHU CSSE GISand Data)
https://corona.lmao.ninja/v2/historical/{country-name}Get historical data from the start of 2020 for a specific country. (JHU CSSE GISand Data)
https://corona.lmao.ninja/v2/jhucsseReturn data from the Johns Hopkins CSSE Data Repository (Country, province, confirmed, death, recovered)

Endpoints v1

GET RequestOutput
https://corona.lmao.ninja/allReturns all total cases, recovery, and deaths.
https://corona.lmao.ninja/countriesReturns data of all countries that has COVID-19
https://corona.lmao.ninja/countries?sort={parameter}Returns data of each country sorted by the parameter
https://corona.lmao.ninja/countries/{country-name}Returns data of a specific country. If an exact name match is desired pass ?strict=true in the query string
https://corona.lmao.ninja/statesReturns all United States of America and their Corona data
https://corona.lmao.ninja/jhucsseDEPRECATED USE V2 ENDPOINT Return data from the Johns Hopkins CSSE Data Repository (Provinces and such)
https://corona.lmao.ninja/historicalDEPRECATED USE V2 ENDPOINT Get historical data from the start of 2020. (JHU CSSE GISand Data)
https://corona.lmao.ninja/historical/{country-name}DEPRECATED USE V2 ENDPOINT Get historical data from the start of 2020 for a specific country. (JHU CSSE GISand Data)

Loading and using our NPM Package

We suggest you load the module via require, considering ES modules in Node.js are not yet stable.

const covid = require('novelcovid');

Documentation

To actually use the data, you will need an async/await.

// Declare the package
const covid = require('novelcovid');

// Now we create a async/await
(async () => {

    // Now we await it.
    let all = await covid.getAll();

    // Make sure you return it, this usually implies if you are using this inside a function.
    // Use \n to break lines.
    return console.log(`Cases: ${all.cases}\nDeaths: ${all.deaths}\nRecovered: ${all.recovered}`)
})()
Sorting the data.

Some methods can be sorted.

const covid = require('novelcovid');

(async () => {
    let sortedCountries = await covid.getCountry({sort: 'recovered'});
    return console.log(sortedCountries);

    let sortedStates = await covid.getState({sort: 'deaths'});
    return console.log(sortedStates);
})();
Filtering for a specific country/state.
const covid = require('novelcovid');

(async () => {
   // Specific Country
   let specificCountry = await covid.getCountry({country: 'United States'});
   return console.log(specificCountry);
   
   // Specific State
   let specificState = await covid.getState({state: 'New York'});
   return console.log(specificCountry);
})();

Note Since data.updated returns milliseconds, you can do new Date(data.updated) as it returns an ISO Date

You can read more about new Date() here

For further support, you can join our discord server! More Tutorials can be found there too! https://discord.gg/EvbMshU

Sources:

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Tag summary

Content type

Image

Digest

Size

91.2 MB

Last updated

over 6 years ago

docker pull jessestuart/covid-api