Skip to main content

Python package to get information regarding the novel corona virus provided by Johns Hopkins university and worldometers.info

Project description

Covid

CircleCI codecov Pypi locked Python version Downloads GitHub

Description

Python package to get information regarding the novel corona virus provided by Johns Hopkins university and worldometers.info

Full Documentation can be found here

corona.jpeg

Requirements

python >= 3.10

How to install

pip install covid

Dependencies

pydantic
requests

How to use

Getting data from Worldometers.info (default)

worldometers

covid = Covid()

Get Data

covid.get_data()

Result

[
    {
        'country': 'USA',
        'confirmed': 311637,
        'new_cases': 280,
        'deaths': 8454,
        'recovered': 14828,
        'active': 288355,
        'critical': 8206,
        'new_deaths': 2,
        'total_tests': 1656897,
        'total_tests_per_million': Decimal('0'),
        'total_cases_per_million': Decimal('941'),
        'total_deaths_per_million': Decimal('26')
    },
    {
        'active': 1376,
        'confirmed': 81669,
        'country': 'China',
        'critical': 295,
        'deaths': 3329,
        'new_cases': 30,
        'new_deaths': 3,
        'recovered': 76964,
        'total_cases_per_million': Decimal('57'),
        'total_deaths_per_million': Decimal('2'),
        'total_tests': 0,
        'total_tests_per_million': Decimal('0')
    }
    ...
]

Get Status By Country Name

covid.get_status_by_country_name("italy")

Result

{
    'active': 88274,
    'confirmed': 124632,
    'country': 'Italy',
    'critical': 3994,
    'deaths': 15362,
    'new_cases': 0,
    'new_deaths': 0,
    'recovered': 20996,
    'total_cases_per_million': Decimal('2061'),
    'total_deaths_per_million': Decimal('254'),
    'total_tests': 657224,
    'total_tests_per_million': Decimal('0')
 }

List Countries

countries = covid.list_countries()

Result

[
    'china',
    'italy',
    'usa',
    'spain',
    'germany',
...
]

Get Total Active cases

active = covid.get_total_active_cases()

Get Total Confirmed cases

confirmed = covid.get_total_confirmed_cases()

Get Total Recovered cases

recovered = covid.get_total_recovered()

Get Total Deaths

deaths = covid.get_total_deaths()

CLI 2.0 (New)

covid --help

Get all data

Worldometers source (default)

covid

or

covid -s worldometers

John Hopkins source (deprecated)

covid -s john_hopkins

List Countries

This comes in handy when you need to know the available names of countries when using covid -s 'source' -c 'country_name', eg. "The Republic of Moldova" or just "Moldova" So use this when you need to know the country exact name that you can use.

covid -s worldometers --list-countries

Get Status By Country Name

covid -s worldometers -c sweden

Get Total Active cases

covid -s worldometers -o active

Get Total Confirmed cases

covid -s worldometers -o confirmed

Get Total Recovered cases

covid -s worldometers -o recovered

Get Total Deaths

covid -s worldometers -o deaths

John Hopkins University API (Deprecated)

john_hopkins

Get All Data

from covid import Covid

covid = Covid()
covid.get_data()

Result

[
    {
        'id': '53',
        'country': 'China',
        'confirmed': 81020,
        'active': 9960,
        'deaths': 3217,
        'recovered': 67843,
        'latitude': 30.5928,
        'longitude': 114.3055,
        'last_update': 1584097775000
    },
    {
        'id': '115',
        'country': 'Italy',
        'confirmed': 24747,
        'active': 20603,
        'deaths': 1809,
        'recovered': 2335,
        'latitude': 41.8719,
        'longitude': 12.5674,
        'last_update': 1584318130000
    },
    ...
]

List Countries

This comes in handy when you need to know the available names of countries when using get_status_by_country_name, eg. "The Republic of Moldova" or just "Moldova" So use this when you need to know the country exact name that you can use.

countries = covid.list_countries()

Result

[
    {'id': '53', 'country': 'China'},
    {'id': '115', 'country': 'Italy'}
    ...
]

Get Status By Country ID

italy_cases = covid.get_status_by_country_id(115)

Result

{
    'id': '115',
    'country': 'Italy',
    'confirmed': 24747,
    'active': 20603,
    'deaths': 1809,
    'recovered': 2335,
    'latitude': 41.8719,
    'longitude': 12.5674,
    'last_update': 1584318130000
}

Get Status By Country Name

italy_cases = covid.get_status_by_country_name("italy")

Result

{
    'id': '115',
    'country': 'Italy',
    'confirmed': 24747,
    'active': 20603,
    'deaths': 1809,
    'recovered': 2335,
    'latitude': 41.8719,
    'longitude': 12.5674,
    'last_update': 1584318130000
}

Get Total Confirmed cases

confirmed = covid.get_total_confirmed_cases()

Get Total Deaths

deaths = covid.get_total_deaths()

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

covid-3.0.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

covid-3.0.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file covid-3.0.0.tar.gz.

File metadata

  • Download URL: covid-3.0.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.1 Linux/5.15.0-1057-aws

File hashes

Hashes for covid-3.0.0.tar.gz
Algorithm Hash digest
SHA256 637f1cab9be768152aca73640cb26357503c4152a02705b078257db6bafb669a
MD5 624ea47c4c5ac0cea2f1b436fa95bc20
BLAKE2b-256 c35bb35da042291d70adeeba1a85de650d7ec9769f3cafc5666b5563c54270ad

See more details on using hashes here.

File details

Details for the file covid-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: covid-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.1 Linux/5.15.0-1057-aws

File hashes

Hashes for covid-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e9eb06671556923b5fb94ef0f2ebecce4998287c3869bcc643b540e4761db01
MD5 c8a5253dad222b8eb9e9bfa4b3bacbc9
BLAKE2b-256 afcdbe41e98c0cc606c48a9a5183ca8b5ece2c35a1d9fd6024e5a1db1c7d974c

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