back

Covid Vaccination Slots

June 2021

GitHub Repo

CoWin Vaccination Slot Finder

Back in 2021, during the peak of COVID in India, getting a vaccination slot felt like winning a lottery.

The government required everyone to book slots through the CoWIN portal. The problem was not the idea, but the execution. To check availability, you had to enter your phone number, wait for an OTP, enter it, and only then see if slots were available. Every single refresh repeated this process. Slots were limited, competition was huge, and unless you were extremely lucky or knew exactly when slots went live, you were stuck refreshing endlessly.

At that time, I already had a strong feeling that I wanted to pursue computer science. I had tried learning C++ through offline coaching before this, and honestly, it was a disaster. I struggled a lot and started doubting whether this field was even for me.

Then I discovered JavaScript.

Compared to C++, JS felt approachable. I started learning the basics, just enough to understand how things worked. Around the same time, while desperately trying to book a vaccination slot, I noticed something interesting at the bottom of the CoWIN website. An API reference.

The CoWIN API.

That moment changed everything.

I got curious and started digging into the API documentation. I went through the endpoints, parameters, and responses. I searched YouTube and Reddit to see if someone had already built something useful with it. Surprisingly, I could not find much. This was before ChatGPT, before AI coding assistants, before vibe coding. It was just me, the docs, and a lot of trial and error.

The biggest challenge was authentication and rate limiting. The API allowed unauthenticated requests but had a strict rate limit of around 80 requests per minute. Cross that limit and your IP would get blocked.

So I played it safe.

I built a simple script using JavaScript that pinged the API every 3 seconds. That kept the request count to about 20 per minute, well within limits. The script checked slot availability based on pincode and date and logged the results in the console. No fancy UI. Just raw data.

And it worked.

Using that small app, I was able to find and book vaccination slots for myself and my family when they became available.

That moment is permanently etched in my memory.

For the first time, I had built something that solved a real problem in my own life. Not a tutorial project. Not a college assignment. A real tool with real impact.

That day, something clicked.

I stopped doubting whether computer science was for me. I knew it. This is what I wanted to do. Building things that solve problems, even small ones, felt incredibly rewarding.

That Cowin Vaccination Slot Finder was my first real project, and it is the reason I decided to seriously pursue software development.

And honestly, that feeling of seeing your code help someone in the real world is something I have been chasing ever since.

It is not rocket science, nor is it the best written or most optimized piece of code. Looking back, there are many things I would do differently today. But this project sits very close to my heart, because this is where it all started for me. It was the first time I truly felt the power of programming and realized that this is what I want to keep doing.

Note: The CoWIN public APIs used in this project have since been discontinued, so the application no longer functions as intended today. However, the source code is still shared below for reference, as it reflects my early approach to reading documentation, handling rate limits, and building a practical solution from scratch.

Code

/* 
! First attempt it runs but not neat
fetch(
    "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/findByPin?pincode=782446&date=11-06-2021"
  )
    .then(res => res.json())
    .then(data => {
      let availablePlaces = [];
      for (let i = 0; i < data["sessions"].length; i++) {
        let res = data["sessions"][i];

        if (res["min_age_limit"] > 18 && res["available_capacity_dose1"] > 0) {
          availablePlaces.push(res);
        }
      }
      availablePlaces.length > 0
        ? console.log(availablePlaces)
        : console.log("Sorry no slots available");
    }); */
let pincode = "";
let date = "";
function startSearch() {
  pincode = document.getElementById("pincode").value;
  date = document.getElementById("date").value;

  //format DD-MM-YYYY
  let url = `https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/findByPin?pincode=${pincode}&date=${date}`;
    
  checkAvailability();
  setInterval(checkAvailability, 30000);

  async function checkAvailability() {
    const res = await fetch(url);
    //console.log(url);
    let availablePlaces = [];
    const data = await res.json();
    for (let i = 0; i < data["sessions"].length; i++) {
      let res = data["sessions"][i];

      if (res["min_age_limit"] >= 18 && res["available_capacity_dose1"] > 0) {
        availablePlaces.push(res);
      }
    }
    availablePlaces.length > 0
      ? console.log(availablePlaces)
      : console.log("No slots available");
  }
}

Ty for reading

cat