Skip to content

Instantly share code, notes, and snippets.

@oyearunpal
Last active May 7, 2021 06:54
Show Gist options
  • Save oyearunpal/455f568d52fd64c7f1f811fc6eb6f79f to your computer and use it in GitHub Desktop.
Save oyearunpal/455f568d52fd64c7f1f811fc6eb6f79f to your computer and use it in GitHub Desktop.
Get available covid slot available.
from datetime import datetime
import requests
import pandas as pd
import ast
import json
date=datetime.now().strftime("%d-%m-%Y")
by_pincode_url="https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=400059&date=03-05-2021"
mumbai_district="395"
min_age=18
by_district_url="https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByDistrict?district_id=%s&date=%s"%(mumbai_district,date)
response = requests.get(by_district_url)
#print(response)
dict_response = response.json()
df=pd.DataFrame(dict_response['centers'])
for index, row in df.iterrows():
for s in row['sessions']:
if s['available_capacity'] > 0 and s['min_age_limit'] == min_age:
print("%s Available at %s, pincode %s"%(s['available_capacity'] ,row['name'],row['pincode']))
df.to_csv("slot.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment