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.
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/
For finding list of states and districts with their ids use BASE_URL as cdn-api.co-vin.in/api/v2/admin/location/
PATH | PATH PARAMETERS | EXAMPLE |
---|---|---|
states | None | cdn-api.co-vin.in/api/v2/admin/location/states |
districts | state_id | cdn-api.co-vin.in/api/v2/admin/location/districts/21 |
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:
- Import library:
import requests
- Make the GET call
response = requests.get("https://cdn-api.co-vin.in/api/v2/admin/location/states")
- Check the status (200 = successful)
print(response.status_code)
- Show the response
print(response.json())
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:
- Instantiate the object
var request = new XMLHttpRequest()
- 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')
- Define a function to do something when the response is received
request.onload = function () {
console.log(request.status); console.log(this.response); } - Make the GET call
request.send()
// 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()