Track one or more flights by flight number
I occasionally need to track flight which a friend or family is taking. Is it possible to provide an interface where I can provide one or more flight numbers (e.g. DAL668) and get their status ? I do see there is
frApi.getFlightDetails(flight);
but it takes a 'flight' object which can be constructed by a id used by flight radar. However, most of the layman will know the flight number. It will be awesome if users can feed in one or more strings containing flight number (e.g. DAL668) and get the status of these flights. If this feature is already implemented in current api, then I apologies, it is not obvious from documentation on how to do that. In that case, it will be appreciated if we can update the documents.
You can filter the flights by Airlines and then filter the results by comparing the flight number you want to track with the results you got.
# Filter flights by airline ICAO code and create flight objects
airline_icao = "LA"
query_result = fr24.get_flights(airline=airline_icao)
flight_list = []
for flight in query_result:
flight_data = FlightModel(
flight_id=flight.id,
flight_number=flight.number,
origin=flight.origin_airport_iata,
destination=flight.destination_airport_iata,
altitude=flight.get_altitude(),
speed=flight.get_ground_speed(),
callsign=flight.callsign,
latitude=flight.latitude,
longitude=flight.longitude,
heading=flight.heading
)
flight_list.append(flight_data)
# Example of filtering for specific flight number:
# target_flight = "LA123"
# matching_flights = [f for f in flight_list if f.flight_number == target_flight]
Hello, I seem to be running into a similar issue. When I run my query, the results look like this:
### [<(B789) CC-BGD - Altitude: 39975 - Ground Speed: 358 - Heading: 210>, <(B789) CC-BGB - Altitude: 38975 - Ground Speed: 479 - Heading: 53>]
As you can see, the output is missing the flight number and flight ID. Has there been a recent change to the output format, or am I perhaps doing something wrong on my end?
Bumping this - I'm also getting the same outputs as you (including the same issue surrounding flight number and flight ID) e.g.:
[<(A320) G-EUUR - Altitude: 2900 - Ground Speed: 175 - Heading: 270>, <(A20N) G-TTSD - Altitude: 4025 - Ground Speed: 178 - Heading: 270>, <(A320) G-EUUP - Altitude: 5500 - Ground Speed: 213 - Heading: 21>]
Well, that’s odd.
In this test using the API exactly as it comes after installing it, i make a call to the get_flights method and i print the first result:
from FlightRadar24 import FlightRadar24API
import json
fr24 = FlightRadar24API()
flight_list = fr24.get_flights(airline='LA')
print(json.dumps(vars(flight_list[0]), indent=1))
I get this:
{
"latitude": -17.707,
"longitude": -38.5074,
"id": "3b24013c",
"icao_24bit": "E48DF5",
"heading": 213,
"altitude": 36000,
"ground_speed": 475,
"squawk": "",
"aircraft_code": "B77W",
"registration": "PT-MUJ",
"time": 1751921195,
"origin_airport_iata": "FCO",
"destination_airport_iata": "GRU",
"number": "LA8121",
"airline_iata": "LA",
"on_ground": 0,
"vertical_speed": 0,
"callsign": "TAM8121",
"airline_icao": "LAN"
}
Which is pretty much it — you just need to model the flights afterward for your own purposes to filter information you don’t need