Friday, April 19, 2024
No menu items!

R wrapper for cowin API

In this article you will see how you can check vaccine slots on cowin site using R programming. This article is mainly for Indian residents as cowin website is for booking vaccine slots for Indian nationals.

I developed the package which interacts with cowin API. This package was developed last month and released on Github. Unfortunately i didn’t get time to write detailed documentation around it last month. This package lets you to find slots for vaccination in your district or pincode. Cowin API has restrictions – it allows maximum 100 request per 5 minutes per IP. Your IP address can be blocked if rate limit exceeds.

Installation

You can install the package from github using the command below
# install.packages(“devtools”)
devtools::install_github(“deepanshu88/cowin”)
Once you are done with the installation, load the package.
library(cowin)
library(dplyr)

Extract list of States

df.States It returns state names along with state IDs.
head(df.States)
states.state_id states.state_name
1 Andaman and Nicobar Islands
2 Andhra Pradesh
3 Arunachal Pradesh
4 Assam
5 Bihar
6 Chandigarh

Fetch Districts of a particular state

You need to pass state ID in the function extract_districts(state_id) State ID can be fetched from extract_states() function. In the example below, State ID 16 is for Karnataka.
df.District

Get Districts of all the Indian states

This function loops through all the states and fetch districts against them.
df.Districts

Vaccine slots for 7 days from today’s date in a given district

You need to pass District ID in the function. District ID can be obtained from extract_districts_all() function.
slots

Vaccine slots for 7 days from today’s date in a given district

By default date is today’s date. You can change it.
slots

Cleaned Output of slots_district() and slots_pincode()

In age_limit argument, you can enter 18 for 18+, 45 for 45+. By default, combination of both
slots2 slots2

Vaccine slots for Multiple districts

district.ids slots.all

Vaccine slots for 7 days from a specific date in a given pincode

In this function slots_pincode(pincode), you need to enter 6 digit pincode.
slots.pincodes slots.pincodes2 slots.pincodes2

Vaccine slots for multiple pincodes

slots.all Read MoreListenData

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments