calendarByDistrict
API returns planned vaccination sessions for 7 days from a specific date for a given district.{
"centers": [
{
"center_id": 1234,
"name": "District General Hostpital",
"state_name": "Maharashtra",
"district_name": "Pune",
"pincode": "411057",
"lat": 28.7,
"long": 77.1,
"from": "09:00:00",
"to": "18:00:00",
"fee_type": "Free",
"sessions": [
{
"session_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"date": "10-05-2021",
"available_capacity": 50,
"min_age_limit": 18,
"vaccine": "COVISHIELD",
"slots": [
"FORENOON",
"AFTERNOON"
]
}
]
}
]
}
# District - Pune, Date 10th May, 2021. You can modify it as per your requirement
uri = URI.parse("https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id=363&date=#{Date.today.strftime('%d-%m-%Y')}")
results = Net::HTTP.get(uri)
results = JSON.parse(results).with_indifferent_access
results
hash variable available in which the root element is centers
like this -{
"centers": [
{
"center_id": 1234,
"name": "District General Hostpital"
"sessions": [
{
"date": "10-05-2021",
"available_capacity": 50,
"min_age_limit": 18
}
]
}
]
}
attribute comparison withmin_age_limit
(18
)min_age_limit == 18
is greater thanavailable_capacity
(0
)available_capacity > 0
availability
variable will have the following hash value if any availability found.❯ availability
❯ {413102=>["02-05-2021"], 411044=>["02-05-2021"]}
- Write a fancy output, maybe create mail/SMS to send notification.
- Create a cron-job to run it every 1 minute and notify if there’s availability.
Conclusion
Important
We can’t connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
Reference
warranty of any kind, express or implied, including but not limited to fitness for a particular purpose and non-infringement. In no event shall the author be liable for any claim, damages or other liability in connection with the software or code provided here
Previously published at https://rishi.tips/p/find-vaccine-slots/