-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
API is unable to fetch data by pincode #20
Comments
Hi @babvin, this is a general issue with CoWin where it throws a 401 error at times. I ran the sample you provided and was able to execute it successfully. For now, try to retry in case you get an Exception. There is an open PR #16 which will be merged soon and would give you an option to retry automatically. Also, the exception handling in the library is not too good currently. We are working on it and would be releasing a v1.0.0 with the updated breaking changes which would also address the exceptions being raised. |
I've noticed this error when you try to fetch data outside of India, I have to use a VPN to go around it. I've added try-exception block to get around the issue and provide an useful msg to the user. Would appreciate if exception is thron from the API. |
Hi @clatonhendricks, there's a geofencing enabled by the CoWin team which forces you to use Indian IPs to fetch the data. About the useful error message, apologies for the issue, that's an oversight/mistake from my end which I've fixed in the latest code on master. This will propagate the exceptions thrown by the I'll notify here as soon as it is pushed to PyPi |
from cowin_api import CoWinAPI
pin_code = ["570021","560066"]
date = '03-05-2021' # Optional. Default value is today's date
min_age_limit = 18 # Optional. By default returns centers without filtering by min_age_limit
for pin in pin_code:
cowin = CoWinAPI()
print(pin, type(pin))
try:
available_centers = cowin.get_availability_by_pincode(pin_code, date, min_age_limit)
print(available_centers)
except Exception as Error:
print("Error for pin,", pin, Error)
570021 <class 'str'>
Error for pin, 570021 'HTTPError' object has no attribute 'get'
560066 <class 'str'>
Error for pin, 560066 'HTTPError' object has no attribute 'get'
The text was updated successfully, but these errors were encountered: