Skip to main content

An async Python package to get information regarding the novel corona virus provided by Johns Hopkins university and worldometers.info. Based on https://github.com/ahmednafies/covid

Project description

Async Covid

Based on Ahmednafies' COVID module.

Description

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

Documentation not ready yet, but everything is shown in this README file.

corona.jpeg

Requirements

python >= 3.6

How to install

pip install async-covid

Dependencies

pydantic
asyncio
aiohttp

How to use

Example

import asyncio
from async_covid import Covid

async def main():
    print(await covid.get_data())

if __name__ == __main__:
    covid = COVID()
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
    loop.close()

John Hopkins University API

john_hopkins

Get All Data

await covid.get_data()

Result

[
    CovidModel<
        id=175, 
        country=US, 
        confirmed=7554434, 
        active=4342532, 
        deaths=211905, 
        recovered=2999895, 
        latitude=40.0, 
        longitude=-100.0, 
        last_update=1602163423000
        >,
    CovidModel<
        id=14, 
        country=Bangladesh,
        confirmed=374592, 
        active=80816,
        deaths=5460,
        recovered=288316,
        latitude=23.685, 
        longitude=90.3563, 
        last_update=1602163423000
        >,
    ...
]

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.

await covid.list_countries()

Result

[
    CountryModel<id=175, name=US>, 
    CountryModel<id=80, name=India>,
    ...
]

Get Status By Country ID

await covid.get_status_by_country_id(14)

Result

CovidModel<
    id=14, 
    country=Bangladesh, 
    confirmed=374592,
    active=80816,
    deaths=5460, 
    recovered=288316,
    latitude=23.685,
    longitude=90.3563,
    last_update=1602163423000
>

Get Status By Country Name

 await covid.get_status_by_country_name("bangladesh")

Result

CovidModel<
    id=14, 
    country=Bangladesh, 
    confirmed=374592,
    active=80816,
    deaths=5460, 
    recovered=288316,
    latitude=23.685,
    longitude=90.3563,
    last_update=1602163423000
>

Get Total Active cases

await covid.get_total_active_cases()

Get Total Confirmed cases

await covid.get_total_confirmed_cases()

Get Total Recovered cases

await covid.get_total_recovered()

Get Total Deaths

await covid.get_total_deaths()

Getting data from Worldometers.info

worldometers

covid = Covid(source="worldometers")

Get Data

await covid.get_data()

Result

[
    CovidModel<
    country=North America, 
    confirmed=9332106, 
    new_cases=10355, 
    deaths=322513, 
    recovered=6101706,
    active=2907887, 
    critical=17932,
    new_deaths=512,
    total_tests=0,
    total_tests_per_million=0,
    total_cases_per_million=0, 
    total_deaths_per_million=0,
    population=0>
    ...
]

Get Status By Country Name

await covid.get_status_by_country_name("india")

Result

CovidModel<
country=India,
confirmed=6835655,
new_cases=2667,
deaths=105554,
recovered=5827704,
active=902397,
critical=8944,
new_deaths=0, 
total_tests=83465975
>

List Countries

countries = await covid.list_countries()

Result

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

Get Total Active cases

active = await covid.get_total_active_cases()

Get Total Confirmed cases

confirmed = await covid.get_total_confirmed_cases()

Get Total Recovered cases

recovered = await covid.get_total_recovered()

Get Total Deaths

deaths = await 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

async-covid-0.0.11.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

async_covid-0.0.11-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file async-covid-0.0.11.tar.gz.

File metadata

  • Download URL: async-covid-0.0.11.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.2

File hashes

Hashes for async-covid-0.0.11.tar.gz
Algorithm Hash digest
SHA256 f924903161b9e12d8b406512668af6258d255489b58a9ae3b21c1b9bb05e72c2
MD5 efbb83efb7603478628eb56d0628ae6e
BLAKE2b-256 f1fc9d9a16ce00a32bf2384d97b8cf11b580ab6f13eddc77b1e96f0765d9e782

See more details on using hashes here.

File details

Details for the file async_covid-0.0.11-py3-none-any.whl.

File metadata

  • Download URL: async_covid-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.2

File hashes

Hashes for async_covid-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 2e1bc50e337ef02827af13df29c533fd749f86f5b3abb72a5823464c0454a26c
MD5 e93de5d6443a6bc388e1c4368bd7cc77
BLAKE2b-256 6c3ef5f3775aeb010da84ebde9529085faadb361418a6db6907088f47ebcb448

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