Contents

Covid Vaccine Availability Dashboard

From May 1st, the government of India has opened several vaccination centers for people aged between 18 to 45. The vaccines are scarce and logging into Cowin app to check status is cumbersome due to frequent timeouts. The government has also made a public API to access vaccine related information like finding availability and downloading vaccination certificates. Using this, I have made a dashboard that makes it easy to find vaccine availability by district or pincode.

Info
It can only view vaccine availability. The actual booking needs to be done by the Cowin app

Dashboard Demo

This dashboard is made with Angular web framework and Angular Material for components.

View full page demo | View repo on github

Cowin APIs

The APIs have the general pattern: BASE_URL + PATH + PARAMETERS
where BASE_URL is cdn-api.co-vin.in/api/v2/appointment/sessions/public/

PATHQUERY PARAMETERSEXAMPLE
findByDistrictdistrict_id & datecdn-api.co-vin.in/api/v2/appointment/sessions/public/findByDistrict?district_id=365&date=25-05-2021  
findByPinpincode & datecdn-api.co-vin.in/api/v2/appointment/sessions/public/findByPin?pincode=440010&date=25-05-2021  
calendarByDistrictdistrict_id & datecdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id=365&date=25-05-2021  
calendarByPinpincode & datecdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=440010&date=25-05-2021  

For finding list of states and districts with their ids use BASE_URL as cdn-api.co-vin.in/api/v2/admin/location/

PATHPATH PARAMETERSEXAMPLE
statesNonecdn-api.co-vin.in/api/v2/admin/location/states  
districtsstate_idcdn-api.co-vin.in/api/v2/admin/location/districts/21  
Tip
If you get HTTP 403, then add a User-Agent header with value “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”

These APIs can be accessed directly through a browser, REST clients like Postman, or any programming language.

Python

Requests is one of the python libraries for making HTTP calls, with steps being as simple as:

  1. Import library: import requests
  2. Make the GET call response = requests.get("https://cdn-api.co-vin.in/api/v2/admin/location/states")
  3. Check the status (200 = successful) print(response.status_code)
  4. Show the response print(response.json())
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import requests
import json

# Appointment availibility by district and date (18+)
url = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/findByDistrict"
params = {"district_id": "365", "date": "25-05-2021"}
response = requests.get(url, params=params)
print("HTTP ", response.status_code)
data = response.json()
for session in data["sessions"]:
    if session["min_age_limit"] == 18:
        print(json.dumps(session, indent=2))

# Appointment availibility by district for (18+) for next 7 days
url = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict"
params = {"district_id": "365", "date": "25-05-2021"}
response = requests.get(url, params=params)
print("HTTP ", response.status_code)
data = response.json()
for center in data["centers"]:
    for session in center["sessions"]:
        if session["min_age_limit"] == 18 and session["vaccine"]=="COVISHIELD" and session["available_capacity"] > 0:
            print(json.dumps(session, indent=2))

JavaScript

XMLHttpRequest is a built-in object in JavaScript that can make HTTP calls in simple steps:

  1. Instantiate the object var request = new XMLHttpRequest()
  2. Prepare the GET call request.open('GET', 'https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/findByDistrict?district_id=365&date=25-05-2021')
  3. Define a function to do something when the response is received request.onload = function () {
    console.log(request.status); console.log(this.response); }
  4. Make the GET call request.send()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
// Appointment availibility by date and district
var request = new XMLHttpRequest();        
request.open('GET', 'https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/findByDistrict?district_id=365&date=25-05-2021');

request.onload = function () {               
    console.log(request.status);
    console.log(this.response);
}

request.send()  

References