This Program checks that in which area Covid vaccine center is available using Pincode and Date. This also provide eligibile age for particular vaccine taking and quantity of vaccine showing.
CONTENTS:-
1. Project information
2. Project Requirement
3. Details
4. Source code
5. Output
Project Information:-
covid-19 vaccine is available in India. The government of India launches a vaccine for citizens and this programs will easily detect the in which area what is quantity of vaccine which helps to the users also help to finding the centre of covid vaccine. This project based on the API. It uses a JSON as data format. To display this data we using a Python programming language to parse the response and getting the relevant information. And it is also help to citizens for booking slot by checking available center. This program can also be executed on linux OS.
Project Requirement:-
>>Python 3 installed on computer.
>>A code editor or IDE such as Idle, vs code.
>>Request module should be installed.(python -m pip install requests).
>>Access to the cowin API provided by the Indian government.
Details:-
The code asks to user to enter pincode and date.
Then code constructs an HTTP get request url using the entered pincode and date to search the vaccination centers on that date.
It sends the rquests to the Cowin API using the requests.get ()
function.
Then it checks the response from the API and convert into JSON format using response.json()
function.
Then it will print the number of vaccination centers, vaccine type, minimum age, and available capacity for each vaccine.
Source code:-
import requests PINCODE = "0" while len(PINCODE) != 6: PINCODE = input("Enter the pincode for which you want the status => ") if len(PINCODE) < 6: print (f"{PINCODE} is shorter than the actual length") elif len(PINCODE) > 6: print (f"{PINCODE} is longer than the actual length") REQ_DATE = input ("Enter the Date to get status (Date format: DD-MM-YYYY) => ") request_link = f"https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode={PINCODE}&date={REQ_DATE}" header = {'User-Agent': 'Chrome/84.0.4147.105 Safari/537.36'} response = requests.get(request_link, headers = header) raw_JSON = response.json() Total_centers = len(raw_JSON['centers']) print () print (" *>>>>>> RESULTS <<<<<<<* ") print ("-------------------------------------------------------------------------------------") print (f"Date: {REQ_DATE} | Pincode: {PINCODE} ") if Total_centers != 0: print (f"Total centers in your area is: {Total_centers}" ) else: print (f"Unfortunately !! Seems like no center in this area / Kindly re-check the Pincode" ) print ("------------------------------------------------------------------------------------") print () for cent in range(Total_centers): print () print (f"[{cent+1}] Center Name:", raw_JSON['centers'][cent]['name']) print ("------------------------------------------------------------") print (" Date Vaccine Type Minimum Age Available ") print (" ------ ------------- ------------ ----------") this_session = raw_JSON['centers'][cent]['sessions'] for _sess in range(len(this_session)): print ( "{0:^12} {1:^12} {2:^14} {3:^16} ".format(this_session[_sess]['date'], this_session[_sess]['vaccine'], this_session[_sess]['min_age_limit'], this_session[_sess]['available_capacity']))
Output:-
Submitted by ABHISHEK KUMAR (Abhishek421)
Download packets of source code on Coders Packet
Comments
Good job Mr. Abhishek Kumar