Skip to content

Instantly share code, notes, and snippets.

@sriharshav
Last active May 2, 2021 19:25
Show Gist options
  • Select an option

  • Save sriharshav/edccb9f60a869a6e22b4a94ded909156 to your computer and use it in GitHub Desktop.

Select an option

Save sriharshav/edccb9f60a869a6e22b4a94ded909156 to your computer and use it in GitHub Desktop.
import requests
import json
from datetime import date
# Refer Meta data apis to get district ids https://apisetu.gov.in/public/api/cowin#/Metadata%20APIs
districts = [
294, # BBMP
265, # Bangalore Urban
]
minimum_age = 18
today = date.today()
slots = 0
for district in districts:
res = requests.get(
'https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id='+str(district)+'&date='+today.strftime("%d-%m-%Y"))
calendar = res.json()
for center in calendar["centers"]:
header = True
for session in center["sessions"]:
if (session["min_age_limit"] == minimum_age) and (session["available_capacity"] > 0):
if header:
print("\n%s : %s : %s" % (
str(center["pincode"]), center["name"], center["fee_type"]))
header = False
print("%s : %s : %s" % (session["date"], str(
session["available_capacity"]), session["vaccine"]))
slots = slots + session["available_capacity"]
if slots == 0:
print("\nSlots are not available. Try again later.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment