DEV Community

Cover image for Book CoWIN Vaccination Slots directly from your Terminal...
Dhruv Panchal
Dhruv Panchal

Posted on

Book CoWIN Vaccination Slots directly from your Terminal...

Introduction

CoWIN Portal is used to self-register yourself for the Vaccination process in India. Here you can register yourself with your Phone Number and avail a slot from the available slots in various Vaccination Centres around the country.

About

VacCowin is a CLI based Python Script that can be used to perform tasks such as OTP Generation till Vaccination Slot Booking from Co-WIN Platform directly from your Terminal. This script rechecks after every few seconds and when the slots are available, it confirms the slot only after you enter the captcha shown on the screen.

Since India has started the Vaccination Drive for those above 18 years of age, there is a very heavy rush and slots get booked soon. This script will come in handy for booking those slots as soon as they open.

IMPORTANT: This is a Proof of Concept (POC) Project. I OR the Team do NOT endorse or condone, in any shape or form, automating any monitoring/booking tasks. It's only made for Educational Purposes. Use this at your own risk.

The data used is retrieved using the open APIs at API Setu. It works on both Linux and Windows.

GitHub logo dhhruv / Vac-Cowin

πŸ’‰ One Stop Solution for Booking Vaccination Slots available in the CoWIN Portal directly from your Terminal...

Getting Started

  • Install Python
  • Clone this repository...
git clone https://github.com/dhhruv/Vac-Cowin.git
Enter fullscreen mode Exit fullscreen mode

OR
Download the Zip and Extract the content.

  • Install, create and activate virtual environment. For instance we create a virtual environment named 'venv'.
pip install virtualenv
python -m virtualenv venv
venv\Scripts\activate.bat
Enter fullscreen mode Exit fullscreen mode
  • Install dependencies
cd Vac-Cowin
pip install -r requirements.txt
Enter fullscreen mode Exit fullscreen mode

How To Use

  • Run the Script after performing the Initial Steps of Getting Started: python VacCowin.py
  • Select the Beneficiaries. Read the Important notes. You can select multiple beneficiaries by providing comma-separated index values such as 1,2:
Running VacCowin...
Enter the Registered Mobile Number: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Successfully Requested OTP for the Mobile Number β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ at 2021-05-23 09:28:41.669816..
Enter OTP (If you do not recieve OTP in 2 minutes, Press Enter to Retry): β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Validating OTP. Please Wait...
Token Generated: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ

Fetching the Registered Beneficiaries...
+-------+----------------+---------------+-----------+-------+----------------------+
|   idx |        bref_id | name          | vaccine   |   age | status               |
+=======+================+===============+===========+=======+======================+
|     1 | β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ | β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ | β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   |    β–ˆβ–ˆ | β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ       |
+-------+----------------+---------------+-----------+-------+----------------------+

    ################# IMPORTANT THINGS TO BE REMEMBERED #################

    # 1. While selecting Beneficiaries, make sure that selected Beneficiaries are all taking the same dose: either their First OR Second.
    #    Please do no try to club together booking for first dose for one Beneficiary and second dose for another Beneficiary. Recommended to do both seperately.

    # 2. While selecting Beneficiaries, also make sure that Beneficiaries selected for second dose are all taking the same vaccine: COVISHIELD OR COVAXIN OR SPUTNIK V.
    #    Please do no try to club together booking for Beneficiary taking COVISHIELD with Beneficiary taking COVAXIN and other possibilities.

    # 3. If you're selecting multiple Beneficiaries, make sure all are of the same Age Group (45+ or 18+) as defined by the Government.
    #    Please do not try to club together booking for Younger and Older Beneficiaries at the same time.

    #####################################################################
Enter fullscreen mode Exit fullscreen mode
Enter comma separated index numbers of Beneficiaries to book for : 1
Enter fullscreen mode Exit fullscreen mode
  • Ensure that the Beneficiaries are getting selected:
Selected Beneficiaries are:  
+-------+----------------+---------------+-----------+-------+----------------------+
|   idx |        bref_id | name          | vaccine   |   age | status               |
+=======+================+===============+===========+=======+======================+
|     1 | β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ | β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ | β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   |    β–ˆβ–ˆ | β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ       |
+-------+----------------+---------------+-----------+-------+----------------------+
Enter fullscreen mode Exit fullscreen mode
  • Selecting the State:
+-------+-----------------------------+  
| idx   | state                       |  
+=======+=============================+  
| 1     | Andaman and Nicobar Islands |  
+-------+-----------------------------+  
| 2     | Andhra Pradesh              |  
+-------+-----------------------------+
+-------+-----------------------------+
+-------+-----------------------------+  
| 35    | Uttar Pradesh               |  
+-------+-----------------------------+  
| 36    | Uttarakhand                 |  
+-------+-----------------------------+  
| 37    | West Bengal                 |  
+-------+-----------------------------+
Enter fullscreen mode Exit fullscreen mode
Enter State Index from the Table: 12
Enter fullscreen mode Exit fullscreen mode
  • Select the Districts you are interested in. Multiple Districts can be selected by providing comma-separated index values...
+-------+-------------------------+
|   idx | district                |
+=======+=========================+
|     1 | Ahmedabad               |
+-------+-------------------------+
|     2 | Ahmedabad Corporation   |
+-------+-------------------------+
|    .. | ......                  |
+-------+-------------------------+
|    41 | Valsad                  |
+-------+-------------------------+
Enter fullscreen mode Exit fullscreen mode
Enter comma separated index numbers of Districts to monitor : 2
Enter fullscreen mode Exit fullscreen mode
  • Ensure that the correct Districts are getting selected...
Selected Districts are:
+-------+---------------+-----------------------+--------------+
|   idx |   district_id | district_name         |   alert_freq |
+=======+===============+=======================+==============+
|     1 |           770 | Ahmedabad Corporation |          660 |
+-------+---------------+-----------------------+--------------+
Enter fullscreen mode Exit fullscreen mode
  • Additional Information regarding Vaccination Availability, Loading Data, Date etc... to be added by the User.
Filter out Centres with Vaccine availability less than ? Minimum 1 :
How often do you want to load Data from the Portal (in Seconds)? Default 15. Minimum 5. :

Search for next seven day starting from when?
Use 1 for Today, 2 for Tomorrow, or provide a date in the format DD-MM-YYYY. Default 2:

Do you have a Preference for Fee Type?
Enter 0 for No Preference, 1 for Free Only, or 2 for Paid Only. Default 0 :
Enter fullscreen mode Exit fullscreen mode
  • Program will now start to monitor the slots in these Districts every 15 seconds.
===================================================================================  
Centres are available in Ahmedabad Corporation from 24-05-2021 as of 2021-05-23 09:29:10: 0
No Options Available right now. Next Update in 15 seconds..
Enter fullscreen mode Exit fullscreen mode
  • If at any stage your Token becomes invalid, then the Program will make a Beep and Prompt for y or n. If you would like to continue, provide y and proceed to allow using same Mobile Number
Token is INVALID! 
Do you want to try for a new Token? (y/n Default y): y
Enter the Registered Mobile Number: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Enter OTP: β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
Enter fullscreen mode Exit fullscreen mode
  • When a Centre with more than minimum number of Slots is available, the Program will make a Beep sound - having different frequency for different districts. It will then display the available options as shown in the Screenshot.

  • Before the Next Update, you'll have 10 seconds to provide a choice in the given format centreIndex.slotIndex eg: The input 1.4 will select the First Vaccination Centre and its Fourth Slot.

Working Screenshots:

  • Generating OTP and Token...

SS1

  • Fetching Registered Beneficiaries...

SS2

  • Selecting Beneficiaries...

SS3

  • Additional Information to be entered for Slot Booking...

SS4

  • Auto-Booking Function...

SS5

  • Save Information as JSON File...

SS6

  • Displaying Available Vaccination Centres and Booking Slots (Auto-Booking ON)

SS7

GitHub logo dhhruv / Vac-Cowin

πŸ’‰ One Stop Solution for Booking Vaccination Slots available in the CoWIN Portal directly from your Terminal...

Contributing

Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Team Members:

  1. Dhruv Panchal
  2. Urveshkumar Patel
  3. Nirja Desai

GitHub logo dhhruv / Vac-Cowin

πŸ’‰ One Stop Solution for Booking Vaccination Slots available in the CoWIN Portal directly from your Terminal...

Important:

  • This is a Proof of Concept Project. I OR the Team do NOT endorse or condone, in any shape or form, automating any monitoring/booking tasks. It's only made for Educational Purposes. Use this at your own risk.
  • This Python Script CANNOT book slots automatically. It doesn't skip any of the steps that a User would have to take on the official portal. You will still have to enter the OTP and Captcha as you do in the CoWIN Portal.
  • Do NOT use unless all the beneficiaries selected are supposed to get the same Vaccine and Dose.
  • There is no option to Register a new Phone/Mobile or add beneficiaries for now. This can be used only after beneficiary has been added through the official Portal/App.
  • Be careful if you're choosing to use the auto-book feature. It will blindly select first available Vaccination Centre, Date (Both Sorted Ascending) and a RANDOM slot. I would not recommend using this feature unless and until it's crucial.
  • If you accidentally booked a slot you didn't want to then don’t worry. You can always log in to the CoWIN Portal and cancel/re-schedule that.
  • API Details (Do read the first paragraph): https://apisetu.gov.in/public/marketplace/api/cowin/cowin-public-v2

Top comments (5)

Collapse
 
venkatesh1006 profile image
venkatesh1006

Hi Dhruv. Receiving the below error after creating the venv

Collapse
 
dhhruv profile image
Dhruv Panchal

Which error? Can't see any image or text. Can you embed it and send again?

Collapse
 
venkatesh1006 profile image
venkatesh1006

and the below error as well while starting the python file. some modules are missing in it

Collapse
 
maanuanubhav999 profile image
anubhav_sharma

great work dhruv.

Collapse
 
dhhruv profile image
Dhruv Panchal

Thanks