Example Gallery
You can find even more usage examples under tests/
.
FR24
class¤
Flight list¤
API reference: fr24.core.FlightListService, fr24.core.FlightListService.fetch, fr24.core.FlightListService.fetch_all
Single page¤
from fr24.core import FR24
async def my_list() -> None:
async with FR24() as fr24:
response = await fr24.flight_list.fetch(reg="B-HPB")
data = response.to_arrow()
print(data.df)
data.save()
await my_list()
flight_id number callsign icao24 registration typecode origin destination status STOD ETOD ATOD STOA ETOA ATOA
0 882269295 CX982 CPA982 7901768 B-HPB A21N None None Scheduled NaT NaT NaT NaT NaT NaT
1 882279849 CX983 CPA983 7901768 B-HPB A21N ZGGG VHHH Landed 12:28 2024-04-01 02:15:00 NaT 2024-04-01 03:45:26 2024-04-01 03:45:00 NaT 2024-04-01 04:28:37
2 882263077 CX982 CPA982 7901768 B-HPB A21N VHHH ZGGG Landed 10:02 2024-03-31 23:50:00 NaT 2024-04-01 01:30:05 2024-04-01 00:55:00 NaT 2024-04-01 02:02:58
3 882098982 CX439 CPA439 7901768 B-HPB A21N RKSI VHHH Landed 17:02 2024-03-31 04:35:00 NaT 2024-03-31 05:28:02 2024-03-31 08:25:00 NaT 2024-03-31 09:02:19
4 882069433 CX2410 CPA2410 7901768 B-HPB A21N VHHH RKSI Landed 12:49 2024-03-30 23:55:00 NaT 2024-03-31 00:51:40 2024-03-31 03:35:00 NaT 2024-03-31 03:49:22
5 881837333 CX976 CPA976 7901768 B-HPB A21N RPLL VHHH Landed 07:30 2024-03-29 21:45:00 NaT 2024-03-29 21:46:49 2024-03-30 00:05:00 NaT 2024-03-29 23:30:12
6 881725491 CX913 CPA913 7901768 B-HPB A21N VHHH RPLL Landed 22:24 2024-03-29 12:20:00 NaT 2024-03-29 12:42:42 2024-03-29 14:35:00 NaT 2024-03-29 14:24:57
7 881693238 CX674 CPA674 7901768 B-HPB A21N VTBS VHHH Landed 18:58 2024-03-29 08:05:00 NaT 2024-03-29 08:52:54 2024-03-29 10:55:00 NaT 2024-03-29 10:58:14
8 881665708 CX653 CPA653 7901768 B-HPB A21N VHHH VTBS Landed 14:26 2024-03-29 04:00:00 NaT 2024-03-29 04:35:36 2024-03-29 07:05:00 NaT 2024-03-29 07:26:51
9 881605496 CX976 CPA976 7901768 B-HPB A21N RPLL VHHH Landed 07:30 2024-03-28 21:45:00 NaT 2024-03-28 21:46:18 2024-03-29 00:05:00 NaT 2024-03-28 23:30:58
Paginate all pages¤
Queries for next page as long as user doesn't enter x
, or if there are no pages left.
In each iteration, rows are upserted and saved to the cache.
Note that pagination cannot be run in parallel: fetching page N requires information from page N-1.
from fr24.core import FR24
async def my_full_list() -> None:
async with FR24() as fr24:
data = fr24.flight_list.load(reg="B-HPB") # (1)!
async for response in fr24.flight_list.fetch_all(reg="B-HPB"):
data_new = response.to_arrow()
data.concat(data_new, inplace=True) # (2)!
if input() == "x":
break
data.save()
print(data.df)
await my_full_list()
- First attempt to load existing table from the cache, otherwise it creates an empty in-memory arrow table for us to concat to.
- Upserts the data, replacing older records with new ones.
flight_id number callsign icao24 registration typecode origin destination status STOD ETOD ATOD STOA ETOA ATOA
0 882269295 CX982 CPA982 7901768 B-HPB A21N None None Scheduled NaT NaT NaT NaT NaT NaT
1 882279849 CX983 CPA983 7901768 B-HPB A21N ZGGG VHHH Landed 12:28 2024-04-01 02:15:00 NaT 2024-04-01 03:45:26 2024-04-01 03:45:00 NaT 2024-04-01 04:28:37
2 882263077 CX982 CPA982 7901768 B-HPB A21N VHHH ZGGG Landed 10:02 2024-03-31 23:50:00 NaT 2024-04-01 01:30:05 2024-04-01 00:55:00 NaT 2024-04-01 02:02:58
3 882098982 CX439 CPA439 7901768 B-HPB A21N RKSI VHHH Landed 17:02 2024-03-31 04:35:00 NaT 2024-03-31 05:28:02 2024-03-31 08:25:00 NaT 2024-03-31 09:02:19
4 882069433 CX2410 CPA2410 7901768 B-HPB A21N VHHH RKSI Landed 12:49 2024-03-30 23:55:00 NaT 2024-03-31 00:51:40 2024-03-31 03:35:00 NaT 2024-03-31 03:49:22
5 881837333 CX976 CPA976 7901768 B-HPB A21N RPLL VHHH Landed 07:30 2024-03-29 21:45:00 NaT 2024-03-29 21:46:49 2024-03-30 00:05:00 NaT 2024-03-29 23:30:12
6 881725491 CX913 CPA913 7901768 B-HPB A21N VHHH RPLL Landed 22:24 2024-03-29 12:20:00 NaT 2024-03-29 12:42:42 2024-03-29 14:35:00 NaT 2024-03-29 14:24:57
7 881693238 CX674 CPA674 7901768 B-HPB A21N VTBS VHHH Landed 18:58 2024-03-29 08:05:00 NaT 2024-03-29 08:52:54 2024-03-29 10:55:00 NaT 2024-03-29 10:58:14
8 881665708 CX653 CPA653 7901768 B-HPB A21N VHHH VTBS Landed 14:26 2024-03-29 04:00:00 NaT 2024-03-29 04:35:36 2024-03-29 07:05:00 NaT 2024-03-29 07:26:51
9 881605496 CX976 CPA976 7901768 B-HPB A21N RPLL VHHH Landed 07:30 2024-03-28 21:45:00 NaT 2024-03-28 21:46:18 2024-03-29 00:05:00 NaT 2024-03-28 23:30:58
10 881497323 CX913 CPA913 7901768 B-HPB A21N VHHH RPLL Landed 22:24 2024-03-28 12:20:00 NaT 2024-03-28 12:49:47 2024-03-28 14:35:00 NaT 2024-03-28 14:24:36
11 881467141 CX421 CPA421 7901768 B-HPB A21N RCTP VHHH Landed 18:45 2024-03-28 09:00:00 NaT 2024-03-28 09:11:26 2024-03-28 11:05:00 NaT 2024-03-28 10:45:36
12 881447170 CX420 CPA420 7901768 B-HPB A21N VHHH RCTP Landed 15:33 2024-03-28 05:50:00 NaT 2024-03-28 06:11:32 2024-03-28 07:50:00 NaT 2024-03-28 07:33:47
13 881399852 CX449 CPA449 7901768 B-HPB A21N RCKH VHHH Landed 08:55 2024-03-27 23:45:00 NaT 2024-03-27 23:46:05 2024-03-28 01:15:00 NaT 2024-03-28 00:55:16
14 881284852 CX448 CPA448 7901768 B-HPB A21N VHHH RCKH Landed 22:58 2024-03-27 13:45:00 NaT 2024-03-27 14:02:26 2024-03-27 15:15:00 NaT 2024-03-27 14:58:08
15 881224769 CX357 CPA357 7901768 B-HPB A21N ZSNJ VHHH Landed 16:48 2024-03-27 06:15:00 NaT 2024-03-27 06:38:34 2024-03-27 09:05:00 NaT 2024-03-27 08:48:19
16 881200477 CX356 CPA356 7901768 B-HPB A21N VHHH ZSNJ Landed 13:01 2024-03-27 02:25:00 NaT 2024-03-27 03:09:36 2024-03-27 05:00:00 NaT 2024-03-27 05:01:42
17 881059983 CX742 CPA742 7901768 B-HPB A21N VVNB VHHH Landed 22:12 2024-03-26 12:20:00 NaT 2024-03-26 12:53:49 2024-03-26 14:15:00 NaT 2024-03-26 14:12:35
18 881028286 CX743 CPA743 7901768 B-HPB A21N VHHH VVNB Landed 18:26 2024-03-26 09:15:00 NaT 2024-03-26 09:45:30 2024-03-26 11:20:00 NaT 2024-03-26 11:26:21
19 880987691 CX906 CPA906 7901768 B-HPB A21N RPLL VHHH Landed 13:00 2024-03-26 02:50:00 NaT 2024-03-26 03:17:20 2024-03-26 05:30:00 NaT 2024-03-26 05:00:05
20 880961197 CX907 CPA907 7901768 B-HPB A21N VHHH RPLL Landed 09:31 2024-03-25 23:30:00 NaT 2024-03-25 23:48:48 2024-03-26 01:40:00 NaT 2024-03-26 01:31:18
21 880878019 CX989 CPA989 7901768 B-HPB A21N ZGGG VHHH Landed 00:08 2024-03-25 14:25:00 NaT 2024-03-25 15:32:32 2024-03-25 15:35:00 NaT 2024-03-25 16:08:08
22 880853941 CX988 CPA988 7901768 B-HPB A21N VHHH ZGGG Landed 22:13 2024-03-25 12:05:00 NaT 2024-03-25 13:39:17 2024-03-25 13:10:00 NaT 2024-03-25 14:13:28
23 880807848 CX674 CPA674 7901768 B-HPB A21N VTBS VHHH Landed 18:51 2024-03-25 08:05:00 NaT 2024-03-25 08:27:12 2024-03-25 10:55:00 NaT 2024-03-25 10:51:37
24 880782639 CX653 CPA653 7901768 B-HPB A21N VHHH VTBS Landed 13:51 2024-03-25 04:00:00 NaT 2024-03-25 04:19:31 2024-03-25 07:05:00 NaT 2024-03-25 06:51:40
...
Playback¤
API reference: fr24.core.PlaybackService, fr24.core.PlaybackService.fetch
Miracle on the Hudson¤
Downloads the flight trajectory for UA1549
import rich
from fr24.core import FR24
async def my_playback() -> None:
async with FR24() as fr24:
response = await fr24.playback.fetch(0x2FB3041) # (1)!
data = response.to_arrow()
print(data.df)
rich.print(data.metadata)
data.save()
await my_playback()
timestamp latitude longitude altitude ground_speed vertical_speed track squawk ems
0 1232049993 40.770302 -73.862801 0 0 NaN 59 0 None
1 1232049997 40.770302 -73.862503 0 0 NaN 65 0 None
2 1232050001 40.770302 -73.862198 0 0 NaN 71 0 None
3 1232050005 40.770302 -73.862198 0 0 NaN 76 0 None
4 1232050009 40.770302 -73.862198 0 0 NaN 82 0 None
.. ... ... ... ... ... ... ... ... ...
358 1232051425 40.781399 -73.998199 326 137 NaN 223 0 None
359 1232051429 40.779202 -73.999603 274 131 NaN 226 0 None
360 1232051433 40.777199 -74.001297 187 134 NaN 222 0 None
361 1232051437 40.775002 -74.002899 106 130 NaN 223 0 None
362 1232051441 40.773102 -74.004303 42 128 NaN 223 0 None
[363 rows x 9 columns]
{
'flight_id': 50016321,
'callsign': 'AWE1549',
'flight_number': 'UA1549',
'status_type': 'departure',
'status_text': None,
'status_diverted': None,
'status_time': None,
'model_code': 'A320',
'icao24': 10493137,
'registration': 'N106US',
'owner': None,
'airline': None,
'origin': 'KLGA',
'destination': 'KCLT',
'median_delay': None,
'median_time': None
}
File operations¤
Saves trajectory data to disk, reads the track and metadata from it.
import rich
from fr24.core import FR24
async def my_playback() -> None:
async with FR24() as fr24:
response = await fr24.playback.fetch(0x2FB3041)
data = response.to_arrow()
data.save() # (1)!
# some time later...
data_local = fr24.playback.load(0x2FB3041) # (2)!
print(data_local.df)
rich.print(data_local.metadata)
await my_playback()
timestamp latitude longitude altitude ground_speed vertical_speed track squawk ems
0 1232049993 40.770302 -73.862801 0 0 NaN 59 0 None
1 1232049997 40.770302 -73.862503 0 0 NaN 65 0 None
2 1232050001 40.770302 -73.862198 0 0 NaN 71 0 None
3 1232050005 40.770302 -73.862198 0 0 NaN 76 0 None
4 1232050009 40.770302 -73.862198 0 0 NaN 82 0 None
.. ... ... ... ... ... ... ... ... ...
358 1232051425 40.781399 -73.998199 326 137 NaN 223 0 None
359 1232051429 40.779202 -73.999603 274 131 NaN 226 0 None
360 1232051433 40.777199 -74.001297 187 134 NaN 222 0 None
361 1232051437 40.775002 -74.002899 106 130 NaN 223 0 None
362 1232051441 40.773102 -74.004303 42 128 NaN 223 0 None
[363 rows x 9 columns]
{
'flight_id': 50016321,
'callsign': 'AWE1549',
'flight_number': 'UA1549',
'status_type': 'departure',
'status_text': None,
'status_diverted': None,
'status_time': None,
'model_code': 'A320',
'icao24': 10493137,
'registration': 'N106US',
'owner': None,
'airline': None,
'origin': 'KLGA',
'destination': 'KCLT',
'median_delay': None,
'median_time': None
}
Live Feed¤
API reference: fr24.core.LiveFeedService, fr24.core.LiveFeedService.fetch
Live¤
This example is covered in detail in the quickstart.
from fr24.core import FR24
async def my_feed() -> None:
async with FR24() as fr24:
response = await fr24.live_feed.fetch()
print(response)
datac = response.to_arrow()
print(datac.df)
datac.save()
await my_feed()
LiveFeedAPIResp(
ctx={
"timestamp": 1711911907,
"source": "live",
"duration": None,
"hfreq": None,
"base_dir": PosixPath("/home/user/.cache/fr24"),
},
data=[
{
"timestamp": 1711911905,
"flightid": 882151247,
"latitude": -12.432657241821289,
"longitude": -172.14825439453125,
"track": 203,
"altitude": 34000,
"ground_speed": 515,
"vertical_speed": 0,
"on_ground": False,
"callsign": "QFA7552",
"source": 0,
"registration": "N409MC",
"origin": "HNL",
"destination": "AKL",
"typecode": "B744",
"eta": 0,
"squawk": 0,
}
# ... 15109 more items
],
)
timestamp flightid latitude longitude track altitude ground_speed on_ground callsign source registration origin destination typecode eta vertical_speed squawk
0 1711911905 882151247 -12.432657 -172.148254 203 34000 515 False QFA7552 0 N409MC HNL AKL B744 0 0 0
1 1711911902 882203620 -16.504490 -178.940308 249 36000 460 False VOZ76 0 VH-YIL APW BNE B738 0 0 0
2 1711911904 882212062 -13.240505 -176.195602 292 0 0 True RLY0100 0 F-OCQZ WLS DHC6 0 0 0
3 1711911897 882145424 10.347591 -167.007263 56 37000 516 False QFA15 5 VH-EBQ BNE LAX A332 0 0 0
4 1711911905 882199081 18.591330 -165.391083 247 32000 416 False UAL132 3 N77296 HNL MAJ B738 0 0 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
15095 1711911897 882140495 53.746582 174.467392 258 38000 435 False GTI8650 5 N710GT LAX HKG B77L 0 0 0
15096 1711911887 882155955 54.291172 175.606842 57 31000 515 False UPS81 5 N628UP PVG ANC B748 0 0 0
15097 1711911673 882165589 57.548691 179.460800 246 36000 438 False KAL258 4 HL8285 ANC ICN B77L 0 0 0
15098 1711911901 882187089 56.527115 176.298798 242 38000 442 False CKS936 4 N701CK ANC HFE B744 0 0 0
15099 1711911905 882137160 59.153641 179.730972 229 38000 471 False KAL8286 5 HL8043 YYZ ICN B77L 0 0 0
[15100 rows x 16 columns]
Playback¤
Fetches the live feed three days ago.
from fr24.core import FR24
import time
async def my_feed() -> None:
async with FR24() as fr24:
response = await fr24.live_feed.fetch(int(time.time() - 86400 * 3)) # (1)!
datac = response.to_arrow()
print(datac.df)
await my_feed()
- Subtract current UTC by 3 days.
timestamp flightid latitude longitude track altitude ground_speed on_ground callsign source registration origin destination typecode eta vertical_speed squawk
0 1711697713 881642343 -13.628512 -169.556046 44 37000 499 False DAL42 0 N519DN SYD LAX A359 0 0 0
1 1711697709 881686001 -14.096649 -172.093018 182 8850 298 False ANZ999 0 ZK-NNE APW AKL A21N 0 0 0
2 1711697713 881673319 -46.344315 -173.242355 122 31975 568 False LAN800 4 CC-BGC AKL SCL B789 0 0 0
3 1711697713 881679659 -34.398090 -178.388153 64 37975 530 False ANZ902 4 ZK-NZE AKL PPT B789 0 0 0
4 1711697717 881655685 -12.116470 -169.877808 199 36000 469 False HAL465 5 N395HA HNL PPG A332 0 0 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
11422 1711697721 881662489 56.048801 174.987000 240 36000 468 False CPA3187 3 B-LJG ANC HKG B748 0 0 0
11423 1711697713 881602916 56.870163 175.223923 226 35000 476 False ANA111 3 JA796A ORD HND B77W 0 0 0
11424 1711697713 881669755 56.652039 176.742554 240 34000 459 False FDX5236 3 N573FE ANC ICN MD11 0 0 0
11425 1711697721 881652749 57.509033 179.559845 242 38000 467 False GTI8065 3 N452PA PDX ICN B744 0 0 0
11426 1711697717 881648986 54.571342 175.497025 55 31000 501 False EVA662 5 B-16781 TPE ANC B77L 0 0 0
[11427 rows x 16 columns]
Lower-level functions¤
Flight list¤
API Reference: fr24.json.flight_list, fr24.json.flight_list_df
import httpx
from fr24.authentication import login
from fr24.json import flight_list, flight_list_df
import pandas as pd
async def my_list() -> pd.DataFrame:
async with httpx.AsyncClient() as client:
auth = await login(client)
if auth is not None:
print(auth["message"])
list_ = await flight_list(
client,
flight="AF291",
timestamp="2024-04-01", # (1)!
auth=auth,
)
return list_
list_ = await my_list()
df = flight_list_df(list_)
df
- Replace it with the current time.
flight_id number callsign icao24 registration typecode origin destination status STOD ETOD ATOD STOA ETOA ATOA
0 NaN AF291 None NaN None 77W RJBB LFPG Scheduled 2024-04-08 02:30:00+00:00 NaT NaT 2024-04-08 17:25:00+00:00 NaT NaT
1 NaN AF291 None NaN None 772 RJBB LFPG Scheduled 2024-04-07 02:30:00+00:00 NaT NaT 2024-04-07 17:25:00+00:00 NaT NaT
2 NaN AF291 None NaN None 772 RJBB LFPG Scheduled 2024-04-06 02:30:00+00:00 NaT NaT 2024-04-06 17:25:00+00:00 NaT NaT
3 NaN AF291 None NaN None 772 RJBB LFPG Scheduled 2024-04-05 02:30:00+00:00 NaT NaT 2024-04-05 17:25:00+00:00 NaT NaT
4 NaN AF291 None NaN None 77W RJBB LFPG Scheduled 2024-04-03 02:30:00+00:00 NaT NaT 2024-04-03 17:25:00+00:00 NaT NaT
5 882273605 AF291 AFR291 3754464 F-GSPA B772 RJBB LFPG Estimated 19:06 2024-04-01 02:30:00+00:00 NaT 2024-04-01 02:56:21+00:00 2024-04-01 17:25:00+00:00 2024-04-01 17:06:08+00:00 NaT
6 882083240 AF291 AFR291 3754478 F-GSPO B772 RJBB LFPG Landed 19:15 2024-03-31 02:30:00+00:00 NaT 2024-03-31 02:47:05+00:00 2024-03-31 17:25:00+00:00 NaT 2024-03-31 17:15:33+00:00
7 881882655 AF291 AFR291 3754467 F-GSPD B772 RJBB LFPG Landed 18:47 2024-03-30 02:55:00+00:00 NaT 2024-03-30 03:27:31+00:00 2024-03-30 17:50:00+00:00 NaT 2024-03-30 17:47:52+00:00
8 881661169 AF291 AFR291 3754470 F-GSPG B772 RJBB LFPG Landed 19:14 2024-03-29 03:25:00+00:00 NaT 2024-03-29 03:41:26+00:00 2024-03-29 18:20:00+00:00 NaT 2024-03-29 18:14:54+00:00
9 881224971 AF291 AFR291 3754487 F-GSPX B772 RJBB LFPG Landed 22:22 2024-03-27 03:25:00+00:00 NaT 2024-03-27 06:58:33+00:00 2024-03-27 18:20:00+00:00 NaT 2024-03-27 21:22:08+00:00
Playback¤
API Reference: fr24.json.playback, fr24.json.playback_df
import httpx
from fr24.authentication import login
from fr24.json import playback, playback_df
import pandas as pd
async def my_playback() -> pd.DataFrame:
async with httpx.AsyncClient() as client:
auth = await login(client)
if auth is not None:
print(auth["message"])
list_ = await playback(
client,
flight_id="35d692b1",
timestamp=1719273600,
auth=auth,
)
return list_
list_ = await my_playback()
df = playback_df(list_)
df
timestamp latitude longitude altitude ground_speed vertical_speed track squawk ems
0 2024-06-25 00:34:31+00:00 25.083984 121.251160 0 3 0 137 0 None
1 2024-06-25 00:35:17+00:00 25.083664 121.251465 0 9 0 137 0 None
2 2024-06-25 00:35:27+00:00 25.083344 121.251770 0 9 0 140 0 None
3 2024-06-25 00:35:34+00:00 25.083101 121.251816 0 7 0 163 0 None
4 2024-06-25 00:35:47+00:00 25.082882 121.251541 0 5 0 216 0 None
.. ... ... ... ... ... ... ... ... ...
413 2024-06-25 02:08:13+00:00 22.312042 113.929344 0 5 0 39 1459 None
414 2024-06-25 02:08:21+00:00 22.312243 113.929344 0 6 0 14 1459 None
415 2024-06-25 02:08:30+00:00 22.312475 113.929214 0 6 0 345 1459 None
416 2024-06-25 02:08:39+00:00 22.312706 113.929108 0 5 0 340 1459 None
417 2024-06-25 02:08:53+00:00 22.312906 113.929039 0 3 0 340 1459 None
[418 rows x 9 columns]
Airport Arrivals¤
API Reference: fr24.json.airport_list
import httpx
from fr24.types.airport_list import AirportList
from fr24.json import airport_list
import pandas as pd
async def my_arrivals() -> AirportList:
async with httpx.AsyncClient() as client:
list_ = await airport_list(
client,
airport="tls",
mode="arrivals",
)
return list_
airports = await my_arrivals()
pd.DataFrame(
pd.json_normalize(
airports["result"]["response"]["airport"]["pluginData"]["schedule"][
"arrivals"
]["data"]
)
)
flight.identification.id flight.identification.row flight.identification.number.default flight.identification.number.alternative flight.identification.callsign flight.identification.codeshare flight.status.live flight.status.text flight.status.icon flight.status.estimated ... flight.time.scheduled.departure flight.time.scheduled.arrival flight.time.real.departure flight.time.real.arrival flight.time.estimated.departure flight.time.estimated.arrival flight.time.other.eta flight.time.other.duration flight.aircraft.images flight.owner
0 None 5488300922 FR8125 MAY8125 RYR8125 None False Scheduled None None ... 1711986600 1711991100 None None 1.711987e+09 None None None NaN NaN
1 None 5488216841 AF6124 None None None False Scheduled None None ... 1711987200 1711991700 None None NaN None None None NaN NaN
2 None 5488418617 U24849 EC4849 EJU51KM None False Scheduled None None ... 1711987500 1711992000 None None 1.711988e+09 None None None NaN NaN
3 None 5488418658 U24988 EC4988 EJU82LE None False Scheduled None None ... 1711986900 1711992300 None None 1.711987e+09 None None None NaN NaN
4 None 5488216846 AF6126 None None None False Scheduled None None ... 1711989000 1711993500 None None NaN None None None NaN NaN
5 None 5488417705 U21311 DS1311 EZS15PY None False Scheduled None None ... 1711990500 1711995000 None None 1.711990e+09 None None None NaN NaN
6 None 5488297888 FR1995 MAY1995 RYR1995 None False Scheduled None None ... 1711989600 1711996500 None None 1.711990e+09 None None None NaN NaN
7 None 5488418631 U24851 EC4851 EJU69EW None False Scheduled None None ... 1711992000 1711996500 None None 1.711992e+09 None None None NaN NaN
8 None 5488298693 FR3358 None None None False Scheduled None None ... 1711986900 1711996800 None None 1.711987e+09 None None None NaN NaN
9 None 5488418589 U24729 EC4729 EJU89CR None False Scheduled None None ... 1711993200 1711997400 None None 1.711993e+09 None None None NaN NaN
[10 rows x 75 columns]
Airport Search¤
API Reference: fr24.json.find
from fr24.types.find import FindResult
from fr24.json import find
import pandas as pd
import httpx
async def my_find() -> FindResult:
async with httpx.AsyncClient() as client:
results = await find(client, "paris")
assert results is not None
return results
results = await my_find()
pd.DataFrame(pd.json_normalize(results["results"]))
id label type match detail.lat detail.lon detail.size
0 CDG Paris Charles de Gaulle Airport (CDG / LFPG) airport begins 49.012516 2.555752 199939
1 ORY Paris Orly Airport (ORY / LFPO) airport begins 48.723331 2.379444 87577
2 LBG Paris Le Bourget Airport (LBG / LFPB) airport begins 48.958801 2.433600 27873
3 BVA Paris Beauvais-Tille Airport (BVA / LFOB) airport begins 49.454189 2.113550 16566
4 PRX Paris Cox Field (PRX / KPRX) airport begins 33.636665 -95.450279 1402
5 XCR Paris Vatry Chalons Airport (XCR / LFOK) airport begins 48.759998 4.200000 1008
6 VIY Paris Villacoublay Velizy Air Base (VIY / LFPV) airport begins 48.774399 2.201540 993
7 PHT Paris Henry County Airport (PHT / KPHT) airport begins 36.336384 -88.384270 390
Live feed¤
API Reference: fr24.grpc.live_feed_post
Demonstrates custom bounding boxes.
import httpx
from fr24.grpc import (
live_feed_message_create,
live_feed_post,
live_feed_request_create,
)
from fr24.proto.v1_pb2 import LiveFeedResponse
async def france_data() -> LiveFeedResponse:
async with httpx.AsyncClient() as client:
message = live_feed_message_create(north=50, west=-7, south=40, east=10)
request = live_feed_request_create(message)
return await live_feed_post(client, request)
data = await france_data()
data
flights_list {
flightid: 882295486
latitude: 40.4882507
longitude: -6.38517904
track: 33
altitude: 36000
ground_speed: 454
icon: 7
timestamp: 1711960343
callsign: "BTI4PX"
extra_info {
flight: "BT766"
reg: "YL-ABL"
route {
from_: "LPA"
to: "RIX"
}
type: "BCS3"
}
}
flights_list {
flightid: 882307182
latitude: 40.1034851
longitude: -4.40472412
track: 162
...
to: "HRG"
}
type: "B738"
}
}
In JSON format:
from google.protobuf.json_format import MessageToDict
MessageToDict(data)["flightsList"]
[{'flightid': 882295486,
'latitude': 40.48825,
'longitude': -6.385179,
'track': 33,
'altitude': 36000,
'groundSpeed': 454,
'icon': 7,
'timestamp': 1711960343,
'callsign': 'BTI4PX',
'extraInfo': {'flight': 'BT766',
'reg': 'YL-ABL',
'route': {'from': 'LPA', 'to': 'RIX'},
'type': 'BCS3'}},
{'flightid': 882307182,
'latitude': 40.103485,
'longitude': -4.404724,
'track': 162,
'altitude': 32950,
'groundSpeed': 513,
'icon': 10,
'timestamp': 1711960344,
'callsign': 'EVE1123',
'extraInfo': {'flight': 'E91123',
'reg': 'EC-LZD',
'route': {'from': 'VLL', 'to': 'AGP'},
...
'callsign': 'CXI1015',
'extraInfo': {'flight': 'XR1015',
'reg': '9H-CXE',
'route': {'from': 'CGN', 'to': 'HRG'},
'type': 'B738'}}]
Nearest Flights¤
API Reference: fr24.grpc.nearest_flights_post
import httpx
from fr24.grpc import (
nearest_flights_request_create,
nearest_flights_post,
)
from fr24.proto.v1_pb2 import NearestFlightsResponse, NearestFlightsRequest, Geolocation
async def nearest_flights_data() -> NearestFlightsResponse:
async with httpx.AsyncClient() as client:
message = NearestFlightsRequest(
location=Geolocation(lat=22.31257, lon=113.92708),
radius=1000,
limit=1500
)
request = nearest_flights_request_create(message)
return await nearest_flights_post(client, request)
data = await nearest_flights_data()
data
flights_list {
flight {
flightid: 905701578
lat: 22.3095245
lon: 113.930717
track: 78
speed: 9
timestamp: 1720071634
on_ground: true
callsign: "CES502"
extra_info {
flight: "MU502"
reg: "B-1908"
route {
from: "HKG"
to: "PVG"
}
type: "B738"
logo_id: 131
}
}
distance: 504
}
flights_list {
flight {
...
logo_id: 335
}
}
distance: 783
}
Live Flight Status¤
API Reference: fr24.grpc.live_flights_status_post
import httpx
from fr24.grpc import (
live_flights_status_request_create,
live_flights_status_post,
)
from fr24.proto.v1_pb2 import LiveFlightsStatusRequest, LiveFlightsStatusResponse
async def live_flights_status_data() -> LiveFlightsStatusResponse:
async with httpx.AsyncClient() as client:
message = LiveFlightsStatusRequest(flight_ids_list=[0x35fbc363, 0x35fbf180])
request = live_flights_status_request_create(message)
return await live_flights_status_post(client, request)
data = await live_flights_status_data()
data
flights_map {
flight_id: 905703808
data {
lat: 21.7237415
lon: 114.917908
status: LIVE
}
}
flights_map {
flight_id: 905692003
data {
lat: 21.9285736
lon: 113.912445
status: LIVE
}
}
Follow Flight¤
API Reference: fr24.grpc.follow_flight_stream
Tip
This is a streaming API that repeatedly updates the aircraft state vectors.
Initial metadata (aircraft_info
, flight_plan
and flight_trail_list
)
is only sent in the first packet of data.
import httpx
from fr24.grpc import (
follow_flight_request_create,
follow_flight_stream,
)
from fr24.proto.v1_pb2 import FollowFlightRequest
async def follow_flight_data() -> None:
async with httpx.AsyncClient() as client:
message = FollowFlightRequest(flight_id=0x35fbf965)
request = follow_flight_request_create(message)
i = 0
async for response in follow_flight_stream(client, request):
print(f"##### {i} #####")
print(response)
i += 1
if i > 3:
break
await follow_flight_data()
##### 0 #####
aircraft_info {
icao_address: 5031041
type: "B744"
icon: B747
full_description: "Boeing 747-48EF"
service: CARGO
images_list {
url: "https://www.jetphotos.com/photo/11372499"
copyright: "R Skywalker"
thumbnail: "https://cdn.jetphotos.com/200/5/609890_1717848712_tb.jpg"
medium: "https://cdn.jetphotos.com/400/5/609890_1717848712.jpg"
large: "https://cdn.jetphotos.com/640/5/609890_1717848712.jpg"
}
images_list {
url: "https://www.jetphotos.com/photo/11358154"
copyright: "Tim-Patrick Müller"
thumbnail: "https://cdn.jetphotos.com/200/5/1615840_1716633484_tb.jpg"
medium: "https://cdn.jetphotos.com/400/5/1615840_1716633484.jpg"
large: "https://cdn.jetphotos.com/640/5/1615840_1716633484.jpg"
}
images_list {
url: "https://www.jetphotos.com/photo/11337719"
copyright: "Siegi N."
thumbnail: "https://cdn.jetphotos.com/200/6/417379_1714816605_tb.jpg"
medium: "https://cdn.jetphotos.com/400/6/417379_1714816605.jpg"
large: "https://cdn.jetphotos.com/640/6/417379_1714816605.jpg"
}
msn_available: true
age_available: true
registered_owners: "Network Aviation"
}
flight_plan {
}
schedule_info {
flight_number: "CC4400"
operated_by_id: 437
origin_id: 1366
actual_departure: 1720074023
}
flight_progress {
elapsed_time: 1611
}
flight_info {
flightid: 905705829
lat: 21.2512665
lon: 112.568764
track: 278
alt: 31000
speed: 512
timestamp: 1720075629
callsign: "ABD4400"
ems_availability {
amcp_availability: true
oat_availability: true
tas_availability: true
mach_availability: true
agps_availability: true
agpsdiff_availability: true
wind_dir_availability: true
wind_speed_availability: true
}
squawk_availability: true
vspeed_availability: true
airspace_availability: true
}
flight_trail_list {
snapshot_id: 1720073072
lat: 22.3014889
lon: 113.923706
heading: 340
}
flight_trail_list {
snapshot_id: 1720073114
lat: 22.3012848
lon: 113.92379
spd: 3
heading: 340
}
...
altitude: 31000
spd: 512
heading: 278
}
##### 1 #####
schedule_info {
flight_number: "CC4400"
operated_by_id: 437
origin_id: 1366
actual_departure: 1720074023
}
flight_progress {
elapsed_time: 1615
}
flight_info {
flightid: 905705829
lat: 21.2530975
lon: 112.555733
track: 278
alt: 31000
speed: 512
timestamp: 1720075634
callsign: "ABD4400"
ems_availability {
amcp_availability: true
oat_availability: true
tas_availability: true
mach_availability: true
agps_availability: true
agpsdiff_availability: true
wind_dir_availability: true
wind_speed_availability: true
}
squawk_availability: true
vspeed_availability: true
airspace_availability: true
}
##### 2 #####
schedule_info {
flight_number: "CC4400"
operated_by_id: 437
origin_id: 1366
actual_departure: 1720074023
}
flight_progress {
elapsed_time: 1619
}
flight_info {
flightid: 905705829
lat: 21.2530975
lon: 112.555733
track: 278
alt: 31000
speed: 512
timestamp: 1720075634
callsign: "ABD4400"
ems_availability {
amcp_availability: true
oat_availability: true
tas_availability: true
mach_availability: true
agps_availability: true
agpsdiff_availability: true
wind_dir_availability: true
wind_speed_availability: true
}
squawk_availability: true
vspeed_availability: true
airspace_availability: true
}
##### 3 #####
schedule_info {
flight_number: "CC4400"
operated_by_id: 437
origin_id: 1366
actual_departure: 1720074023
}
flight_progress {
elapsed_time: 1623
}
flight_info {
flightid: 905705829
lat: 21.2557068
lon: 112.537407
track: 278
alt: 31000
speed: 512
timestamp: 1720075641
callsign: "ABD4400"
...
Top Flights¤
API Reference: fr24.grpc.top_flights_post
import httpx
from fr24.grpc import (
top_flights_request_create,
top_flights_post,
)
from fr24.proto.v1_pb2 import TopFlightsRequest, TopFlightsResponse
async def top_flights_data() -> TopFlightsResponse:
async with httpx.AsyncClient() as client:
message = TopFlightsRequest(limit=10)
request = top_flights_request_create(message)
return await top_flights_post(client, request)
data = await top_flights_data()
data
scoreboard_list {
flight_id: 911336284
live_clicks: 1648
total_clicks: 6664
callsign: "LEE92"
from_iata: "QKG"
from_city: "Leeming"
type: "HUNT"
full_description: "Hawker Hunter T2"
}
scoreboard_list {
flight_id: 911326556
live_clicks: 1144
total_clicks: 8848
callsign: "SARAB"
type: "HAWK"
full_description: "British Aerospace Hawk Mk167"
}
scoreboard_list {
flight_id: 911338539
live_clicks: 904
total_clicks: 1764
flight_number: "TN80001"
callsign: "TN080001"
from_iata: "QCY"
...
to_iata: "RMQ"
to_city: "Taichung"
type: "B738"
full_description: "Boeing 737-8AL"
}
Live Trail¤
API Reference: fr24.grpc.live_trail_post
import httpx
from fr24.grpc import (
live_trail_request_create,
live_trail_post,
)
from fr24.proto.v1_pb2 import LiveTrailRequest, LiveTrailResponse
async def live_trail_data() -> LiveTrailResponse:
"""raises empty `DATA` frame error if flight_id is not live"""
async with httpx.AsyncClient() as client:
message = LiveTrailRequest(flight_id=0x35fbad0e)
request = live_trail_request_create(message)
return await live_trail_post(client, request)
data = await live_trail_data()
data
radar_records_list {
timestamp: 1720064455
lat: 30.2406578
lon: 120.420403
spd: 15
heading: 61
callsign: "CPA959"
}
radar_records_list {
timestamp: 1720064462
lat: 30.2408924
lon: 120.420937
heading: 61
callsign: "CPA959"
}
radar_records_list {
timestamp: 1720064480
lat: 30.2415791
lon: 120.422478
spd: 18
heading: 61
callsign: "CPA959"
}
radar_records_list {
timestamp: 1720064488
...
heading: 269
vspd: -960
squawk: 13874
callsign: "CPA959"
}
...