Coder Social home page Coder Social logo

pallupz / covid-vaccine-booking Goto Github PK

View Code? Open in Web Editor NEW
594.0 28.0 534.0 104.5 MB

This tool can be used to automate booking slots on Co-WIN Platform.

License: MIT License

Python 100.00%
vaccine dose-slot-booking vaccination covid-19 vaccine-availability

covid-vaccine-booking's Introduction

COVID-19 Vaccination Slot Booking Script

Update:

First up, a big thank you to everyone for supporting this project and building upon it! I'm glad we were able to help a lot of people through this. However, recently we have been attracting some unwanted attention - which is getting harder to handle. So unfortunately there won't be any additional commits to this project. This has been put on indefinite hold.

Important:

  • This is a proof of concept project. I do NOT endorse or condone, in any shape or form, automating any monitoring/booking tasks. Use at your own risk.
  • This CANNOT book slots automatically. It doesn't skip any of the steps that a normal user would have to take on the official portal. You will still have to enter the OTP and Captcha.
  • Do NOT use unless all the beneficiaries selected are supposed to get the same vaccine and dose.
  • There is no option to register new mobile or add beneficiaries. This can be used only after beneficiary has been added through the official app/site.
  • This goes without saying but, once you get your shot, please do help out any underprivileged people around you who may not have a laptop or the know-how. For instance any sort of domestic help, or the staff in your local grocery store, or literally the thousands of people who don't have the knowledge or luxury we do.
  • API Details (read the first paragraph at least): https://apisetu.gov.in/public/marketplace/api/cowin/cowin-public-v2
  • BMC Link: https://www.buymeacoffee.com/pallupz
    • All donations, as they materialize, will be split equally between COVID Kerala CMDRF and a centre for cerebral palsied children with multiple handicaps.
  • Discord ID for DMs: pallupz#5726
  • And finally, I know, code quality is awful. May be some day I will rewrite the whole thing from scratch.

Noteworthy Forks

Usage:

EXE file that was being built via pyinstaller on GitHub Actions does not work anymore but the Python 3.7 code still does. If you don't already have Python and do not know how to set it up, instructions are at the bottom. It's not complicated at all and takes literally 5 minutes. Please do that and come back here.

Download this code as zip, and extract it to some folder like C:\temp\covid-vaccine-booking. Going by this structure, the py files should be in C:\temp\covid-vaccine-booking\src.

Open command prompt and run cd C:\temp\covid-vaccine-booking

Install all the dependencies with the below. This is a one-time activity (for anyone not familiar with Python)

pip install -r requirements.txt

If you're on Linux or MacOS, install the SoX (Sound eXchange) before running the Python script. To install, run:

Ubuntu:

sudo apt install sox

MacOS:

brew install sox

Finally, run the script file as shown below:

python src\covid-vaccine-slot-booking.py

If you already have a bearer token, you can also use:

python src\covid-vaccine-slot-booking.py --token=YOUR-TOKEN-HERE

If you'd prefer to pass the mobile number while running the script instead of typing in later, you can also use:

python src\covid-vaccine-slot-booking.py --mobile=YOUR-MOBILE-NUMBER

Python 3.7.3 Installation in Windows

  • Check if Python is already installed by opening command prompt and running python --version.
  • If the above command returns Python <some-version-number> you're probably good - provided version number is above 3.6
  • If Python's not installed, command would say something like: 'python' is not recognized as an internal or external command, operable program or batch file.
  • If so, download the installer from: https://www.python.org/ftp/python/3.7.3/python-3.7.3-amd64.exe
  • Run that. In the first screen of installer, there will be an option at the bottom to "Add Python 3.7 to Path". Make sure to select it.
  • Open command prompt and run python --version. If everything went well it should say Python 3.7.3
  • You're all set!

covid-vaccine-booking's People

Contributors

amal1205 avatar aneeska avatar daggy1234 avatar github-actions[bot] avatar mrehanms avatar namanphy avatar pallupz avatar rohanbeast avatar sparshsinghal avatar sparshsinghaltw avatar superfrag avatar vasugamdha avatar vishalv26 avatar vsachinv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

covid-vaccine-booking's Issues

look for slots from today

Few of the hospitals offer their slots early in the morning for the same day. The current script starts looking for slots from tomorrow, so we will need to change "check_calendar_by_district" and "check_calendar_by_pincode" to "today" instead of "tomorrow".

API key for Prod

It's not an issue, re-writing this in GO, with new features.
What is the API key for production access.

Suggestion: Better make this a website than a Python script

Nice work on automating the booking process. But I think this is unfair. This puts programmers and people with technical expertise at an advantage over everyone else. Currently the cowin platform appointment is based on luck for everyone. With a script, programmers have edge over everyone else.

But at some point, someone would have made this anyway and kept it private. At least you made it open source. Thanks for that!

It would be more equitable if this is a website for python-terminal-illiterate people. An alternative frontend for Cowin with these features you added.

Showing a non-zero number of centers available with no viable options. Should show 0 mostly?

image

This is what I see when I run the code as is. But when I change 'tomorrow' in this line (in check_calendar() in utils.py) ->
resp = requests.get(base_url.format(district['district_id'], tomorrow), headers=request_header)

to 'today' then that 105 number becomes 0. Not sure why this is happening. I was running this modified version and the slots that opened up did not show up while this was running.

Update frequency

Hi Pallupz, really appreciate your efforts. Is there any way to reduce the frequency of updates? For some locations the slots get filled up in just a second or so, so it would be great if the slot availability could be checked every second.

Notification issue

Script was not able to show the available slots which were visible on the cowin website

OTP Issue

Getting the following error :
sh: 1: pause: not found
Unable to Create OTP

OTP problem

I Get this error -
HTTPSConnectionPool(host='cdn-api.co-vin.in', port=443): Max retries exceeded with url: /api/v2/auth/generateMobileOTP (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)')))

how to fix it.

after selecting auto booking still asking for inputs like indexofcentre.indexofslot

bro i was searching for slots in Bangalore and an alert came on one of the telegram bots for 100 slots. But the script didn't show any. Is there something wrong with what i am doing here?
also i tried using it for my family in rajasthan i got a hit yet it didn't auto book it and asked for indexofcentre.indexofslot the availability was just 1(i set minimum number of vaccines required to 1 too). kindly help bro.

Object of type Response is not JSON serializable

As I was unable to create an OTP through the program, I manually generated the OTP and entered it. This is what I got -

Enter OTP: 903571
Validating OTP..
Object of type Response is not JSON serializable
Exiting Script

Latest checkout is breaking

Tried running the script, but it broke with:

  File "src/covid-vaccine-slot-booking.py", line 20
    request_header = {"Authorization": f"Bearer {token}"}
                                                       ^
SyntaxError: invalid syntax

Don't know enough python to fix this :|

State/District. option doesnt work

Hi , This is a probably new feature that got added in.
After seleting the people who want to get vaccination, this option comes and the app taps out.

Getting error on line 52

Hi,

Thanks for creating this script. I have very limited working knowledge of Python and hence pasting the error I am getting on line 52.

python ./covid-vaccine-slot-booking.py

File "./covid-vaccine-slot-booking.py", line 52
CALENDAR_URL += f"&vaccine={vaccine_type}"
SyntaxError: invalid syntax

It is showing a error on " after } . Could you let me know how to resolve this?

certificate verify failed: unable to get local issuer certificate

I am getting this below error after enterring the registered phone number.

Enter the registered mobile number: ******
Requesting OTP with mobile number ******..
HTTPSConnectionPool(host='cdn-api.co-vin.in', port=443): Max retries exceeded with url: /api/v2/auth/generateMobileOTP (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1091)')))
Exiting Script
Press any key to continue . . .

seeing sytax error while running the python script

I see the following error-

python src/covid-vaccine-slot-booking.py
File "src/covid-vaccine-slot-booking.py", line 20
request_header = {"Authorization": f"Bearer {token}"}
^
SyntaxError: invalid syntax

Anyone know why this problem is?

Kerala specific!

Great job - however, the slot booking mechanism looking at just next 7 days, is quite Kerala specific. In other states, they are opening up slots for 10 days or more at once. We need to give users an option on how many days they want to look for

Edit: I see the 7 days is coming from the API limitations - perhaps a begin date argument?

On Windows client getting the following error...Support will be really appreciated

C:\Users\chamehta\Downloads\Pyscripts>python covid-vaccine-slot-booking.py
Enter the registered mobile number: XXXXXXXXXX
Requesting OTP with mobile number XXXXXXXXXX..
HTTPSConnectionPool(host='cdn-api.co-vin.in', port=443): Max retries exceeded with url: /api/v2/auth/generateMobileOTP (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1076)')))
Exiting Script
Press any key to continue . . .

Unable to Create OTP

`Enter the registered mobile number: 75075XXXXX
Requesting OTP with mobile number 75075XXXXX..
Unable to Create OTP

<TITLE>ERROR: The request could not be satisfied</TITLE>

403 ERROR

The request could not be satisfied.


Request blocked. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.

Generated by cloudfront (CloudFront)
Request ID: yc_80Zck48I4dhhO9yh05XeWccrv-5NCqTfq760qr_BCu7I0WGx5yw==
`

Is this legal ???

Production apis is not open for public uses. So just wanted to check if that is legal?

Get OTP Call failing with 403

Getting below error when trying to get OTP since yesterday evening.

Unable to Create OTP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>403 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Request blocked.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>
Press any key to continue . . .|

403 ERROR

Got 403 ERROR. Does it seem that this has been blocked forever?

P.S. It was working fine and I was able to book an appointment 1 hour ago.

Status code 403 receiving

After entering mobile no for OTP received following error.

It seems bearer token needs to be used with every request to bypass cloudfront.

======================================================
Unable to Create OTP

<TITLE>ERROR: The request could not be satisfied</TITLE>

403 ERROR

The request could not be satisfied.


Request blocked. We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.

Generated by cloudfront (CloudFront)
Request ID: TVGQE9XeOlpUHYWQ9dnxHxD9M5x9N_8yS-dRHnFmAnhFLrtakc3raw==

===========================================

unable to fetch beneficiaries

Im getting this error after entering OTP:

Fetching registered beneficiaries..
Unable to fetch beneficiaries
401
Unauthenticated access!
sh: pause: command not found
object of type 'NoneType' has no len()
Exiting Script
sh: pause: command not found

where am I going wrong?

Error while running code

I'm facing an error while running your code :

Here is a snippet of it: (Occurs right after I enter mobile number and it requests for otp)
HTTPSConnectionPool(host='cdn-api.co-vin.in', port=443): Max retries exceeded with url: /api/v2/auth/generateMobileOTP (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))
Exiting Script'

Please help!! :(

Thank You

Just want to thank you for the script and the only way I know is to open an issue ๐Ÿ™‚. The script worked great for us. Really simple to setup and use. Please close the issue once you see it.

Host a UI on the web for automated booking

First of all, great job @pallupz! This worked for me after a an hour of tinkering. beep wasn't beeping so I replaced it with a dog barking sound whenever slots opened. :P

This got me thinking about how its possible to setup a front end and host this so that even laymen can use this service quite easily. Libraries like streamlit allow to easily repurpose python scripts into GUI web apps. Your thoughts?

Error on both Mac & Linux

Following your instruction to run the scripts, I am on Linux.

Getting error when I ran python src/covid-vaccine-slot-booking.py

File "src/covid-vaccine-slot-booking.py", line 20
request_header = {"Authorization": f"Bearer {token}"}

Logic behind calculation of "District alert frequency"

On this line, you are calculating the district alert frequency. Could you explain how this is calculated?

'district_alert_freq': 440 + ((2 * idx) * 110)

Thanks!

P.S. Great utility btw, really appreciate your time and effort in creating this! It's the most convenient one I've found out there. I just wish even the (re)authorization could have been automated. But this is the next best thing, so again, kudos!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.