Skip to main content

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

Project description

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 for the ExpDev07/coronavirus-tracker-api REST API. It retrieves data directly from @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 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
}

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!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

COVID19Py-0.3.0.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file COVID19Py-0.3.0.tar.gz.

File metadata

  • Download URL: COVID19Py-0.3.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for COVID19Py-0.3.0.tar.gz
Algorithm Hash digest
SHA256 9bc2eb02a2a7410975f24913bcb0ab4ab7eaac7fd19271aad2eacdca61efe50f
MD5 52e4f9973c01915bd119f2db479b8f62
BLAKE2b-256 d2e5d8129426769328cc19d939c7ccb9cb774a79de92cb093bec65f3dc81eb75

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page