Giter Club home page Giter Club logo

covid19py's Introduction

COVID19Py

Downloads Downloads Downloads GPLv3 License All Contributors CodeFactor HitCount GitHub stars

A tiny Python package for easy access to up-to-date Coronavirus (COVID-19, SARS-CoV-2) cases data.

About

COVID19Py is a Python wrapper made to be compatible with ExpDev07/coronavirus-tracker-api REST API. It retrieves data directly from an instance of @ExpDev07's backend but it can also be set up to use a different backend.

To achieve this, just pass the URL of the backend as a parameter to the library's constructor:

import COVID19Py
covid19 = COVID19Py.COVID19("https://my-awesome-covid19-backend")

Installation

In order install this package, simply run:

pip install COVID19Py

Usage

To use COVID19Py, you first need to import the package and then create a new instance:

import COVID19Py
covid19 = COVID19Py.COVID19()

Choosing a data source

COVID19Py supports the retrieval of data from multiple data sources. To choose a specific data source, simply pass it as a parameter to the library's constructor:

covid19 = COVID19Py.COVID19(data_source="csbs")

For more details about the available data sources, please check the API's documentation.

Getting latest amount of total confirmed cases, deaths, and recoveries:

latest = covid19.getLatest()

Getting all locations:

locations = covid19.getLocations()

or:

locations = covid19.getLocations(timelines=True)

to also get timelines.

You can also rank the results by confirmed, deaths or recovered.

locations = covid19.getLocations(rank_by='recovered')

Getting location by country code:

location = covid19.getLocationByCountryCode("US")

or:

location = covid19.getLocationByCountryCode("US", timelines=True)

to also get timelines.

Getting a specific location (includes timelines by default):

location = covid19.getLocationById(39)

Getting location by country name:

location = covid19.getLocationByCountry("Zimbabwe")

or:

location = covid19.getLocationByCountry("Zimbabwe", timelines=True)

Getting all data at once:

You can also get all the available data with one command.

data = covid19.getAll()

or:

data = covid19.getAll(timelines=True)

to also get timelines.

latest will be available on data["latest"] and locations will be available on data["locations"].

Getting latest deltas:

When using getAll(), COVID19Py will also store the previous version of the retrieved data. This allows us to easily see how data changed since the last time we requested them.

changes = covid19.getLatestChanges()
{
    "confirmed": 512,
    "deaths": 16,
    "recovered": 1024
}

Contributing

You will need to fork this repository onto your own GitHub account, then clone the repo to your local machine.

In the project directory, you will need to make sure the required packages are installed. To install requirements from the Pipfile, run a command like the following, which may depend on how you have package management set up:

pipenv install

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Konstantinos Kamaropoulos

๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ก

Jarod DeWeese

๐Ÿ’ป ๐Ÿ“–

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

covid19py's People

Contributors

kamaropoulos avatar jdeweese1 avatar allcontributors[bot] avatar bbwanaz avatar jbchouinard avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.