/covid-vaccine-booking

This very basic script can be used to automate COVID-19 vaccination slot booking on India's Co-WIN Platform.

Primary LanguagePython

This party is NOT over. Added captcha support (basically pulled changes from the main repo). Now you will hear a beep and then a captcha will popup like this: Note: The captcha is a bit buggy and I had to make 5-6 tries before I was able to book.

image

Bombardier fully automated COVID-19 Vaccination Slot Booking Script

This is a fork over the neat https://github.com/pallupz/covid-vaccine-booking Thanks for creating a playground for me to build on.

What this repository does:

  1. Automates OTP read from the SMS (Android only) after the token expires
  2. Randomly chooses one of the available slots instea of waiting for input from the user
  3. Reduces the polling wait to optimize on the polling frequency (hence the name bombardier) image

How it works:

  1. https://ifttt.com/ is used to create a SMS trigger. The trigger happens when the OTP SMS is received
  2. The trigger sends the text of the SMS to a REST service, I have used a free service which needs 0 setup for a shared storage

Parallely

  1. The script runs continuously to poll (same logic as the original repository)
  2. Whenever th OTP expires, an OTP is requested
  3. When the OTP SMS is received on the Android, phone, the above logic triggers to store the OTP SMS in the shared storage
  4. The script polls the shared storage to get the OTP
  5. Once the OTP is received, the polling resumes
  6. If a free slot is found, rather than waiting for an input, it randomly chooses a slot and attempts to book

Steps to setup

  1. Create an account in ifttt.com (A premium paid account is recommended for a quicker response)
  2. Create a new applet
    
  3. If this..... click on Android SMS trigger
    
  4. Select "New SMS received matches search" and use CoWIN as the search key
    
  5. Then... Choose a service named Webhooks and then select make a web request
    
  6.     Paste the url:  https://kvdb.io/3YgXf9PHYHbX6NsF7zP6Us/99XXXXXXXX replace 99XXXXXXXX with your phone number
    
  7.     Method is PUT
    
  8.     Content Type PlainText
    
  9.    Body: Add ingredient and select Text
    
  10. On your android phone, install ifttt app
  11. Login 
    
  12. Ensure that the battery saver mode, and all other optimizations are removed. The appshould always run (This is the key for quick response). 
    
    Tip: If your IFTTT is not triggered when your SMS is received: https://www.androidpolice.com/2020/05/30/how-to-prevent-apps-sleeping-in-the-background-on-android/ Also a premium account is faster
  13. Clone this repository
  14. On mac I had to do the following too
  15. brew install python-tk
    
  16. brew install SoX
    
  17. Run the script, use the steps given below to enter your preferences
  18. Hopefully you get the slot
  19. Stay healthy and stay safe!

Tips: I used this command to run the script as it was giving me Syntax error:_ python3 src/covid-vaccine-slot-booking.py_ Also I used this command to install the dependencies python3 -m pip install -r requirements.txt

Same steps in screenshots: image image image image image image image image image

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
  • If you accidentally book a slot, don't worry. You can always login to the official portal and cancel that.
  • API Details: https://apisetu.gov.in/public/marketplace/api/cowin/cowinapi-v2
  • And finally, I know code quality probably isn't great. Suggestions are welcome.

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:

  1. Run script: python src\covid-vaccine-slot-booking.py

  2. 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
    
  3. Ensure correct beneficiaries are getting selected:

    Selected beneficiaries:  
    +-------+----------------------------+-----------+  
    | idx   | beneficiary_reference_id   | vaccine   |  
    +=======+============================+===========+  
    | 1     | ██████████████             |           |  
    +-------+----------------------------+-----------+
    
  4. 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
    
  5. 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
    
  6. Ensure correct districts are getting selected.

    Selected districts:  
    +-------+---------------+-----------------+-----------------------+  
    | idx   | district_id   | district_name   | district_alert_freq   |  
    +=======+===============+=================+=======================+  
    | 1     | 307           | Ernakulam       | 660                   |  
    +-------+---------------+-----------------+-----------------------+  
    | 2     | 303           | Thrissur        | 3080                  |  
    +-------+---------------+-----------------+-----------------------+
    
  7. Enter the minimum number of slots to be available at the center:

    Filter out centers with availability less than: 5
    
  8. 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.
    
  9. 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
    
  10. 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
    
  11. 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.