Last active
November 17, 2024 13:16
How I made 10 line ruby script to get my 1st jab done! 🤷🏼
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# District - Pune, Date - Today's date. 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 | |
availability = {} | |
results[:centers].each do |center| | |
# 1st condition - Checking Age | |
sessions = center[:sessions].select{ |c| c[:min_age_limit] == 18 } | |
# 2nd condition - Checking Availability | |
sessions_with_availability = sessions.select{ |s| s[:available_capacity] > 0 } | |
# Collect date for specific pincode if there's vaccine availability | |
availability[center[:pincode]] = sessions_with_availability.collect{ |s| s[:date] } if sessions_with_availability.any? | |
end | |
availability | |
# {413102=>["10-05-2021"], 411044=>["11-05-2021"]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
original post - https://rishi.tips/p/find-vaccine-slots/