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 <- extract_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 functionextract_districts(state_id)
State ID can be fetched from extract_states()
function. In the example below, State ID 16 is for Karnataka.
df.District <- extract_districts(16)
Get Districts of all the Indian states
This function loops through all the states and fetch districts against them.df.Districts <- extract_districts_all(df.States)
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 fromextract_districts_all()
function.
slots <- slots_district(df.Districts[1,1])
Vaccine slots for 7 days from today’s date in a given district
By defaultdate
is today's date. You can change it.
slots <- slots_district(df.Districts[1,1], date = Sys.Date()+7)
Cleaned Output of slots_district() and slots_pincode()
Inage_limit
argument, you can enter 18 for 18+, 45 for 45+. By default, combination of both
slots2 <- slots_cleaned(slots) slots2 <- slots_cleaned(slots, age_limit = 45)
Vaccine slots for Multiple districts
district.ids <- c(1,3) slots.all <- slots_district_all(district.ids)
Vaccine slots for 7 days from a specific date in a given pincode
In this functionslots_pincode(pincode)
, you need to enter 6 digit pincode.
slots.pincodes <- slots_pincode(201301) slots.pincodes2 <- slots_cleaned(slots.pincodes) slots.pincodes2 <- slots_cleaned(slots.pincodes, age_limit = 45)
Vaccine slots for multiple pincodes
slots.all <- slots_pincode_all(pincodes = c(201301,110032))
Share Share Tweet