Get covid vaccine using python script
https://github.com/pallupz/covid-vaccine-booking
COVID-19 Vaccination Slot Booking Script
This very basic CLI based script can be used to automate covid vaccination slot booking on Co-WIN Platform.
Important:
POC project. Use at your own risk.
Do NOT use unless all beneficiaries selected are supposed to get the same vaccine and dose.
No option to register new user or add beneficiaries. This can be used only after beneficiary has been added through the official app/site
Be careful if you choose to use the auto-book feature. It will blindly book for first available center, date - both sorted ascending - and a RANDOM slot. I would recommend against using this. Only added for the convenience of people in short supply areas.
If you accidentally book a slot, donβt worry. You can always login to the official portal and cancel that. There will be an X symbol on the right-top corner for each beneficiary.
API Details (read the first paragraph at least): https://apisetu.gov.in/public/marketplace/api/cowin/cowin-public-v2
Please feel free to spread the word, if you dont mind. Link: https://www.linkedin.com/feed/update/urn:li:activity:6794138228464193536/
And finally, I know code quality isnβt great. Suggestions are welcome.
Noteworthy Forks
https://github.com/bombardier-gif/covid-vaccine-booking : I havenβt tried this personally but, it looks like a promising, completely automated solution that would require a bit more setting up.
Usage:
For the anyone not familiar with Python and using Windows, using the covid-vaccine-slot-booking.exe executable file would be the easiest way. It might trigger an anti-virus alert. Thatβs because I used pyinstaller to package the python code and it needs a bit more effort to avoid such alerts.
OR
Run the script file as show below:
python src\covid-vaccine-slot-booking.py
If youβre on Linux, install the beep package before running the Python script. To install beep, run:
sudo apt-get install beep
If you already have a bearer token, you can also use:
python src\covid-vaccine-slot-booking.py --token=YOUR-TOKEN-HERE
Third-Party Package Dependency:
tabulate : For displaying data in tabular format.
requests : For making GET and POST requests to the API.
inputimeout : For creating an input with timeout.
Install all dependencies by running:
pip install -r requirements.txt
Steps:
Run script: python src\covid-vaccine-slot-booking.py
Select Beneficiaries. Read the important notes. You can select multiple beneficiaries by providing comma-separated index values such as 1,2:
Enter the registered mobile number: ββββββββββ
Requesting OTP with mobile number ββββββββββ..
Enter OTP: 999999
Validating OTP..
Token Generated: βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Fetching registered beneficiaries..
Β±------Β±---------------------------Β±--------------------------Β±-----------+
| idx | beneficiary_reference_id | name | vaccine |
+=======+============================+===========================+============+
| 1 | ββββββββββββββ | βββββββββββββββββββββββββ | COVISHIELD |
Β±------Β±---------------------------Β±--------------------------Β±-----------+
| 2 | ββββββββββββββ | βββββββββββββββββ | |
Β±------Β±---------------------------Β±--------------------------Β±-----------+
################# IMPORTANT NOTES #################
1. While selecting beneficiaries, make sure that selected beneficiaries are all taking the same dose: either first OR second.
Please do no try to club together booking for first dose for one beneficiary and second dose for another beneficiary.
2. While selecting beneficiaries, also make sure that beneficiaries selected for second dose are all taking the same vaccine: COVISHIELD OR COVAXIN.
Please do no try to club together booking for beneficiary taking COVISHIELD with beneficiary taking COVAXIN.
###################################################
Enter comma separated index numbers of beneficiaries to book for : 2
Ensure correct beneficiaries are getting selected:
Selected beneficiaries:
Β±------Β±---------------------------Β±----------+
| idx | beneficiary_reference_id | vaccine |
+=======+============================+===========+
| 1 | ββββββββββββββ | |
Β±------Β±---------------------------Β±----------+
Select a state
Β±------Β±----------------------------+
| idx | state |
+=======+=============================+
| 1 | Andaman and Nicobar Islands |
Β±------Β±----------------------------+
| 2 | Andhra Pradesh |
Β±------Β±----------------------------+
Β±------Β±----------------------------+
Β±------Β±----------------------------+
| 35 | Uttar Pradesh |
Β±------Β±----------------------------+
| 36 | Uttarakhand |
Β±------Β±----------------------------+
| 37 | West Bengal |
Β±------Β±----------------------------+
Enter State index: 18
Select districts you are interested in. Multiple districts can be selected by providing comma-separated index values
Β±------Β±-------------------+
| idx | district |
+=======+====================+
| 1 | Alappuzha |
Β±------Β±-------------------+
| 2 | Ernakulam |
Β±------Β±-------------------+
| 3 | Idukki |
Β±------Β±-------------------+
Β±------Β±-------------------+
Β±------Β±-------------------+
| 13 | Thrissur |
Β±------Β±-------------------+
| 14 | Wayanad |
Β±------Β±-------------------+
Enter comma separated index numbers of districts to monitor : 2,13
Ensure correct districts are getting selected.
Selected districts:
Β±------Β±--------------Β±----------------Β±----------------------+
| idx | district_id | district_name | district_alert_freq |
+=======+===============+=================+=======================+
| 1 | 307 | Ernakulam | 660 |
Β±------Β±--------------Β±----------------Β±----------------------+
| 2 | 303 | Thrissur | 3080 |
Β±------Β±--------------Β±----------------Β±----------------------+
Enter the minimum number of slots to be available at the center:
Filter out centers with availability less than: 5
Script will now start to monitor slots in these districts every 15 seconds.
===================================================================================
Centers available in Ernakulam from 01-05-2021 as of 2021-04-30 15:13:44: 0
Centers available in Thrissur from 01-05-2021 as of 2021-04-30 15:13:44: 0
No viable options. Waiting for next update in 15s.
Centers available in Ernakulam from 01-05-2021 as of 2021-04-30 15:13:59: 0
Centers available in Thrissur from 01-05-2021 as of 2021-04-30 15:13:59: 0
No viable options. Waiting for next update in 15s.
If at any stage your token becomes invalid, the script will make a beep and prompt for y or n. If youβd like to continue, provide y and proceed to allow using same mobile number
Token is INVALID.
Try for a new Token? (y/n): y
Try for OTP with mobile number βββββββββββ? (y/n) : y
Enter OTP: 888888
When a center with more than minimum number of slots is available, the script will make a beep sound - different frequency for different district. It will then display the available options as table:
===================================================================================
Centers available in Ernakulam from 01-05-2021 as of 2021-04-30 15:34:19: 1
Centers available in Thrissur from 01-05-2021 as of 2021-04-30 15:34:19: 0
Β±------Β±---------------Β±-----------Β±------------Β±-----------Β±-----------------------------------------------------------------------------+
| idx | name | district | available | date | slots |
+=======+================+============+=============+============+==============================================================================+
| 1 | Ayyampilly PHC | Ernakulam | 30 | 01-05-2021 | [β09:00AM-10:00AMβ, β10:00AM-11:00AMβ, β11:00AM-12:00PMβ, β12:00PM-02:00PMβ] |
Β±------Β±---------------Β±-----------Β±------------Β±-----------Β±-----------------------------------------------------------------------------+
----------> Wait 10 seconds for updated options OR
----------> Enter a choice e.g: 1.4 for (1st center 4th slot): 1.3
Before the next update, youβll have 10 seconds to provide a choice in the format centerIndex.slotIndex eg: The input1.4 will select the vaccination center in second row and its fourth slot.
!