- Discord notification
- Search-by mode customization
- Search for list of pincodes
- Randomized intevals of requests
- Logging
- Clone the repository
git clone https://github.com/RAvengineer/vad-bot.git cd vad-bot
- Create a webhook in the desired Discord channel. Follow this Intro to Webhooks official guide for learning how to create & manage a webhook.
- Follow the guidelines for
.env
file provided below (next section) ⏬ - (Optional) Create a virtual environment [Requires Python 3+]
python -m venv venv source ./venv/bin/activate
- Install required libraries
pip install -r requirements.txt
- Execute in terminal
python vad-bot.py
Create file named .env
in the root directory of the project & paste the content provided below
# Discord Webhook URL for the channel in which you want notifications
DISCORD_WEBHOOK_URL = YOUR-DISCORD-CHANNEL-URL-HERE
# Search centers by District or List of Pincodes
# Comment out the mode you are not using
#SEARCH_BY = DISTRICT
SEARCH_BY = PINCODE
# Set District ID, if SEARCH_BY mode chosen as DISTRICT
# (Ex.: 391)
DISTRICT_ID = YOUR-3-DIGIT-DISTRICT-ID-HERE
# List Pincodes, if SEARCH_BY mode chosen as PINCODE
LIST_OF_PINCODES = [201301, 301233, 401408, 501209, 801301, 901304]
💻 Setup .env file from terminal (For Linux/MacOS users):
- Type the following
nano .env
- Use
Ctrl + Shift + V
to paste the copied text contents - Press
Ctrl + S
, followed byCtrl + X
to save & exit the file
❓ How to find your DISTRICT_ID?
- Open this link containing the list of
state_id
&state_name
- Press
Ctrl+F
and type your State name. You will be find you state in the form of{"state_id":21,"state_name":"Maharashtra"}
- Note down the State ID, for the above example it is
21
. - Copy & paste
https://cdn-api.co-vin.in/api/v2/admin/location/districts/state_id
in your address bar (Don't hit search/Enter/Return yet!) - Replace
state_id
in the above link with the State ID noted down in the 4th step. Then, hit Enter/Return/search - Again, there will be a list of districts displayed with
district_id
&district_name
- Press
Ctrl+F
and type your District name. You will be find you district in the form of{"district_id":395,"district_name":"Mumbai"}
- Replace
YOUR-3-DIGIT-DISTRICT-ID-HERE
in.env
file with the District ID found in the previous step
TL;DR: In
PINCODE
mode, limit the number of pincodes in the list to 6
... The appointment availability data is cached and may be upto 30 minutes old. Further, these APIs are subject to a rate limit of 100 API calls per 5 minutes per IP ... [Updated on 5 May 2021] Source: API Setu
Considering the above limit & the fact that this bot requests data from the API in an interval decided by a psudo-random function which returns values between 20 to 40 inclusively, it is evident that number of Pincodes provided in the list should NOT exceed 6. Explanation:
In worst case scenario, the psudo-random function returns the value 20 on every call. Thus, the fetchData
function will be called
Now, each pincode requires a seperate request.
Therefore, number of possible pincodes to avoid your IP being blocked are
- API Helpers
- Discord Webhook
- Misc