A NodeJS wrapper of Cowin Public API. We can win Covid 🤝
npm install cowin
- getState - Get all states in India
- getListofDistricts - Get get all the districts of state
- findByPin - Get planned vaccination sessions on a specific date in a given pin
- findByDistrict - Get planned vaccination sessions on a specific date in a given district
- calendarByPin - Get planned vaccination sessions for 7 days from a specific date in a given pin,
- calendarByDistrict - Get planned vaccination sessions for 7 days from a specific date in a given district
Referred to Cowin API Docs for more details.
- Import required modules
const {
getStates,
getListofDistricts,
findByPin,
findByDistrict,
calendarByPin,
calendarByDistrict
} = require('cowin')
- Write asynchronous function
async function fireitup() { /* asynchronous */
const allstates = await getStates()
console.log(allstates)
const alldistricts = await getListofDistricts(36) /* { state_id } */
console.log(alldistricts)
const calenderbypin = await calendarByPin(731204, '13-05-2021') /* { pincode, date } */
console.log(calenderbypin)
const calenderbydistrict = await calendarByDistrict(713, '13-05-2021') /* district_id, date */
console.log(calenderbydistrict)
const findbypin = await findByPin(731204, '13-05-2021') /* { pincode, date } */
console.log(findbypin)
const findbydistrict = await findByDistrict(713, '13-05-2021') /* district_id, date */
console.log(findbydistrict)
}
fireitup()
- Response will looks like
{
status: true,
result: [/* Results */]
}
- Exception handling
{
status: false,
message: "Sorry that's an error"
}
APIs are subject to a rate limit of 100 API calls per 5 minutes per IP