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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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