Bengaluru Airport (KIA) Estimated Wait Time Data
KIA (Kempegowda International Airport Bengaluru) has interesting and valuable data about wait times at various places. They show it on overhead displays in the airport and on their website. Over time, this data can help make decisions. Hence I started saving it. Here is how you can get it.
Website and Data
KIA's website has a page and data API to display the live data on the site. It updates every minute. We use the same API but once in five minutes to keep the load low.
Git scraping and Repo
I use git scraping to save the data. It gets data and saves it into this GitHub repo every five minutes into `status.json` file. The file receives a commit on every change. The changes can be got by going through git history and parsing data. For this we will use the tool `git-history`.
Git History
Git Hisotry goes through the commit history of a file and collects the data into a SQLite file. Before we start parsing, install git-history
using pip.
pip install git-history
git-history: a tool for analyzing scraped data collected using Git and SQLite
Git Hisotry
Now run the command to gather data. Here I am getting only high-level data. But you can experiment with --convert
flag, which takes python code to flatten the data. For example, if you want airline-specific data.
First clone the project and then run load.sh, it will run the following and creates an SQLite file
git clone https://github.com/thejeshgn/bengaluru_airport_estimated_wait_time.git
cd bengaluru_airport_estimated_wait_time
sh load.sh
# load.sh
# Remove the DB
rm status.db
#create the DB
git-history file status.db status.json \
--branch master \
--full-versions \
--id key \
--convert '
response_data = json.loads(content)
data = response_data["data"]
keys = data.keys()
for key in keys:
event = {}
#print(key)
event["key"] = key
if "Queue" in data[key]:
event["Queue_QueueLength"] = data[key]["Queue"]["QueueLength"] if "QueueLength" in data[key]["Queue"] else None
event["Queue_WaitDisplay"] = data[key]["Queue"]["WaitDisplay"] if "WaitDisplay" in data[key]["Queue"] else None
else:
event["Queue_QueueLength"] = None
event["Queue_WaitDisplay"] = None
if "Desk" in data[key]:
event["Desk_QueueLength"] = data[key]["Desk"]["QueueLength"] if "QueueLength" in data[key]["Desk"] else None
event["Desk_ProcessTime"] = data[key]["Desk"]["ProcessTime"] if "ProcessTime" in data[key]["Desk"] else None
else:
event["Desk_QueueLength"] = None
event["Desk_ProcessTime"] = None
#print(event)
yield event
'
The above command will create the db called status.db
, you can explore it using DB Browser or any other tool.
Queries to explore
Here are some SQL queries to get historical data. Get all the wait times and queue lengths
-- Get all the wait times and queue lengths
select commit_at as "date_time",
iv.key,
iv.Queue_WaitDisplay,
iv.Queue_QueueLength,
iv.Desk_QueueLength,
iv.Desk_ProcessTime
from
item_version as iv,
commits as c
where
iv._commit = c.id
order by date_time asc
Get the data for a specific key - T1IS - international security gate
-- Get the data for a specific key - T1IS - international security
select datetime(commit_at) as "date_time",
iv.key,
iv.Queue_WaitDisplay,
iv.Queue_QueueLength,
iv.Desk_QueueLength,
iv.Desk_ProcessTime
from
item_version as iv,
commits as c
where
iv._commit = c.id and
iv.key = "T1IS"
order by date_time asc
Big Ideas
Collect data over time. And estimate what's the best time to arrive at the airport. Or anything else that you derive out of this data. Also, I have not fully explored and documented the data; any help with that will be great. That will also help in coming up with ideas.
2 Responses
[…] Bengaluru Airport (KIA) Estimated Wait Time Data https://thejeshgn.com/2023/01/28/bengaluru-airport-kia-estimated-wait-time-data/ […]
[…] started collecting Bengaluru Airport (KIA) Estimated Wait Time Data. It’s an interesting set of data. Let me know if you have ideas about using […]