COWIN vaccine appointment slot tracker/notification for age 18+ using PHP script

Update: Check our latest article for getting email notification for CoWIN Vaccine slot availability.

As the country open up Covid 19 vaccination for 18+ age group on COWIN portal, there is a acute shortage of vaccines and appointment slots. In many states, only private hospitals have started vaccination for 18+ age group but with very limited number of slots available.

vaccine alertUsing a PHP script, we can monitor the vaccine availability and get email notification.

Step 1: Deploy a Linux server in India

Even though you can run the script on local computer, it is best to deploy it on a server as you can run it 24×7. I recommend using AWS to deploy a Ubuntu server with PHP and Apache or Nginx. Make sure the server is located in India as the API is blocked outside India.

Step 2: Prerequisites 

  1. Download PHPMailer and copy PHPMailer.php and SMTP.php files to web directory. (
  2. Create a Gmail account to send notification emails. Enable less secure apps or use app specific password if you have 2 step verification on.
  3. Identify the district code for your district from

Step 3: Modify the PHP script as required

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
date_default_timezone_set('Asia/Kolkata'); // Your time zone
$distid=781; // Your district code
$today = date('d-m-Y');
for($j=1; $j<=10; $j++)
echo '<h2>Mod time '.$today.'</h2>';
$agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36";

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $links);
curl_setopt($curl, CURLOPT_USERAGENT, $agent);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1) ;
if (!is_null($file_get_contents)){
//echo $file_get_contents;
$arrLength = count($data);
for($i=0; $i<$arrLength; $i++)
echo '<p>';
echo '<b>Name:</b> '.$data[$i]->name;
echo '<br>';
echo '<b>Address:</b> '.$data[$i]->address;
echo '<br>';
echo '<b>District:</b> '.$data[$i]->pincode;
echo '<br>';
echo '<b>Pincode:</b> '.$data[$i]->pincode;
echo '<br>';
echo '<b>Date:</b> '.$data[$i]->date;
echo '<br>';
echo '<b>Fee:</b> '.$data[$i]->fee;
echo '<br>';
echo '<b>Age:</b> '.$data[$i]->min_age_limit;
echo '<br>';
echo '<b>Capacity:</b> '.$data[$i]->available_capacity;
echo '<br>';
echo '<b>Vaccine:</b> '.$data[$i]->vaccine;

$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->Host = '';
$mail->SMTPAuth = true;
$mail->Username = '';
$mail->Password = 'password'; //password for your Gmail account
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom('', 'Vaccine Alert');
$mail->addAddress('', 'Vaccine');
$mail->Subject = 'Vaccine Center Found';
$mailContent = "<h1>Vaccine center details</h1>
<b>Name:</b> $name
<b>Address:</b> $address
<b>District:</b> $district
<b>Pincode:</b> $pincode
<b>Date:</b> $date
<b>Fee:</b> $fee
<b>Age:</b> $age
<b>Capacity:</b> $capacity
<b>Vaccine:</b> $vaccine
<b>Book Now: </b><a href=></a>";
$mail->Body = $mailContent;
echo '<p>';
echo 'Email has been sent';
echo '<p>';
echo 'Email could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
$repeat = strtotime("+1 day",strtotime($today));
$today = date('d-m-Y',$repeat);

Step 4: Upload files and configure cronjob

  1. Upload the files to your web directory (/var/www/html/).
  2. Create a cron job and add below (sudo crontab -e)
  3. */5 * * * * IS_CRON=1 /usr/bin/php /var/www/html/vaccine.php

The cron job will run the PHP script every 5mins and sends you notification if it finds a vaccine slot available in your city. It also scans for slot in next 10 days time and not just current date.

There is a rate limit for the API, so please avoid running it every min. You can deploy multiple scripts for each district you want to monitor.

3 thoughts on “COWIN vaccine appointment slot tracker/notification for age 18+ using PHP script

Leave a Reply

Your email address will not be published. Required fields are marked *