Skip to main content

Python wrapper for CoWin APIs

Project description

Cowin Tracker

Python API wrapper for CoWin, India's digital platform launched by the government to help citizens register themselves for the vaccination drive by booking an appointment at the nearby vaccination centres.This wrapper is meant to enable folks to build their own versions of a system to lookup for vaccine availablity either in a district or in a particular pin code.

Example:

from CowinApi import ClientAPI

cowin = ClientAPI()

states = cowin.get_states()
print(states)

Install

pip install cowin-tracker

Usage

The wrapper currently covers four endpoints used by the CoWin portal specified below.

Initialize

from CowinApi import ClientAPI

cowin = ClientAPI()

Get all the available states

Returns the list of states in which vaccine drive is being conducted. This also returns the state_id which would be required in the subsequent requests.

from cowin_api import CoWinAPI

cowin = CoWinAPI()
states = cowin.get_states()
print(states)

Get all the available districts

Returns the list of districts in a particular states in which vaccine drive is being conducted. This also returns the district_id which would be required in the subsequent requests.

In this method, you would need to pass the state_id retrieved from the previous method.

from CowinApi import ClientAPI

cowin = ClientAPI()

state_id = '21'
districts = cowin.get_districts(state_id)
print(districts)

Get all the centers available in a district

Use this method to lookup for centers based on a district_id. This method is broader than searching by pin code as it covers the whole district.

In this method, you would need to pass the district_id retrieved from the previous methods. By default, the method looks-up for slots with today's date. For any other dates pass the date in DD-MM-YYYY format.

from CowinApi import ClientAPI

cowin = ClientAPI()

district_id = '367'
date = '12-05-2021'  # Optional. Takes today's date by default
min_age_limit = 18  # Optional. By default returns centers without filtering by min_age_limit

available_centers = cowin.get_availability_by_district_id(district_id, date, min_age_limit)
print(available_centers)

Get all the available centers in a pin code

Use this method to lookup for centers based on a pin_code or a list of pin_codes. By default, the method looks-up for slots with today's date. For any other dates pass the date in DD-MM-YYYY format.

from CowinApi import ClientAPI

cowin = ClientAPI()

pin_code = "400080"
date = '03-05-2021'  # Optional. Default value is today's date
min_age_limit = 18  # Optional. By default returns centers without filtering by min_age_limit

available_centers = cowin.get_availability_by_pincode(pin_code, date, min_age_limit)
print(available_centers)

Get all the available centers in a city name

Use this method to lookup for centers based on a city_name. By default, the method looks-up for slots with today's date. For any other dates pass the date in DD-MM-YYYY format.

from CowinApi import ClientAPI

cowin = ClientAPI()

city_name = "Pune"
date = '03-05-2021'  # Optional. Default value is today's date
min_age_limit = 18  # Optional. By default returns centers without filtering by min_age_limit

available_centers = cowin.get_availability_by_pincode(city_name, date, min_age_limit)
print(available_centers)

Notes:

The API's of CoWin may at times return a 403 response. To mitigate this we are passing user agents in the request. Still, if the issue persists please wait for a few minutes before trying again.

License:

MIT License

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

cowin_tracker-1.0.2.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cowin_tracker-1.0.2-py3-none-any.whl (2.4 kB view details)

Uploaded Python 3

File details

Details for the file cowin_tracker-1.0.2.tar.gz.

File metadata

  • Download URL: cowin_tracker-1.0.2.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.0

File hashes

Hashes for cowin_tracker-1.0.2.tar.gz
Algorithm Hash digest
SHA256 26c0234003e7b6653b1812d840f55b87c161da98a05a230a2f583213f7a93de4
MD5 947c1ff98a420548f76562e019e19442
BLAKE2b-256 8aab1ee138abc42d8b327a215674eb1b7ed0504bc0d41f966723e18c4371d1b7

See more details on using hashes here.

File details

Details for the file cowin_tracker-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: cowin_tracker-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 2.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.0

File hashes

Hashes for cowin_tracker-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 07671e2078ad102b3a70d8f6f3b921c5667878055194b08859d95e2efb6322d4
MD5 f4c8ed3d1f628cb850c52ae570f5fc2f
BLAKE2b-256 fcfb7d8dd3a1f62a9ef31997db2e4aa3e5e34c2256a7f4b33e90166314db8449

See more details on using hashes here.

Supported by

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