bhattbhavesh91/cowin-vaccination-slot-availability

Not working: might be some changes in api access!!

skmalviya opened this issue · 4 comments

import requests
import datetime
import json
import pandas as pd

for state_code in range(1,40):
    print("State code: ", state_code)
    response = requests.get("https://cdn-api.co-vin.in/api/v2/admin/location/districts/{}".format(state_code))
    json_data = json.loads(response.text)
    print (json_data)
    #for i in json_data["districts"]:
        #print(i["district_id"],'\t', i["district_name"])
    #print("\n")

Output:

State code:  1
{'message': 'Forbidden'}
State code:  2
{'message': 'Forbidden'}
State code:  3
{'message': 'Forbidden'}
State code:  4
{'message': 'Forbidden'}
State code:  5
{'message': 'Forbidden'}
State code:  6
{'message': 'Forbidden'}
State code:  7
{'message': 'Forbidden'}
.
.
.
.

Running it from Kaggle or Jupyter throws the 'forbidden' error. Works fine otherwise - as a url or from command line

I noticed another issue yesterday evening: discrepancy between the official GUI (https://selfregistration.cowin.gov.in/) and the API. API was telling me there are 118 spots available at a specific centre, whereas GUI said it was fully booked. Discrepancy lasted for about 45 mins.

@neelima-j APIs seem to have geo restrictions in place where if you are connected to VPN or from servers hosted elsewhere forbidden is being thrown, I had a VPN connected and as soon as I disconnect it, api starts working

As @akashvyom mentioned, the API has geo restriction so disconnect your VPN and try running the script! It should work! Closing this for now!