Sunday, November 17, 2024
Google search engine
HomeLanguagesTrack Covid-19 Vaccine Slots using cowin in Python

Track Covid-19 Vaccine Slots using cowin in Python

India has recently launched its largest Vaccination drive for everyone to get vaccinated against covid-19. The CoWin is an official website that handles the availability of the vacant slot. The process of going forth can be tedious items. Python API Wrapper for this site, CoWin, offers certain methods which can help us find availability near us on basis of Pincode and districts.

Installation:

To install this module type the below command in the terminal.

pip install cowin

Getting List of All States

Here will get all the states using get_states() methods. First, we will import the module, and then we use coWinAPI() to access the get_state() object. This method gets list of states present along with their IDs

Code:

Python3




from cowin_api import CoWinAPI
from pprint import pprint
 
cowin = CoWinAPI()
 
states = cowin.get_states()
print("All States List : ")
print(states)


Output : 

Getting all districts in a State

Here we will use get_districts(), which return the district name, pass the integer into the get_districts(). get_districts(state_id) takes state id returned from above API, as param and returns all districts with their IDs.

Code:

Python3




from cowin_api import CoWinAPI
from pprint import pprint
 
 
cowin = CoWinAPI()
state_id = '24'
districts = cowin.get_districts(state_id)
 
print("Districts by State Id : ")
pprint(districts)


Output : 

Getting all centers with Availability Information in District

Here we will get the center information in the district, get_availability_by_district() methods are able to return all the center information within the district.

Syntax: get_availability_by_district(district_id, date, min_age_limit)

Parameters :

  • district_id : ID obtained using above API.
  • date(optional) : Date in dd-mm-YYYY format. Defaults to today.
  • min_age_limit(optional) : Minimum age to be queried, since slots get open in different age group brackets. If not given, all ages are used as filter.
     

Code:

Python3




from cowin_api import CoWinAPI
from pprint import pprint
cowin = CoWinAPI()
 
district_id = '425'
date = '14-05-2021'
available_centers = cowin.get_availability_by_district(district_id, date)
print("All Available Centers [ By district ] : ")
pprint(available_centers)


Output : 

Getting all centers with Availability Information by Pincode

Here we will get all the center availability info according to Pincode, get_availability_by_pincode are able to return the center information by Pincode.

Syntax: get_availability_by_pincode(pin_code, date, min_age_limit) 

Parameter:

  • pin_code : Pincode of area to find centers.
  • date(optional) : Date in dd-mm-YYYY format. Defaults to today.
  • min_age_limit(optional) : Minimum age to be queried, since slots get open in different age group brackets. If not given, all ages are used as filter.

Code:

Python3




from cowin_api import CoWinAPI
from pprint import pprint
cowin = CoWinAPI()
 
pin_code = "796014"
date = '14-05-2021'
min_age_limit = 18
available_centers = cowin.get_availability_by_pincode(pin_code, date)
print("All Available Centers [ By Pincode ] : ")
pprint(available_centers)


Output : 

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments