See the example gallery to learn more.
authentication
¤
Functions:
Name | Description |
---|---|
get_credentials |
Reads credentials from the environment variables, overriding it with |
login |
Read credentials and logs into the API. |
login_with_username_password |
Retrieve bearer token and subscription key from the API. |
login_with_token_subscription_key |
Login with subscription key and/or token. |
get_credentials
¤
get_credentials(
fp_config_file: Path = FP_CONFIG_FILE,
) -> TokenSubscriptionKey | UsernamePassword | None
Reads credentials from the environment variables, overriding it with the config file if it exists.
login
async
¤
login(
client: AsyncClient,
creds: TokenSubscriptionKey
| UsernamePassword
| None
| Literal["from_env"] = "from_env",
fp_config_file: Path = FP_CONFIG_FILE,
) -> None | Authentication
Read credentials and logs into the API.
By default, credentials are read from the environment variables or the
config file if creds_override
is not set. Then, if the credentials:
- username
and password
is set: makes a POST request to the login
endpoint
- subscription_key
and token
is set: returns immediately
- otherwise, None
is returned
login_with_username_password
async
¤
login_with_username_password(
client: AsyncClient, username: str, password: str
) -> Authentication
Retrieve bearer token and subscription key from the API.
Bearer: json['userData']['accessToken']
token=
query param: json['userData']['subscriptionKey']
login_with_token_subscription_key
async
¤
login_with_token_subscription_key(
_client: AsyncClient,
subscription_key: str,
token: str | None,
) -> Authentication | None
Login with subscription key and/or token. Falls back to anonymous access if token is expired or invalid.
JSON endpoints¤
json
¤
Classes:
Name | Description |
---|---|
FlightListParams |
Parameters to fetch metadata/history of flights for |
AirportListParams |
Request data to fetch metadata/history of flights |
PlaybackParams |
Request data to fetch historical track playback data for a given flight. |
FindParams |
|
Functions:
Name | Description |
---|---|
flight_list |
Query flight list data. |
airport_list |
Fetch aircraft arriving, departing or on ground at a given airport. |
playback |
Fetch historical track playback data for a given flight. |
find |
General search. |
playback_metadata_dict |
Flatten and rename important variables in the flight metadata to a |
playback_track_dict |
Flatten and rename each variable in this observation into a new dictionary. |
playback_track_ems_dict |
If the Enhanced Mode-S data is available in this observation, |
playback_df |
Parse each fr24.types.playback.TrackData in the API response into a |
flight_list_dict |
Flatten a flight entry into dict, converting fr24 hex ids into integers. |
flight_list_df |
Parse each fr24.types.flight_list.FlightListItem in the API response |
FlightListParams
dataclass
¤
FlightListParams(
reg: str | None = None,
flight: str | None = None,
page: int = 1,
limit: int = 10,
timestamp: IntoTimestamp
| Literal["now"]
| None = "now",
)
Parameters to fetch metadata/history of flights for either a given aircraft registration or flight number.
Attributes:
Name | Type | Description |
---|---|---|
reg |
str | None
|
Aircraft registration (e.g. |
flight |
str | None
|
Flight number (e.g. |
page |
int
|
Page number |
limit |
int
|
Number of results per page - use |
timestamp |
IntoTimestamp | Literal['now'] | None
|
Show flights with ATD before this Unix timestamp |
limit
class-attribute
instance-attribute
¤
limit: int = 10
Number of results per page - use 100
if authenticated.
timestamp
class-attribute
instance-attribute
¤
timestamp: IntoTimestamp | Literal['now'] | None = 'now'
Show flights with ATD before this Unix timestamp
AirportListParams
dataclass
¤
AirportListParams(
airport: str,
mode: Literal["arrivals"]
| Literal["departures"]
| Literal["ground"],
page: int = 1,
limit: int = 10,
timestamp: IntoTimestamp
| Literal["now"]
| None = "now",
)
Request data to fetch metadata/history of flights
Attributes:
Name | Type | Description |
---|---|---|
airport |
str
|
IATA airport code (e.g. |
mode |
Literal['arrivals'] | Literal['departures'] | Literal['ground']
|
arrivals, departures or on ground aircraft |
page |
int
|
Page number |
limit |
int
|
Number of results per page - use |
timestamp |
IntoTimestamp | Literal['now'] | None
|
Show flights with STA before this timestamp |
mode
instance-attribute
¤
arrivals, departures or on ground aircraft
limit
class-attribute
instance-attribute
¤
limit: int = 10
Number of results per page - use 100
if authenticated.
timestamp
class-attribute
instance-attribute
¤
timestamp: IntoTimestamp | Literal['now'] | None = 'now'
Show flights with STA before this timestamp
PlaybackParams
dataclass
¤
PlaybackParams(
flight_id: int | str,
timestamp: IntoTimestamp | None = None,
)
Request data to fetch historical track playback data for a given flight.
Attributes:
Name | Type | Description |
---|---|---|
flight_id |
int | str
|
fr24 flight id, represented in hex |
timestamp |
IntoTimestamp | None
|
Actual time of departure (ATD) of the historic flight, |
timestamp
class-attribute
instance-attribute
¤
timestamp: IntoTimestamp | None = None
Actual time of departure (ATD) of the historic flight, Unix timestamp in seconds. Optional, but it is recommended to include it.
FindParams
dataclass
¤
flight_list
async
¤
flight_list(
client: AsyncClient,
params: FlightListParams,
auth: None | Authentication = None,
) -> Annotated[Response, FlightList]
Query flight list data.
To determine if there are more pages to query, check the response .result.response.page.more.
Includes basic information such as status, O/D, scheduled/estimated/real times: see fr24.types.flight_list.FlightList for more details.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client
|
AsyncClient
|
HTTPX async client |
required |
auth
|
None | Authentication
|
Authentication data |
None
|
airport_list
async
¤
airport_list(
client: AsyncClient,
params: AirportListParams,
auth: None | Authentication = None,
) -> Annotated[Response, AirportList]
Fetch aircraft arriving, departing or on ground at a given airport.
Returns on ground/scheduled/estimated/real times: see fr24.types.flight_list.FlightListItem for more details.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client
|
AsyncClient
|
HTTPX async client |
required |
auth
|
None | Authentication
|
Authentication data |
None
|
Returns:
Type | Description |
---|---|
Annotated[Response, AirportList]
|
the raw binary response, representing a JSON-encoded fr24.types.flight_list.FlightList. |
playback
async
¤
playback(
client: AsyncClient,
params: PlaybackParams,
auth: None | Authentication = None,
) -> Annotated[Response, Playback]
Fetch historical track playback data for a given flight.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client
|
AsyncClient
|
HTTPX async client |
required |
auth
|
None | Authentication
|
Authentication data |
None
|
find
async
¤
find(
client: AsyncClient,
params: FindParams,
auth: None | Authentication = None,
) -> Annotated[Response, Find]
General search.
playback_metadata_dict
¤
playback_metadata_dict(
flight: FlightData,
) -> dict[str, Any]
Flatten and rename important variables in the flight metadata to a dictionary.
playback_track_dict
¤
playback_track_dict(
point: TrackData,
) -> PlaybackTrackRecord
Flatten and rename each variable in this observation into a new dictionary.
Note
The JSON response claims that heading
is available, but ADS-B only
transmits the ground track.
Heading
is only available in EMS data.
We rename it to track
to avoid confusion.
playback_track_ems_dict
¤
playback_track_ems_dict(
point: TrackData,
) -> PlaybackTrackEMSRecord | None
If the Enhanced Mode-S data is available in this observation,
flatten and rename each variable to a dictionary. Otherwise, return None
.
playback_df
¤
playback_df(data: Playback) -> DataFrame
Parse each fr24.types.playback.TrackData in the API response into a dataframe.
If the response is empty, a warning is logged and an empty table is returned
flight_list_dict
¤
flight_list_dict(entry: FlightListItem) -> FlightListRecord
Flatten a flight entry into dict, converting fr24 hex ids into integers.
flight_list_df
¤
flight_list_df(data: FlightList) -> DataFrame
Parse each fr24.types.flight_list.FlightListItem in the API response into a polars dataframe.
If the response is empty, a warning is logged and an empty table is returned
gRPC endpoints¤
grpc
¤
Endpoint: https://data-feed.flightradar24.com
Service name: fr24.feed.api.v1.Feed
Methods:
LiveFeed
Playback
NearestFlights
LiveFlightsStatus
FollowFlight
TopFlights
LiveTrail
HistoricTrail
FetchSearchIndex
FlightDetails
PlaybackFlight
Classes:
Name | Description |
---|---|
BoundingBox |
|
IntoLiveFeedRequest
module-attribute
¤
IntoLiveFeedRequest: TypeAlias = Union[
SupportsToProto[LiveFeedRequest], LiveFeedRequest
]
BBOXES_WORLD_STATIC
module-attribute
¤
BBOXES_WORLD_STATIC = [
BoundingBox(
-90,
90,
LNGS_WORLD_STATIC[i],
LNGS_WORLD_STATIC[i + 1],
)
for i in range(len(LNGS_WORLD_STATIC) - 1)
]
Default static bounding boxes covering the entire world
BBOX_FRANCE_UIR
module-attribute
¤
BBOX_FRANCE_UIR = BoundingBox(42, 52, -8, 10)
Bounding box for france UIR
IntoPlaybackRequest
module-attribute
¤
IntoPlaybackRequest: TypeAlias = Union[
SupportsToProto[PlaybackRequest],
PlaybackRequest,
LiveFeedPlaybackParams,
]
IntoNearestFlightsRequest
module-attribute
¤
IntoNearestFlightsRequest: TypeAlias = Union[
SupportsToProto[NearestFlightsRequest],
NearestFlightsRequest,
]
IntoLiveFlightsStatusRequest
module-attribute
¤
IntoLiveFlightsStatusRequest: TypeAlias = Union[
SupportsToProto[LiveFlightsStatusRequest],
LiveFlightsStatusRequest,
]
IntoFetchSearchIndexRequest
module-attribute
¤
IntoFetchSearchIndexRequest: TypeAlias = Union[
SupportsToProto[FetchSearchIndexRequest],
FetchSearchIndexRequest,
]
IntoFollowFlightRequest
module-attribute
¤
IntoFollowFlightRequest: TypeAlias = Union[
SupportsToProto[FollowFlightRequest],
FollowFlightRequest,
]
IntoTopFlightsRequest
module-attribute
¤
IntoTopFlightsRequest: TypeAlias = Union[
SupportsToProto[TopFlightsRequest], TopFlightsRequest
]
IntoLiveTrailRequest
module-attribute
¤
IntoLiveTrailRequest: TypeAlias = Union[
SupportsToProto[LiveTrailRequest], LiveTrailRequest
]
IntoHistoricTrailRequest
module-attribute
¤
IntoHistoricTrailRequest: TypeAlias = Union[
SupportsToProto[HistoricTrailRequest],
HistoricTrailRequest,
]
IntoFlightDetailsRequest
module-attribute
¤
IntoFlightDetailsRequest: TypeAlias = Union[
SupportsToProto[FlightDetailsRequest],
FlightDetailsRequest,
]
IntoPlaybackFlightRequest
module-attribute
¤
IntoPlaybackFlightRequest: TypeAlias = Union[
SupportsToProto[PlaybackFlightRequest],
PlaybackFlightRequest,
]
BoundingBox
¤
LiveFeedParams
dataclass
¤
LiveFeedParams(
bounding_box: BoundingBox = BBOX_FRANCE_UIR,
stats: bool = False,
limit: int = 1500,
maxage: int = 14400,
fields: set[LiveFeedField] = lambda: {
"flight",
"reg",
"route",
"type",
}(),
)
Bases: SupportsToProto[LiveFeedRequest]
Methods:
Name | Description |
---|---|
to_proto |
|
Attributes:
Name | Type | Description |
---|---|---|
bounding_box |
BoundingBox
|
|
stats |
bool
|
Whether to include stats in the given area. |
limit |
int
|
Maximum number of flights (should be set to 1500 for unauthorized users, |
maxage |
int
|
Maximum time since last message update, seconds. |
fields |
set[LiveFeedField]
|
Fields to include. |
stats
class-attribute
instance-attribute
¤
stats: bool = False
Whether to include stats in the given area.
limit
class-attribute
instance-attribute
¤
limit: int = 1500
Maximum number of flights (should be set to 1500 for unauthorized users, 2000 for authorized users).
maxage
class-attribute
instance-attribute
¤
maxage: int = 14400
Maximum time since last message update, seconds.
fields
class-attribute
instance-attribute
¤
fields: set[LiveFeedField] = field(
default_factory=lambda: {
"flight",
"reg",
"route",
"type",
}
)
Fields to include.
For unauthenticated users, a maximum of 4 fields can be included.
When authenticated, squawk
, vspeed
, airspace
, logo_id
and age
can be included.
LiveFeedPlaybackParams
dataclass
¤
LiveFeedPlaybackParams(
bounding_box: BoundingBox = BBOX_FRANCE_UIR,
stats: bool = False,
limit: int = 1500,
maxage: int = 14400,
fields: set[LiveFeedField] = lambda: {
"flight",
"reg",
"route",
"type",
}(),
timestamp: IntoTimestamp | Literal["now"] = "now",
duration: int = 7,
hfreq: int | None = None,
)
Bases: LiveFeedParams
, SupportsToProto[PlaybackRequest]
Methods:
Name | Description |
---|---|
to_proto |
|
Attributes:
Name | Type | Description |
---|---|---|
timestamp |
IntoTimestamp | Literal['now']
|
Start timestamp |
duration |
int
|
Duration of prefetch, |
hfreq |
int | None
|
High frequency mode |
bounding_box |
BoundingBox
|
|
stats |
bool
|
Whether to include stats in the given area. |
limit |
int
|
Maximum number of flights (should be set to 1500 for unauthorized users, |
maxage |
int
|
Maximum time since last message update, seconds. |
fields |
set[LiveFeedField]
|
Fields to include. |
timestamp
class-attribute
instance-attribute
¤
timestamp: IntoTimestamp | Literal['now'] = 'now'
Start timestamp
duration
class-attribute
instance-attribute
¤
duration: int = 7
Duration of prefetch, floor(7.5*(multiplier))
seconds
For 1x playback, this should be 7 seconds.
stats
class-attribute
instance-attribute
¤
stats: bool = False
Whether to include stats in the given area.
limit
class-attribute
instance-attribute
¤
limit: int = 1500
Maximum number of flights (should be set to 1500 for unauthorized users, 2000 for authorized users).
maxage
class-attribute
instance-attribute
¤
maxage: int = 14400
Maximum time since last message update, seconds.
fields
class-attribute
instance-attribute
¤
fields: set[LiveFeedField] = field(
default_factory=lambda: {
"flight",
"reg",
"route",
"type",
}
)
Fields to include.
For unauthenticated users, a maximum of 4 fields can be included.
When authenticated, squawk
, vspeed
, airspace
, logo_id
and age
can be included.
NearestFlightsParams
dataclass
¤
LiveFlightsStatusParams
dataclass
¤
LiveFlightsStatusParams(flight_ids: Sequence[IntoFlightId])
Bases: SupportsToProto[LiveFlightsStatusRequest]
Methods:
Name | Description |
---|---|
to_proto |
|
Attributes:
Name | Type | Description |
---|---|---|
flight_ids |
Sequence[IntoFlightId]
|
List of flight IDs to get status for |
flight_ids
instance-attribute
¤
flight_ids: Sequence[IntoFlightId]
List of flight IDs to get status for
FollowFlightParams
dataclass
¤
FollowFlightParams(
flight_id: IntoFlightId,
restriction_mode: ValueType | str | bytes = NOT_VISIBLE,
)
Bases: SupportsToProto[FollowFlightRequest]
Methods:
Name | Description |
---|---|
to_proto |
|
Attributes:
Name | Type | Description |
---|---|---|
flight_id |
IntoFlightId
|
Flight ID to fetch details for. |
restriction_mode |
ValueType | str | bytes
|
FAA LADD visibility mode. |
flight_id
instance-attribute
¤
flight_id: IntoFlightId
Flight ID to fetch details for.
Must be live, or the response will contain an empty DATA
frame error.
TopFlightsParams
dataclass
¤
TopFlightsParams(limit: int = 10)
Bases: SupportsToProto[TopFlightsRequest]
Methods:
Name | Description |
---|---|
to_proto |
|
Attributes:
Name | Type | Description |
---|---|---|
limit |
int
|
Maximum number of top flights to return (1-10) |
FlightDetailsParams
dataclass
¤
FlightDetailsParams(
flight_id: IntoFlightId,
restriction_mode: ValueType | str | bytes = NOT_VISIBLE,
verbose: bool = True,
)
Bases: SupportsToProto[FlightDetailsRequest]
Methods:
Name | Description |
---|---|
to_proto |
|
Attributes:
Name | Type | Description |
---|---|---|
flight_id |
IntoFlightId
|
Flight ID to fetch details for. |
restriction_mode |
ValueType | str | bytes
|
FAA LADD visibility mode. |
verbose |
bool
|
Whether to include [fr24.proto.v1_pb2.FlightDetailsResponse.flight_plan] |
flight_id
instance-attribute
¤
flight_id: IntoFlightId
Flight ID to fetch details for.
Must be live, or the response will contain an empty DATA
frame error.
PlaybackFlightParams
dataclass
¤
PlaybackFlightParams(
flight_id: IntoFlightId, timestamp: IntoTimestamp
)
Bases: SupportsToProto[PlaybackFlightRequest]
Methods:
Name | Description |
---|---|
to_proto |
|
Attributes:
Name | Type | Description |
---|---|---|
flight_id |
IntoFlightId
|
Flight ID to fetch details for. |
timestamp |
IntoTimestamp
|
Actual time of departure (ATD) of the historic flight, |
flight_id
instance-attribute
¤
flight_id: IntoFlightId
Flight ID to fetch details for.
Must not be live, or the response will contain an empty DATA
frame error.
timestamp
instance-attribute
¤
timestamp: IntoTimestamp
Actual time of departure (ATD) of the historic flight, Unix timestamp in seconds.
construct_request
¤
construct_request(
method_name: str,
message: T,
auth: None | Authentication = None,
) -> Request
Construct the gRPC request with encoded gRPC body.
to_protobuf_enum
¤
live_feed
async
¤
live_feed(
client: AsyncClient,
message: IntoLiveFeedRequest,
auth: None | Authentication = None,
) -> Annotated[Response, LiveFeedResponse]
live_feed_position_buffer_dict
¤
live_feed_position_buffer_dict(
position_buffer: PositionBuffer,
) -> list[RecentPositionRecord]
live_feed_flightdata_dict
¤
live_feed_flightdata_dict(lfr: Flight) -> FlightRecord
Convert the protobuf message to a dictionary.
live_feed_playback
async
¤
live_feed_playback(
client: AsyncClient,
message: IntoPlaybackRequest,
auth: None | Authentication = None,
) -> Annotated[Response, LiveFeedResponse]
nearest_flights
async
¤
nearest_flights(
client: AsyncClient,
message: IntoNearestFlightsRequest,
auth: None | Authentication = None,
) -> Annotated[Response, NearestFlightsResponse]
nearest_flights_nearbyflight_dict
¤
nearest_flights_nearbyflight_dict(
nf: NearbyFlight,
) -> NearbyFlightRecord
live_flights_status
async
¤
live_flights_status(
client: AsyncClient,
message: IntoLiveFlightsStatusRequest,
auth: None | Authentication = None,
) -> Annotated[Response, LiveFlightsStatusResponse]
live_flights_status_flightstatusdata_dict
¤
live_flights_status_flightstatusdata_dict(
flight_status: LiveFlightStatus,
) -> LiveFlightStatusRecord
search_index
async
¤
search_index(
client: AsyncClient,
message: IntoFetchSearchIndexRequest,
auth: None | Authentication = None,
) -> Annotated[Response, FetchSearchIndexResponse]
Unstable API: gateway timeout.
follow_flight_stream
async
¤
follow_flight_stream(
client: AsyncClient,
message: IntoFollowFlightRequest,
auth: None | Authentication = None,
) -> AsyncGenerator[Annotated[bytes, ProtoError]]
top_flights
async
¤
top_flights(
client: AsyncClient,
message: IntoTopFlightsRequest,
auth: None | Authentication = None,
) -> Annotated[Response, TopFlightsResponse]
live_trail
async
¤
live_trail(
client: AsyncClient,
message: IntoLiveTrailRequest,
auth: None | Authentication = None,
) -> Annotated[Response, LiveTrailResponse]
Unstable API: returns empty DATA
frame as of Sep 2024
Contains empty DATA
frame error if flight_id is not live
historic_trail
async
¤
historic_trail(
client: AsyncClient,
message: IntoHistoricTrailRequest,
auth: None | Authentication = None,
) -> Annotated[Response, HistoricTrailResponse]
Unstable API: returns empty DATA
frame
flight_details
async
¤
flight_details(
client: AsyncClient,
message: IntoFlightDetailsRequest,
auth: None | Authentication = None,
) -> Annotated[Response, FlightDetailsResponse]
contains empty DATA
frame error if flight_id is not live
flight_details_dict
¤
flight_details_dict(
response: FlightDetailsResponse,
) -> FlightDetailsRecord
ems_dict
¤
ems_dict(ems: EMSInfo) -> EMSRecord
Transform Enhanced Mode-S data in the protobuf message into a dictionary.
This is similar to EMS data in the JSON API response, specifically fr24.json.playback_track_ems_dict, which gets converted to fr24.types.cache.PlaybackTrackEMSRecord. However, several fields are missing:
timestamp
autopilot
track
roll
precision
emergency
tcas_acas
heading
playback_flight
async
¤
playback_flight(
client: AsyncClient,
message: IntoPlaybackFlightRequest,
auth: None | Authentication = None,
) -> Annotated[Response, PlaybackFlightResponse]
contains empty DATA
frame error if flight_id is live
playback_flight_dict
¤
playback_flight_dict(
response: PlaybackFlightResponse,
) -> PlaybackFlightRecord