Skip to content
/ API Public
forked from disease-sh/API

API for Current cases and more stuff about COVID-19 or the Novel Coronavirus Strain

License

Notifications You must be signed in to change notification settings

cmcleese/API

 
 

Repository files navigation

All Contributors

Join our Server!

Discord server

API

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

Recommended by Postman

NovelCovid API is recommended by Postman here

Documentation

NovelCovid/API Documentation can be found here

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

Executing a method will return a Promise. The examples here utilise async/await to access the data.

// 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:

https://www.worldometers.info/coronavirus/

https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data/csse_covid_19_time_series

Contributors ✨

Thanks goes to these wonderful people (emoji key):


EliteDaMyth

💻

Ethan Winters

🐛

dicedtomato

💻

apollyon600

📖

James Shelley

👀

Ryan Harlow

🐛

Ali Tas

🐛

Walter Corrales

💻

Ahmad Awais ⚡️

📖

MrAugu

🐛

Ayyan Lewis

🐛

Ben Sommer

🐛

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

About

API for Current cases and more stuff about COVID-19 or the Novel Coronavirus Strain

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.7%
  • Dockerfile 0.3%