Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions Python/Covid_Vaccination_Center_Locator/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Covid_Vaccination_center_locator

A script to find the available covid vaccination center in the specified pincode.
When you run the code, it asks for the pincode of the place and date where you want to know the availability of center.
The script store the real time information about the center into the json file and read it and shows in the terminal.


# Technology Used

Restful APIs from api setu

Request module


# Run Locally

Run ```covid_vaccine_locator.py```

```python
python covid_vaccine_locator.py
```


# Output

This python script runs and output the json file and read it to the terminal.

## '''

Center Name : NEW DELHI MEDICAL CENTRE
Address : 1st Floor Hemkunt Tower Rajendra Place New Delhi, Central Delhi, Delhi

Total Capacity : 700

Dose1 : 300

Dose2 : 400

Price : 780

Center Name : NEW DELHI MEDICAL CENTRE

Address : 1st Floor Hemkunt Tower Rajendra Place New Delhi, Central Delhi, Delhi

Total Capacity : 700

Dose1 : 300

Dose2 : 400

Price : 780

## '''

# Author
https://github.com/das88768
46 changes: 46 additions & 0 deletions Python/Covid_Vaccination_Center_Locator/covid_vaccine_locator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import requests
import json

pincode = input("Enter the pincode of the area : ")
date = input("Enter the date to get vaccinate (dd-mm-yyyy): ")

url = f'https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/findByPin?pincode={pincode}&date={date}'
response = requests.get(url)
print(f"Status Code : {response.status_code}")

response_dict = response.json()
vacc_dicts = response_dict['sessions']

filename = 'vaccine_info.json'
with open(filename, 'w') as file:
json.dump(response_dict, file, indent=4)

if vacc_dicts:
vacc_info_dicts = []
for vacc_dict in vacc_dicts:
if vacc_dict['fee_type'] == 'Paid':
fee = vacc_dict['fee']
else:
fee = 'Free'

vacc_info = {
'center_name': vacc_dict['name'],
'address': f"{vacc_dict['address']}, {vacc_dict['district_name']}, {vacc_dict['state_name']}",
'vacc_name': vacc_dict['vaccine'],
'total_capacity': vacc_dict['available_capacity'],
'capacity_dose1': vacc_dict['available_capacity_dose1'],
'capacity_dose2': vacc_dict['available_capacity_dose2'],
'fees': fee,
}
vacc_info_dicts.append(vacc_info)

for info in vacc_info_dicts:
print(f"\nCenter Name : {info['center_name']}")
print(f"Address : {info['address']}")
print(f"Total Capacity : {info['total_capacity']}")
print(f"Dose1 : {info['capacity_dose1']}")
print(f"Dose2 : {info['capacity_dose2']}")
print(f"Price : {info['fees']}")

else:
print("Vaccination Closed")