How to Get Flight Status Data With an API?
We will sign up for a Flight Status API. This API provides free 30 credits for testing. Before we start coding you should read the documentation of this API. We will be using Python 3.x
for this example. I am hoping that you have already installed Python on your machine and if not then you can download it from here.
Requirements
You will have to download the requests library using pip.
pip install requests
This library will be used for making an HTTP connection with the API.
Getting Flight Status
For this example, we are going to track American Airlines(AA) flight number 15.
# Set your API key before making the request
import requests
resp = requests.get('https://api.flightapi.io/airline/Your-API-Key?num=56&name=AA&date=20240125')
print (resp.json())
In the above example, we are sending a GET request to /airline endpoint. We have passed the number of the flight as 56, the name as AA, and the date as 20240125 which means 25th Jan 2024.
Once you run this code you will get this JSON data.
[{'departure': [{'status': 'Scheduled', 'Airport:': 'MIA', 'Scheduled Time:': '10:45 PM,\xa0Jan\xa025', 'Estimated Time:': '10:45 PM,\xa0Jan\xa025', 'Terminal - Gate:': 'Terminal D - D30A'}]}, {'arrival': [{'Airport:': 'LHR', 'Scheduled Time:': '12:20 PM,\xa0Jan\xa026', 'Estimated Time:': '12:20 PM,\xa0Jan\xa026', 'Terminal - Gate:': 'Terminal 3'}]}]
This data contains every little detail like.
- Status — Scheduled or Canceled.
- Time of arrival
- Terminal Information
- Gate Information
With this API you can track any flight around the globe.