### Quick start: Flight summary & tracks Source: https://fr24api.flightradar24.com/docs/sdk/js Example of how to get a light summary for flights and retrieve detailed tracks for a specific flight. ```APIDOC import SDK from '@flightradar24/fr24sdk'; const client = new SDK.Client({ apiToken: process.env.FR24_API_TOKEN }); try { // Retrieve a light summary for one or more flights const summary = await client.flightSummary.getLight({ flightIds: ['391fdd79'], // example flight_id }); // Retrieve tracks for a flight const tracks = await client.flightTracks.get({ flightId: '391fdd79', }); console.log(summary, tracks); } finally { client.close(); } ``` -------------------------------- ### Python SDK Example Source: https://fr24api.flightradar24.com/docs/getting-started This code snippet demonstrates how to use the FR24 Python SDK to fetch live flight positions. Ensure you have installed the SDK and replaced 'your_api_token' with your actual token. ```APIDOC ## Making Your First API Call in Python Our Python SDK can help you to ease the way of the FR24 API usage. Simply install the library, and run the code sample. #### Prerequisites: * Python installed on your machine. * `requests` library installed (`pip install requests`). ```python from fr24sdk.client import Client with Client(api_token="your_api_token") as client: result = client.live.flight_positions.get_light(bounds="50.682,46.218,14.422,22.243") # N, S, W, E print(result) ``` ``` -------------------------------- ### Install and Use FR24 SDK in Python Source: https://fr24api.flightradar24.com/docs/getting-started Install the FR24 SDK and use it to fetch live flight positions within specified geographical bounds. Ensure you have Python and the 'requests' library installed. ```bash pip install fr24sdk ``` ```python from fr24sdk.client import Client with Client(api_token="your_api_token") as client: result = client.live.flight_positions.get_light(bounds="50.682,46.218,14.422,22.243") # N, S, W, E print(result) ``` -------------------------------- ### Installation Source: https://fr24api.flightradar24.com/docs/sdk/python Install the latest release of the `fr24sdk` from PyPI using pip or uv. ```APIDOC ## Installation `# using pip pip install fr24sdk # or using uv uv pip install fr24sdk` ``` -------------------------------- ### Install JavaScript SDK Source: https://fr24api.flightradar24.com/docs/sdk/js Install the Flightradar24 JavaScript SDK using npm. ```bash npm install @flightradar24/fr24sdk ``` -------------------------------- ### Install FR24 Node SDK Source: https://fr24api.flightradar24.com/docs/endpoints/flight-positions-batch-query Install the FR24 Node SDK and dotenv for managing API tokens. Ensure you have Node.js and an active FR24 API subscription. ```bash npm install @flightradar24/fr24sdk dotenv ``` -------------------------------- ### Install fr24sdk using pip Source: https://fr24api.flightradar24.com/docs/sdk/python Install the latest release of the fr24sdk from PyPI using pip or uv. ```bash # using pip pip install fr24sdk # or using uv uv pip install fr24sdk ``` -------------------------------- ### Install fr24sdk Source: https://fr24api.flightradar24.com/docs/examples-and-use-cases/use-case-calculating-calculating-the-farthest-flight Install the FR24 API Python SDK using pip. Ensure you are using Python 3.9 or later. ```bash pip install fr24sdk ``` -------------------------------- ### Python Example: Fetching Flight Positions Over a Date Range Source: https://fr24api.flightradar24.com/docs/endpoints/flight-positions-batch-query Demonstrates how to retrieve historical flight data over a specified date range using the FR24 Python SDK. Ensure you have Python 3.9+, an active API subscription, and the SDK installed. Store your API token in an environment variable for security. ```python from fr24sdk.api import FR24API from datetime import datetime, timedelta # Initialize the API with your token (reads from FR24_API_TOKEN env var by default) api = FR24API() async def get_flight_positions_over_time(start_time: datetime, end_time: datetime, interval_minutes: int = 15): """Fetches flight positions over a specified time range with a given interval.""" current_time = start_time all_flight_positions = [] while current_time <= end_time: try: # Fetch data for the current timestamp # You can add other parameters like 'bounds', 'flights', 'callsigns', etc. flight_positions = await api.get_flight_positions(timestamp=int(current_time.timestamp())) all_flight_positions.extend(flight_positions) print(f"Fetched {len(flight_positions)} positions at {current_time}") except Exception as e: print(f"Error fetching data at {current_time}: {e}") # Move to the next interval current_time += timedelta(minutes=interval_minutes) return all_flight_positions # Example usage: # Define your date range and interval start_dt = datetime(2023, 10, 26, 10, 0, 0) end_dt = datetime(2023, 10, 26, 12, 0, 0) interval = 15 # minutes # Run the async function (requires an async event loop) # import asyncio # flight_data = asyncio.run(get_flight_positions_over_time(start_dt, end_dt, interval)) # print(f"Total flight positions collected: {len(flight_data)}") ``` -------------------------------- ### Full Example: Flight Geofence Alerting Source: https://fr24api.flightradar24.com/docs/examples-and-use-cases/use-case-triggering-alerts-when-a-flight-enters-a-circular-area This comprehensive script monitors live flights within a specified circular geofence and triggers alerts when a flight enters the area. It includes setup, geometry calculations, alert processing, and a continuous monitoring loop. Ensure the FR24_API_TOKEN environment variable is set. ```python import os import time import logging from math import radians, sin, cos, sqrt, atan2 from typing import Optional, Dict, Any # --- SDK import --- from fr24sdk.client import Client from fr24sdk.models.flight import FlightSummaryLight # --- Config --- CENTER_LAT = 52.5200 CENTER_LON = 13.4050 RADIUS_KM = 50 POLLING_SECONDS = 5 API_TOKEN = os.environ.get("FR24_API_TOKEN", "your_api_token_here") logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") # --- Geometry --- def haversine_km(lat1: float, lon1: float, lat2: float, lon2: float) -> float: R = 6371.0 dlat = radians(lat2 - lat1) dlon = radians(lon2 - lon1) a = sin(dlat/2)**2 + cos(radians(lat1)) * cos(radians(lat2)) * sin(dlon/2)**2 c = 2 * atan2(sqrt(a), sqrt(1 - a)) return R * c def is_inside_circle(flat: float, flon: float) -> bool: return haversine_km(flat, flon, CENTER_LAT, CENTER_LON) <= RADIUS_KM def flights_in_circle(flights: Optional[list[FlightSummaryLight]]) -> FlightSummaryLight: for flight in flights: lat = flight.lat lon = flight.lon if lat is not None and lon is not None and is_inside_circle(lat, lon): yield flight # --- Bounds helper --- def make_bounds(center_lat: float, center_lon: float, lat_delta: float = 1.0, lon_delta: float = 1.0) -> str: north = center_lat + lat_delta south = center_lat - lat_delta west = center_lon - lon_delta east = center_lon + lon_delta return f"{north},{south},{west},{east}" BOUNDS = make_bounds(CENTER_LAT, CENTER_LON) # --- Alerts --- alerted: set[str] = set() def send_alert(flight: dict) -> None: logging.info("ALERT ✈️ Flight %s entered the area", flight.fr24_id) def process_alerts(flights: FlightSummaryLight) -> None: for flight in flights: flight_id = flight.fr24_id if not flight_id: continue if flight_id in alerted: continue send_alert(flight) alerted.add(flight_id) # --- Main loop --- def monitor_geofence() -> None: client = Client(api_token=API_TOKEN) while True: try: flights = client.live.flight_positions.get_light(bounds=BOUNDS) inside = list(flights_in_circle(flights.data)) if inside: process_alerts(inside) time.sleep(POLLING_SECONDS) except Exception as exc: logging.error("Error during polling: %s", exc) time.sleep(POLLING_SECONDS) if __name__ == "__main__": monitor_geofence() ``` -------------------------------- ### Example API Usage Output Source: https://fr24api.flightradar24.com/docs/credit-overview This is an example of the JSON output you might receive when calling the /usage endpoint, showing request counts and credits used for a specific endpoint. ```json { "data": [{ "endpoint": "historic/flight-positions/full?{filters}", "request_count": 1, "credits": 80 }] } ``` -------------------------------- ### Example Response - Flight Summary Full Source: https://fr24api.flightradar24.com/docs/endpoints/flight-summary This example demonstrates the JSON response for a 'Full' flight summary, including additional fields like IATA codes, runway information, and flight distances. ```json { "data": [ { "fr24_id": "0987654321", "flight": "SK1415", "callsign": "SAS1415", "operated_as": "SAS", "painted_as": "SAS", "type": "A20N", "reg": "SE-DOY", "orig_icao": "ESSA", "orig_iata": "ARN", "datetime_takeoff": "2023-01-27T05:15:22", "runway_takeoff": "12R", "dest_icao": "EKCH", "dest_iata": "CPH", "dest_icao_actual": "EPWA", "dest_iata_actual": "WAW", "datetime_landed": "2023-01-27T06:15:10", "runway_landed": "27L", "flight_time": 3600, "actual_distance": 1007.74, "circle_distance": 6245, "category": "Passenger", "hex": "4A91F9", "first_seen": "2023-01-27T05:06:22", "last_seen": "2023-01-27T06:18:10", "flight_ended": "true" } ] } ``` -------------------------------- ### Example Sandbox API Call - Flight Positions Source: https://fr24api.flightradar24.com/docs/sandbox-environment This example demonstrates a sandbox API call for flight positions. Note that query parameters are ignored in the sandbox environment, and responses are static. ```http https://fr24api.flightradar24.com/api/live/flight-positions/full?bounds=50.682,46.218,14.422,22.243 ``` ```json { "data": [ { "fr24_id": "333ca4a2", "flight": "SK7679", "callsign": "SAS7679", "lat": 35.34722, "lon": -7.90277, "track": 219, "alt": 37000, "gspeed": 440, "vspeed": 64, "squawk": "0734", "timestamp": "2024-10-10T08:08:12Z", "source": "ADSB", "hex": "4CAD41", "type": "A20N", "reg": "EI-SIN", "painted_as": "SAS", "operating_as": "SL", "orig_iata": "ARN", "orig_icao": "ESSA", "dest_iata": "FUE", "dest_icao": "GCFV", "eta": "2023-12-15T14:47:28Z" } ] } ``` -------------------------------- ### Python Example: Retrieving Flight Positions Over a Date Range Source: https://fr24api.flightradar24.com/docs/endpoints/flight-positions-batch-query Example demonstrating how to fetch historical flight data over a date range using the FR24 Python SDK. This involves setting objectives, defining the date range and interval, optimizing parameters, and implementing efficient functions for data aggregation. ```APIDOC ## Python Example Using the FR24 Python SDK ### Prerequisites * Python **3.9+** * An active FR24 API subscription and API token * FR24 Python SDK installed: `pip install fr24sdk` ### Usage Recommended: store your token in an environment variable: `export FR24_API_TOKEN="your_api_token_here" ` ``` -------------------------------- ### Example Response - Flight Summary Light Source: https://fr24api.flightradar24.com/docs/endpoints/flight-summary This is an example of the JSON response structure for a 'Light' flight summary. Note that fields like `destination_icao_actual` may be null if not applicable or available. ```json { "data": [ { "fr24_id": "1234567890", "flight": "SK1415", "callsign": "SAS1415", "operated_as": "SAS", "painted_as": "SAS", "type": "A20N", "reg": "SE-DOY", "origin_icao": "ESSA", "datetime_takeoff": "2023-01-27T05:15:22", "destination_icao": "EKCH", "destination_icao_actual": "EPWA", "datetime_landed": "2023-01-27T06:15:10", "hex": "4A91F9", "first_seen": "2023-01-27T05:06:22", "last_seen": "2023-01-27T06:18:10", "flight_ended": "true" } ] } ``` -------------------------------- ### Example Sandbox API Call - Airlines Source: https://fr24api.flightradar24.com/docs/sandbox-environment This example shows how to call a sandbox endpoint for airline data. Sandbox endpoints ignore query parameters and always return the same static response. ```http https://fr24api.flightradar24.com/api/static/airlines/AAL/light ``` ```json { "name": "American Airlines", "iata": "AA", "icao": "AAL" } ``` -------------------------------- ### Set API Token (.env file) Source: https://fr24api.flightradar24.com/docs/sdk/js Use a .env file with the dotenv package to manage your API token. Install dotenv with `npm i dotenv` and create a .env file with your token. ```dotenv FR24_API_TOKEN=your_actual_token_here ``` -------------------------------- ### Get Flight Summary and Tracks using fr24sdk Source: https://fr24api.flightradar24.com/docs/sdk/python Fetch flight summaries and tracks using client.flight_summary.get_light() and client.flight_tracks.get() respectively. Requires flight IDs. ```python from fr24sdk.client import Client with Client() as client: summary = client.flight_summary.get_light(flight_ids=["391fdd79"]) # example flight_id tracks = client.flight_tracks.get(flight_id=["391fdd79"]) print(summary, tracks) ``` -------------------------------- ### Constructing an API Request Source: https://fr24api.flightradar24.com/docs/getting-started Details on how to construct a GET request to the FR24 API, including the base URL, required headers, and parameter usage. ```APIDOC ## Constructing the API request Our API adheres to standard RESTful principles, making it intuitive and easy to integrate. Here's how to construct a request: * **Endpoint URL:** The base URL for all API requests is `https://fr24api.flightradar24.com/api`. * **HTTP Method:** `GET` * **Request Headers:** Include your API token in the header as `Authorization: Bearer ` and API version as `API Version: v1` * **Request parameters:** The API uses path and query parameters to pass data. Ensure that the required parameters are included in the URL or as query parameters. Check our endpoints article for details on how to construct the requests. ``` -------------------------------- ### Python Example: Using 'limit' for Flight Positions Source: https://fr24api.flightradar24.com/docs/credit-overview Demonstrates how to use the 'limit' parameter in a Python script to restrict the number of results returned by the historic flight positions API endpoint, thereby controlling credit consumption. Ensure your API token is correctly set. ```python import requests import json # Define the API token and endpoint URL API_TOKEN = '' BASE_URL = 'https://fr24api.flightradar24.com/api' ENDPOINT = '/historic/flight-positions/full' # Define the headers, including the Authorization header with your API token headers = { 'Accept': 'application/json', 'Authorization': 'Bearer {API_TOKEN}', 'Accept-Version': 'v1' } # Define any query parameters params = { 'bounds': '50.682,46.218,14.422,22.243', 'timestamp': '1702383145', 'limit': 10 } # Construct the full URL url = f"{BASE_URL}{ENDPOINT}" # Make the GET request to the API response = requests.get(url, headers=headers, params=params) # Check if the request was successful if response.status_code == 200: # Parse and print the JSON response response_data = response.json() print("Response Data:") print(json.dumps(response_data, indent=2)) else: print(f"Error: {response.status_code}") print(response.text) ``` -------------------------------- ### Get Live Flight Positions in a Bounding Box using fr24sdk Source: https://fr24api.flightradar24.com/docs/sdk/python Query live flight positions within a specified bounding box using client.live.flight_positions.get_light(). The bounds format is N, S, W, E. ```python from fr24sdk.client import Client bounds = "50.682,46.218,14.422,22.243" # N, S, W, E with Client() as client: flights = client.live.flight_positions.get_light(bounds=bounds) print(f"Flights returned: {len(flights.data)}") ``` -------------------------------- ### Get Flight Summary and Tracks Source: https://fr24api.flightradar24.com/docs/sdk/js Retrieve a light summary for one or more flights using their IDs, and fetch detailed tracks for a specific flight. Ensure the client is closed after operations. ```javascript import SDK from '@flightradar24/fr24sdk'; const client = new SDK.Client({ apiToken: process.env.FR24_API_TOKEN }); try { // Retrieve a light summary for one or more flights const summary = await client.flightSummary.getLight({ flightIds: ['391fdd79'], // example flight_id }); // Retrieve tracks for a flight const tracks = await client.flightTracks.get({ flightId: '391fdd79', }); console.log(summary, tracks); } finally { client.close(); } ``` -------------------------------- ### Flight summary light Source: https://fr24api.flightradar24.com/docs/endpoints Returns key timings and locations of aircraft takeoffs and landings alongside all primary flight, aircraft, and operator information. Both real-time and historical data are available. Data is available starting from 2022-06-01 and will be extended further in the near future. ```APIDOC ## Flight summary light ### Description Returns key timings and locations of aircraft takeoffs and landings alongside all primary flight, aircraft, and operator information. Both real-time and historical data are available. Data is available starting from 2022-06-01 and will be extended further in the near future. ### Method GET ### Endpoint /flight/summary/light ``` -------------------------------- ### Flight summary full Source: https://fr24api.flightradar24.com/docs/endpoints Returns comprehensive timings and locations of aircraft takeoffs and landings, including detailed flight, aircraft, and operator information. Both real-time and extensive historical data are available. Data is available starting from 2022-06-01 and will be extended further in the near future. ```APIDOC ## Flight summary full ### Description Returns comprehensive timings and locations of aircraft takeoffs and landings, including detailed flight, aircraft, and operator information. Both real-time and extensive historical data are available. Data is available starting from 2022-06-01 and will be extended further in the near future. ### Method GET ### Endpoint /flight/summary/full ``` -------------------------------- ### Initialize FR24 SDK Client Source: https://fr24api.flightradar24.com/docs/examples-and-use-cases/use-case-triggering-alerts-when-a-flight-enters-a-circular-area Import necessary libraries and initialize the FR24 API client. Ensure your API token is set as an environment variable or provided directly. ```python import os import logging from fr24sdk.client import Client from fr24sdk.models.flight import FlightSummaryLight logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") FR24_API_TOKEN = os.environ.get("FR24_API_TOKEN", "your_api_token_here") client = Client(api_token=FR24_API_TOKEN) ``` -------------------------------- ### Initialize fr24sdk Client with Authentication Source: https://fr24api.flightradar24.com/docs/sdk/python Initialize the Client object, either by reading the token from the FR24_API_TOKEN environment variable or by passing the token explicitly. ```python from fr24sdk.client import Client # Option A: token from FR24_API_TOKEN env var client = Client() # Option B: pass token explicitly client = Client(api_token="your_actual_token_here") ``` -------------------------------- ### Python: Main Execution Block Source: https://fr24api.flightradar24.com/docs/endpoints/flight-summary Sets up API key and headers, defines flight route and date, calls functions to fetch flight IDs, retrieve tracks, and plot them on a map. Requires replacement of 'your_api_key'. ```python def main(): API_KEY = "your_api_key" # Replace with your actual API key headers = { "Authorization": f"Bearer {API_KEY}", "Accept": "application/json", "Accept-Version": "v1" } # Example: All flights departing from LHR to JFK on 2025-01-05 origin = "LHR" destination = "JFK" date_str = "2025-01-05" route = f"{origin}-{destination}" print(f"Fetching flights for route {route} on date {date_str} ...") flight_ids = get_flights_for_airport_date(route, date_str, headers) print(f"Found {len(flight_ids)} flights. Fetching tracks now...") flight_tracks = get_flight_tracks(flight_ids, headers) print(f"Fetched tracks for {len(flight_tracks)} flights.") plot_flight_tracks_on_map(flight_tracks, output_html="all_flight_tracks.html") if __name__ == "__main__": main() ``` -------------------------------- ### Authentication - .env with dotenv Source: https://fr24api.flightradar24.com/docs/sdk/js Use a .env file with the dotenv package for authentication. ```APIDOC npm i dotenv # .env file: FR24_API_TOKEN=your_actual_token_here ``` -------------------------------- ### Get Airport Details using fr24sdk Source: https://fr24api.flightradar24.com/docs/sdk/python Fetch full airport details by ICAO code using the client.airports.get_full() method. The result is a typed object with airport attributes. ```python from fr24sdk.client import Client with Client() as client: waw = client.airports.get_full("WAW") print(waw.name, waw.icao, waw.city, waw.country, waw.lat, waw.lon) ``` -------------------------------- ### Historic flights events full Source: https://fr24api.flightradar24.com/docs/endpoints Returns selected historical flight events with detailed flight information. Data is available starting from 2022-06-01 and will be extended further in the near future. ```APIDOC ## Historic flights events full ### Description Returns selected historical flight events with detailed flight information. Data is available starting from 2022-06-01 and will be extended further in the near future. ### Method GET ### Endpoint /historic/flights/events/full ``` -------------------------------- ### Authentication Source: https://fr24api.flightradar24.com/docs/sdk/python Set your API token as an environment variable (`FR24_API_TOKEN`) or pass it directly to the `Client` constructor. ```APIDOC ## Authentication `# macOS/Linux export FR24_API_TOKEN="your_actual_token_here" # Windows (PowerShell) $Env:FR24_API_TOKEN="your_actual_token_here"` ```python from fr24sdk.client import Client # Option A: token from FR24_API_TOKEN env var client = Client() # Option B: pass token explicitly client = Client(api_token="your_actual_token_here") ``` `FR24_API_TOKEN` is the environment variable used by the SDK. ``` -------------------------------- ### Historic flight events light Source: https://fr24api.flightradar24.com/docs/endpoints Returns selected historical flight events with detailed flight information. Data is available starting from 2022-06-01 and will be extended further in the near future. ```APIDOC ## Historic flight events light ### Description Returns selected historical flight events with detailed flight information. Data is available starting from 2022-06-01 and will be extended further in the near future. ### Method GET ### Endpoint /historic/flight/events/light ``` -------------------------------- ### Get Airport Details Source: https://fr24api.flightradar24.com/docs/sdk/js Fetch full details for a specific airport using its ICAO code. Ensure your API token is set via environment variable or passed to the client. The client should be closed after use. ```javascript import SDK from '@flightradar24/fr24sdk'; const client = new SDK.Client({ apiToken: process.env.FR24_API_TOKEN }); try { const waw = await client.airports.getFull('WAW'); console.log(waw.name, waw.icao, waw.city, waw.country, waw.lat, waw.lon); } finally { client.close(); } ``` -------------------------------- ### Configure FR24 API Token (Node.js) Source: https://fr24api.flightradar24.com/docs/endpoints/flight-positions-batch-query Create a .env file in your project root to store your FR24 API token. This token is required for authenticating with the FR24 API. ```dotenv FR24_API_TOKEN=your_api_token_here ``` -------------------------------- ### Configure Claude Desktop with FR24 API MCP Server Source: https://fr24api.flightradar24.com/docs/mcp-server Add this configuration block to your Claude Desktop config file to connect to the FR24 API MCP server. Ensure you replace 'your_api_key_here' with your actual FR24 API key. ```json { "mcpServers": { "fr24api": { "command": "npx", "args": ["@flightradar24/fr24api-mcp@latest"], "env": { "FR24_API_KEY": "your_api_key_here" } } } } ``` -------------------------------- ### Get Live Flight Positions in Bounding Box Source: https://fr24api.flightradar24.com/docs/sdk/js Query live flight data within a specified geographic bounding box. The bounds are defined as 'N,S,W,E'. Remember to close the client after use. ```javascript import SDK from '@flightradar24/fr24sdk'; const client = new SDK.Client({ apiToken: process.env.FR24_API_TOKEN }); try { // bounds: "N,S,W,E" const bounds = '50.682,46.218,14.422,22.243'; const flights = await client.live.getFlights({ bounds }); console.log(`Flights returned: ${flights.data.length}`); } finally { client.close(); } ``` -------------------------------- ### Authentication - OS environment variable Source: https://fr24api.flightradar24.com/docs/sdk/js Set your API token as an environment variable for authentication. ```APIDOC # macOS/Linux export FR24_API_TOKEN="your_actual_token_here" # Windows (PowerShell) $Env:FR24_API_TOKEN="your_actual_token_here" ``` -------------------------------- ### Python: Fetch Flights for Airport Date Source: https://fr24api.flightradar24.com/docs/endpoints/flight-summary Fetches flights on a specific route for a given date using the Flight Summary Light endpoint. Requires API key and sets date range for the entire day. ```python import requests import datetime import folium def get_flights_for_airport_date(route: str, date_str: str, headers): """ Fetch all flights on a specific route on the specified date, using Flight Summary Light endpoint. """ base_url = "https://fr24api.flightradar24.com/api/flight-summary/light" # Build the start/end of day in UTC for the query (example uses the entire 24-hour period) flight_datetime_from = f"{date_str} 00:00:00" flight_datetime_to = f"{date_str} 23:59:59" params = { "flight_datetime_from": flight_datetime_from, "flight_datetime_to": flight_datetime_to, "routes": f"{route}", "limit": 50 # Adjust limit as needed. } response = requests.get(base_url, params=params, headers=headers) response.raise_for_status() data = response.json() # Extract flight IDs from the response to then fetch detailed track data. fr24_ids = [] for flight in data.get("data", []): fr24_id = flight.get("fr24_id") if fr24_id: fr24_ids.append(fr24_id) return fr24_ids ``` -------------------------------- ### Retrieve Live Flight Positions Source: https://fr24api.flightradar24.com/docs/examples-and-use-cases/use-case-triggering-alerts-when-a-flight-enters-a-circular-area Fetch live flight data using the SDK's `get_light` method with the defined bounding box. This retrieves a coarse set of flights within the specified area. ```python flights = client.live.flight_positions.get_light(bounds=BOUNDS) ``` -------------------------------- ### Set FR24 API Token Environment Variable Source: https://fr24api.flightradar24.com/docs/sdk/python Set your API token as an environment variable for authentication. This is the preferred method for the SDK. ```bash # macOS/Linux export FR24_API_TOKEN="your_actual_token_here" # Windows (PowerShell) $Env:FR24_API_TOKEN="your_actual_token_here" ``` -------------------------------- ### Retrieve API Usage Details Source: https://fr24api.flightradar24.com/docs/credit-overview Use this Python script to call the /usage endpoint and retrieve details about your API credit consumption. Ensure your API token is correctly set in the headers. The usage endpoint has a rate limit of 1 call per minute. ```python import requests import json # Define the API token and endpoint URL API_TOKEN = '' BASE_URL = 'https://fr24api.flightradar24.com/api' ENDPOINT = '/usage' # Define the headers, including the Authorization header with your API token headers = { 'Accept': 'application/json', 'Authorization': 'Bearer {API_TOKEN}', 'Accept-Version': 'v1' } # Construct the full URL url = f"{BASE_URL}{ENDPOINT}" # Make the GET request to the API response = requests.get(url, headers=headers) # Check if the request was successful if response.status_code == 200: # Parse and print the JSON response usage_data = response.json() print("Usage Data:") print(json.dumps(usage_data, indent=2)) else: print(f"Error: {response.status_code}") print(response.text) ``` -------------------------------- ### Live flight positions light Source: https://fr24api.flightradar24.com/docs/endpoints Returns real-time aircraft flight movement information including latitude, longitude, speed, and altitude. ```APIDOC ## Live flight positions light ### Description Returns real-time aircraft flight movement information including latitude, longitude, speed, and altitude. ### Method GET ### Endpoint /live/flight/positions/light ``` -------------------------------- ### Continuous Monitoring Loop Source: https://fr24api.flightradar24.com/docs/examples-and-use-cases/use-case-triggering-alerts-when-a-flight-enters-a-circular-area Implement a loop that continuously polls for live flight data at a specified interval (e.g., 5 seconds). It fetches data, filters flights within the geofence, processes alerts, and handles potential exceptions. ```python import time POLLING_SECONDS = 5 def monitor_geofence() -> None: while True: try: flights = client.live.flight_positions.get_light(bounds=BOUNDS) inside = list(flights_in_circle(flights.data)) if inside: process_alerts(inside) time.sleep(POLLING_SECONDS) except Exception as exc: logging.error("Error during polling: %s", exc) time.sleep(POLLING_SECONDS) ``` -------------------------------- ### Python: Fetch Flight Tracks Source: https://fr24api.flightradar24.com/docs/endpoints/flight-summary Fetches detailed flight trajectories using the FR24 Flight Tracks endpoint for a list of flight IDs. Requires API key. ```python def get_flight_tracks(fr24_ids, headers): """ Fetch full flight trajectories using the FR24 Flight Tracks endpoint. """ base_url = "https://fr24api.flightradar24.com/api/flight-tracks" all_tracks = [] for flight_id in fr24_ids: params = { "flight_id": flight_id } response = requests.get(base_url, params=params, headers=headers) response.raise_for_status() track_data = response.json() # Store track info in a list (or write to DB, etc.) all_tracks.append(track_data) return all_tracks ``` -------------------------------- ### Flight Summary Full Source: https://fr24api.flightradar24.com/docs/endpoints/flight-summary Retrieves all data from the Light version plus additional flight details such as runway identifiers, flight distance, and duration. ```APIDOC ## GET /flight-summary/full ### Description Provides all data from the Flight Summary Light version plus additional flight details like runway identifiers, flight distance, and flight duration. ### Endpoint `/flight-summary/full` ### Parameters #### Query Parameters - **flight_ids** (string) - Required - Comma-separated `fr24_id` values. Maximum of 10 flight_ids. Cannot be used with `flight_datetime_from`/`flight_datetime_to`. - **flight_datetime_from** (string) - Required - Start of datetime range (UTC). Format: `YYYY-MM-DDTHH:MM:SS` or `YYYY-MM-DD HH:MM:SS`. Cannot be used with `flight_ids`. Maximum of 14 days of data. - **flight_datetime_to** (string) - Required - End of datetime range (UTC). Format: `YYYY-MM-DDTHH:MM:SS` or `YYYY-MM-DD HH:MM:SS`. Cannot be used with `flight_ids`. - **flights** (string) - Optional - Comma-separated flight numbers, 15 maximum. - **registrations** (string) - Optional - Comma-separated aircraft registrations, 15 maximum. - **callsigns** (string) - Optional - Comma-separated flight callsigns, 15 maximum. - **operating_as** (string) - Optional - ICAO code for the operating airline, 15 maximum. - **painted_as** (string) - Optional - ICAO code representing the aircraft livery, 15 maximum. - **airports** (string) - Optional - IATA/ICAO codes or ISO country codes, 15 maximum. Can use `inbound:`, `outbound:` or `both:`. Example: `LHR,SE,inbound:WAW,outbound:JFK,both:ESSA`. - **aircraft** (string) - Optional - Aircraft ICAO type codes, comma-separated, 15 maximum. - **categories** (string) - Optional - Comma-separated aircraft/service category letters, 15 maximum. Must be combined with at least one other filter. Available options: `P`, `C`, `M`, `J`, `T`, `H`, `B`, `G`, `D`, `V`, `O`, `N`. - **routes** (string) - Optional - Specific routes between airports or countries, 15 maximum. Example: `SE-US,ESSA-JFK`. - **limit** (integer) - Optional - Maximum number of results to return (up to 20,000). - **sort** (string) - Optional - Sorting order of the results by `first_seen`. Default: `asc`. Available options: `asc`, `desc`. ### Response #### Success Response (200) - **field1** (type) - Description (Details not provided in source) ``` -------------------------------- ### Set FR24 API Token Source: https://fr24api.flightradar24.com/docs/examples-and-use-cases/use-case-calculating-calculating-the-farthest-flight Store your FR24 API token as an environment variable for secure access. This is the recommended method. ```bash export FR24_API_TOKEN="your_api_token_here" ``` -------------------------------- ### Live flight positions full Source: https://fr24api.flightradar24.com/docs/endpoints Returns real-time aircraft flight movement information including latitude, longitude, speed, and altitude alongside key flight and aircraft information such as origin, destination, callsign, registration and aircraft type. ```APIDOC ## Live flight positions full ### Description Returns real-time aircraft flight movement information including latitude, longitude, speed, and altitude alongside key flight and aircraft information such as origin, destination, callsign, registration and aircraft type. ### Method GET ### Endpoint /live/flight/positions/full ``` -------------------------------- ### Live Flight Positions in a Bounding Box Source: https://fr24api.flightradar24.com/docs/sdk/python Query live flight positions within a specified geographical bounding box. The `client.live.flight_positions.get_light()` method accepts bounds in the format N, S, W, E. ```APIDOC ## Live flight positions in a bounding box ```python from fr24sdk.client import Client bounds = "50.682,46.218,14.422,22.243" # N, S, W, E with Client() as client: flights = client.live.flight_positions.get_light(bounds=bounds) print(f"Flights returned: {len(flights.data)}") ``` The SDK exposes `client.live.flight_positions.get_light(...)` to query live positions; pass the same bounds you’d use in the HTTP API. ```