Vaccine Finder — A frustrated Software engineer’s solution

swaroop gudipudi
6 min readMay 20, 2021

The image depicts the current scenario of how difficult it is to find vaccine slots for our loved ones. Imagine if all states start vaccines for 18+.

I am a frustrated software developer like most of you. In past one month, I tried enrolling through vaccine finder apps like vaccinateme.in, etc. Although I get alerts from these apps, I could not successfully book slot for my parents due to following reasons:

  1. There are millions of subscribers to these vaccine finder apps and by the time these apps sends messages to end subscribers there will be lot of delay and slots will be finished in cowin. Every minute matters in this crisis situation.
  2. These vaccine finder apps, have limitation on sending number of alerts to subscribers. Example vaccinate me sends whatsapp messages twice to their subscribers in a day.
  3. One biggest issue, I am sure most of people must have faced this, although slots are open in Cowin portal but when we try to book they don’t get booked and we don’t understand why. Cowin needs to improve the error messages more friendly. One root cause I found out is in APIs that Arogya Setu exposed they have slots for dose1 and dose2. So if you are dose1 individual and trying to book a slot but slots are open for dose2, you wont be able to book those slots. And no where on Cowin or Arogya Setu UI this message is shown.

After facing different types of challenges especially few highlighted above, I finally decided to explore Setu Api and come up with my own vaccine finder. And the results are extra ordinary. I was able to book successfully for my parents and in laws in just a day of running my app.

If you also faced above pain areas and eagerly looking to develop own solution “Aatmanirbhar”, then welcome to the club. Follow these easy steps by spending hardly 30 mins of your time for setting up this app in your machine and in return a guaranteed slot for your loved ones.

Introducing API Setu

The Swagger documentation for the Setu Api can be found here:

https://apisetu.gov.in/public/api/cowin

More documentation can be found here

Let me explain with an easy example.

First find your state id using the Get States call

https://cdn-api.co-vin.in/api/v2/admin/location/states

Now grab the state code and find the district id using below Get Districts call, where 32 is Telangana State code

https://cdn-api.co-vin.in/api/v2/admin/location/districts/32

Last step, use the Get Calendar by District api to find the vaccine slots available in the given district.

Sample response received for District code 581 on date 17–05–2021
Json response from Setu API that shows Dose2 vaccine slots are available

In this example I am interested in finding vaccines for district Hyderabad that has district code of 581 for 17th May, 2021.

https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id=581&date=17-05-2021

If slots are available, will get a big Json response that has lot of valuable information

Lets Automate this

If we can automate above steps that runs every minute and alerts us with available slots then it becomes cake walk to book slots successfully.

Scheduling is very easy with Airflow and following github link has the working code. It has docker script and all you have to do is just run the docker-compose commands.

Prerequisites

  1. Download and install docker in your machine. Don’t worry if you are hearing this term for first time. It is very simple and docker knowledge is not required. Just follow my commands!

2. We want to enable real time notifications through email and hence we would need an email notification service. I can think of only gmail, the best Email service provider and its free.

https://security.google.com/settings/security/apppasswords

Select “mail” from drop down and any device for example if you are on windows, select windows. Hit generate that generates the SMTP password. Save it somewhere as it will be generated only once.

If you don’t see above screen, then you need to first sign into gmail and navigate to the below page for enabling 2 factor authentication.

Three Simple Steps for setting up

Configure your project:

update with your smtp details generated in prerequisites section

Clone the git repository into your local and update the docker-compose.yaml file with your smtp details in these lines.

Run below docker commands from your terminal/command prompt. Ensure you are in the git cloned project path.

  1. docker-compose up airflow-init
  2. docker-compose up
  3. “Use this command to clean up. Warning: This will delete all the data from temporary database that you created with first step”.
docker-compose down --volumes --rmi all

Note: Make sure you enable file sharing for docker in your docker desktop settings. Refer to references for more details.

Setting up Airflow

After running docker-compose up, the airflow can be accessible from the below link

http://localhost:8080/home

First time login with username: airflow and password also airflow

On Airflow UI Navigate to Admin -> Connections and create a new connection as below

Save the connection with above details and you need to create email list to send notifications.

Navigate to Admin -> Variables and create a new variable with below details

modify the Val with list of emails that airflow needs to send alerts

Now you are all set to run the Dag

Navigate to DAGs and enable the vaccine_notify_pipeline dag. Wait for 5 minutes for successful run.

After successful run, you can open Dag “vaccine_notify_pipeline” and you can check the dag tasks status.

Individual Task status in Graph View

If you find the task status in above format then that means you should have received an email by now in below format.

I had to remove my PII data

Ta da look at the beautiful email with most important information. With these email alerts you can go to cowin portal and book the required slots. You have enough information to see how many slots open for dose1 and dose2. And which center is offering Covishield vs Covaxin.

Customizing the airflow script to suite your requirements

If you want to modify the alert frequency, navigate to your code and update at this line with frequency you are interested in. Right now it is scheduled to run every 5 minutes.

Scheduled to run every 5 minutes

If you want to add more districts, update below code snippet

Lastly, modify below dates as of now the code checks the slots availability from 17th to 30th May, 2021

Hope this helps someone book slots in this crisis situation. Vaccine is an important shield against Covid-19. Make sure you and your loved ones are taking Vaccine.

Please clap if you felt this article insightful and mention in comments your experience and feedback.

If you face any issues while setting this up, just comment or connect with me on linkedin

References:

--

--

swaroop gudipudi

Data Science Architect with passion to create impactful solutions