### Fetch Arrival Schedule for Airport on Specific Date Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Queries all arriving flights at a specified airport for a particular date. This endpoint requires an API key, airport code, and date. The response includes detailed arrival information, origin airports, and operational status. The example is shown using cURL and provides an expected JSON response structure. ```bash curl -X GET "https://aviation-edge.com/v2/public/flightsHistory?key=YOUR_API_KEY&code=JFK&type=arrival&date_from=2023-03-04" ``` ```json [ { "type": "arrival", "status": "landed", "departure": { "iataCode": "eyw", "icaoCode": "keyw", "gate": "8", "delay": 15, "scheduledTime": "2021-11-02t16:55:00.000", "actualTime": "2021-11-02t17:09:00.000", "estimatedRunway": "2021-11-02t17:09:00.000", "actualRunway": "2021-11-02t17:09:00.000" }, "arrival": { "iataCode": "iah", "icaoCode": "kiah", "terminal": "b", "baggage": "b3", "gate": "76", "scheduledTime": "2021-11-02t19:00:00.000", "estimatedTime": "2021-11-02t18:46:00.000", "actualTime": "2021-11-02t18:55:00.000", "estimatedRunway": "2021-11-02t18:55:00.000", "actualRunway": "2021-11-02t18:55:00.000" }, "airline": { "name": "united airlines", "iataCode": "ua", "icaoCode": "ual" }, "flight": { "number": "6264", "iataNumber": "ua6264", "icaoNumber": "ual6264" } } ] ``` -------------------------------- ### Query Flight Schedule for Date Range Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Retrieves historical flight schedules across multiple days by specifying both start and end dates. This is useful for analyzing flight patterns and trends over time. The query requires an API key, airport code, date range (from and to), and optionally the flight type (departure/arrival). This example demonstrates its usage with cURL and provides a JavaScript implementation using 'axios'. ```bash curl -X GET "https://aviation-edge.com/v2/public/flightsHistory?key=YOUR_API_KEY&code=JFK&type=departure&date_from=2023-03-01&date_to=2023-03-07" ``` ```javascript async function fetchDateRangeData(apiKey, airportCode, dateFrom, dateTo, type = 'departure') { const endpoint = `https://aviation-edge.com/v2/public/flightsHistory?key=${apiKey}&code=${airportCode}&type=${type}&date_from=${dateFrom}&date_to=${dateTo}`; try { const response = await axios.get(endpoint); console.log(`Fetched ${response.data.length} flights from ${dateFrom} to ${dateTo}`); return response.data; } catch (error) { console.error("Error fetching date range data:", error); return null; } } // Example: Get week of departures from JFK fetchDateRangeData('your-api-key', 'JFK', '2023-03-01', '2023-03-07', 'departure') .then(flights => { const flightsByDay = {}; flights.forEach(flight => { const date = flight.departure.scheduledTime.split('t')[0]; flightsByDay[date] = (flightsByDay[date] || 0) + 1; }); console.log('Flights per day:', flightsByDay); }); ``` -------------------------------- ### Fetch Route Arrival Data and Analyze On-Time Performance (JavaScript) Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Fetches historical flight arrival data for a specified route and analyzes its on-time performance. This function uses `axios` to make a GET request to the API, filters flights that were on time, and calculates the on-time rate for the given route and date range. ```javascript async function fetchRouteArrivals(apiKey, destinationCode, originCode, dateFrom, dateTo) { const endpoint = `https://aviation-edge.com/v2/public/flightsHistory?key=${apiKey}&code=${destinationCode}&type=arrival&date_from=${dateFrom}&date_to=${dateTo}&dep_iataCode=${originCode}`; try { const response = await axios.get(endpoint); console.log(`Route ${originCode} → ${destinationCode}: ${response.data.length} flights`); // Analyze on-time performance const onTimeFlights = response.data.filter(f => !f.departure.delay || f.departure.delay === 0); const onTimeRate = (onTimeFlights.length / response.data.length * 100).toFixed(2); console.log(`On-time performance: ${onTimeRate}%`); return response.data; } catch (error) { console.error("Error fetching route data:", error); return null; } } // Analyze LAX to JFK route fetchRouteArrivals('your-api-key', 'JFK', 'LAX', '2023-03-01', '2023-03-07'); ``` -------------------------------- ### Fetch Historical Airport Data using Axios (JavaScript) Source: https://github.com/aviationedgeapi/historical-schedules-api/blob/main/README.md Demonstrates how to fetch historical flight schedule data for a specific airport and date using the axios library. It makes a GET request to the Aviation Edge API endpoint and handles potential errors. ```javascript const axios = require('axios'); async function fetchAirportData(apiKey, airportCode, date) { const endpoint = `https://aviation-edge.com/v2/public/flightsHistory?key=${apiKey}&code=${airportCode}&type=departure&date_from=${date}`; try { const response = await axios.get(endpoint); return response.data; } catch (error) { console.error("Error fetching airport data:", error); return null; } } const apiKey = 'api-key'; // Replace with your actual API key const airportCode = 'JFK'; const date = '2023-03-04'; fetchAirportData(apiKey, airportCode, date).then(data => { console.log(data); }); ``` -------------------------------- ### Query Flight Schedule for Date Range Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Retrieves historical flight schedules across multiple days by specifying both start and end dates. This allows for comprehensive analysis of flight patterns and trends over time. ```APIDOC ## GET /v2/public/flightsHistory ### Description Retrieves historical flight schedules for a specified airport and date range, for either departures or arrivals. ### Method GET ### Endpoint `/v2/public/flightsHistory` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. - **code** (string) - Required - The IATA airport code (e.g., "JFK"). - **type** (string) - Required - "departure" or "arrival". - **date_from** (string) - Required - The start date in "YYYY-MM-DD" format. - **date_to** (string) - Required - The end date in "YYYY-MM-DD" format. ### Request Example ```bash curl -X GET "https://aviation-edge.com/v2/public/flightsHistory?key=YOUR_API_KEY&code=JFK&type=departure&date_from=2023-03-01&date_to=2023-03-07" ``` ```javascript const axios = require('axios'); async function fetchDateRangeData(apiKey, airportCode, dateFrom, dateTo, type = 'departure') { const endpoint = `https://aviation-edge.com/v2/public/flightsHistory?key=${apiKey}&code=${airportCode}&type=${type}&date_from=${dateFrom}&date_to=${dateTo}`; try { const response = await axios.get(endpoint); return response.data; } catch (error) { console.error("Error fetching date range data:", error); return null; } } // Example: Get week of departures from JFK fetchDateRangeData('your-api-key', 'JFK', '2023-03-01', '2023-03-07', 'departure') .then(flights => { if (flights) { console.log(`Fetched ${flights.length} flights from 2023-03-01 to 2023-03-07`); // Further processing can be done here, e.g., grouping by day. } }); ``` ### Response #### Success Response (200) - **Array of flight objects** - Each object contains detailed information about a flight within the specified date range. #### Response Example ```json [ { "departure": { "iataCode": "jfk", "scheduledTime": "2023-03-01T08:00:00.000Z" }, "arrival": { "iataCode": "ord", "scheduledTime": "2023-03-01T10:00:00.000Z" }, "airline": { "name": "American Airlines", "iataCode": "aa" }, "flight": { "number": "378" } } ] ``` ``` -------------------------------- ### GET /v2/public/flightsHistory Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Retrieves historical flight data, filtering departures by a specific arrival airport IATA code. This is useful for analyzing outbound route performance from a given origin. ```APIDOC ## GET /v2/public/flightsHistory ### Description Retrieves historical flight data, filtering departures by a specific arrival airport IATA code. This is useful for analyzing outbound route performance from a given origin. ### Method GET ### Endpoint `/v2/public/flightsHistory` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key for authentication. - **code** (string) - Required - The IATA code of the origin airport (e.g., 'JFK'). - **type** (string) - Required - Specifies the flight type. Use 'departure' to filter departures. - **date_from** (string) - Required - The start date for the historical data query in 'YYYY-MM-DD' format. - **arr_iataCode** (string) - Optional - The IATA code of the arrival airport to filter departures (e.g., 'LHR'). ### Request Example ```bash curl -X GET "https://aviation-edge.com/v2/public/flightsHistory?key=YOUR_API_KEY&code=JFK&type=departure&date_from=2023-03-04&arr_iataCode=LHR" ``` ### Response #### Success Response (200) - **data** (array) - An array of flight objects matching the query criteria. - **airline** (object) - Information about the airline. - **iataCode** (string) - The IATA code of the airline. - **name** (string) - The name of the airline. - **departure** (object) - Departure details. - **delay** (number) - The departure delay in minutes. - **arrival** (object) - Arrival details. - **iataCode** (string) - The IATA code of the arrival airport. #### Response Example ```json [ { "airline": {"iataCode": "AA", "name": "American Airlines"}, "departure": {"delay": 15, "iataTimeDep": "2023-03-04T10:30:00Z"}, "arrival": {"iataCode": "LHR", "iataTimestampArrival": "2023-03-04T22:45:00Z"} }, { "airline": {"iataCode": "BA", "name": "British Airways"}, "departure": {"delay": 5, "iataTimeDep": "2023-03-04T11:00:00Z"}, "arrival": {"iataCode": "LHR", "iataTimestampArrival": "2023-03-04T23:00:00Z"} } ] ``` ``` -------------------------------- ### GET /v2/public/flightsHistory Source: https://github.com/aviationedgeapi/historical-schedules-api/blob/main/README.md Retrieves historical flight schedules for a specific airport on a given date or date range. Supports filtering by departure or arrival, status, flight number, and airline. ```APIDOC ## GET /v2/public/flightsHistory ### Description Fetches historical flight data for a specified airport, allowing filtering by date, flight type (departure/arrival), status, flight number, and airline. ### Method GET ### Endpoint `https://aviation-edge.com/v2/public/flightsHistory` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. - **code** (string) - Required - The IATA code of the airport. - **type** (string) - Required - Flight type, either "departure" or "arrival". - **date_from** (string) - Required - The starting date in YYYY-MM-DD format. Can be used for a single day or the start of a range. - **date_to** (string) - Optional - The end date in YYYY-MM-DD format to specify a date range. - **status** (string) - Optional - Filters flights by their status (e.g., "cancelled", "delayed"). - **flight_number** (string) - Optional - Filters for a specific flight number. - **airline_iata** (string) - Optional - Filters flights by airline IATA code. - **dep_iataCode** (string) - Optional - Filters by departure airport IATA code when `type` is "arrival". - **arr_iataCode** (string) - Optional - Filters by arrival airport IATA code when `type` is "departure". ### Request Example ```json { "example": "GET https://aviation-edge.com/v2/public/flightsHistory?key=YOUR_API_KEY&code=JFK&type=departure&date_from=2023-01-01&date_to=2023-01-07&status=landed" } ``` ### Response #### Success Response (200) - **flightId** (string) - Unique identifier for the flight. - **departure** (object) - Details about the departure. - **iataCode** (string) - Departure airport IATA code. - **airport** (string) - Departure airport name. - **scheduled** (string) - Scheduled departure time. - **estimated** (string) - Estimated departure time. - **actual** (string) - Actual departure time. - **delay** (integer) - Departure delay in minutes. - **arrival** (object) - Details about the arrival. - **iataCode** (string) - Arrival airport IATA code. - **airport** (string) - Arrival airport name. - **scheduled** (string) - Scheduled arrival time. - **estimated** (string) - Estimated arrival time. - **actual** (string) - Actual arrival time. - **delay** (integer) - Arrival delay in minutes. - **airline** (object) - Details about the airline. - **iataCode** (string) - Airline IATA code. - **name** (string) - Airline name. - **flight** (object) - Details about the flight. - **number** (string) - Flight number. - **iataCode** (string) - Flight IATA code. - **icaoCode** (string) - Flight ICAO code. #### Response Example ```json { "example": [ { "flightId": "123456789", "departure": { "iataCode": "JFK", "airport": "John F. Kennedy International Airport", "scheduled": "2023-01-01T10:00:00Z", "estimated": "2023-01-01T10:15:00Z", "actual": "2023-01-01T10:10:00Z", "delay": 10 }, "arrival": { "iataCode": "LAX", "airport": "Los Angeles International Airport", "scheduled": "2023-01-01T13:00:00Z", "estimated": "2023-01-01T13:15:00Z", "actual": "2023-01-01T13:10:00Z", "delay": 0 }, "airline": { "iataCode": "AA", "name": "American Airlines" }, "flight": { "number": "100", "iataCode": "AA100", "icaoCode": "AAL100" } } ] } ``` ``` -------------------------------- ### Fetch Departure Schedule for Airport on Specific Date Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Retrieves all departure flights from a specified airport for a single date using the Aviation Edge API. It requires an API key, airport code, and date as input. The function returns flight data or null in case of an error. This example uses the 'axios' library for making HTTP requests. ```javascript const axios = require('axios'); async function fetchAirportData(apiKey, airportCode, date) { const endpoint = `https://aviation-edge.com/v2/public/flightsHistory?key=${apiKey}&code=${airportCode}&type=departure&date_from=${date}`; try { const response = await axios.get(endpoint); console.log(`Fetched ${response.data.length} departure flights from ${airportCode}`); return response.data; } catch (error) { console.error("Error fetching airport data:", error); return null; } } const apiKey = 'your-api-key-here'; const airportCode = 'JFK'; const date = '2023-03-04'; fetchAirportData(apiKey, airportCode, date).then(data => { if (data && data.length > 0) { console.log('First flight:', data[0]); } }); ``` -------------------------------- ### Fetch Arrival Schedule for Airport on Specific Date Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Queries all arriving flights at a specified airport for a particular date, providing detailed arrival information, origin airports, and operational status for each flight. ```APIDOC ## GET /v2/public/flightsHistory ### Description Retrieves all arrival flights at a specified airport for a single date. ### Method GET ### Endpoint `/v2/public/flightsHistory` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. - **code** (string) - Required - The IATA airport code (e.g., "JFK"). - **type** (string) - Required - Set to "arrival" for arrivals. - **date_from** (string) - Required - The date in "YYYY-MM-DD" format. ### Request Example ```bash curl -X GET "https://aviation-edge.com/v2/public/flightsHistory?key=YOUR_API_KEY&code=JFK&type=arrival&date_from=2023-03-04" ``` ### Response #### Success Response (200) - **Array of flight objects** - Each object contains detailed information about an arrival flight. #### Response Example ```json [ { "type": "arrival", "status": "landed", "departure": { "iataCode": "eyw", "actualTime": "2021-11-02t17:09:00.000Z" }, "arrival": { "iataCode": "iah", "actualTime": "2021-11-02t18:55:00.000Z" }, "airline": { "name": "united airlines", "iataCode": "ua" }, "flight": { "number": "6264" } } ] ``` ``` -------------------------------- ### Historical Schedules API - General Usage Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt This section outlines the general usage of the Historical Airport Schedules API, including authentication, request methods, and common query parameters. ```APIDOC ## Historical Airport Schedules API ### Description The Historical Airport Schedules API provides access to historical flight data, including schedules, delays, and cancellations. It is designed for use cases such as flight compensation verification, operational analysis for airlines and airports, travel analytics, and aviation research. ### Method GET ### Endpoint `/aviationedgeapi/historical-schedules-api` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key for authentication. - **airport_code** (string) - Optional - Filter by airport IATA code (e.g., "JFK"). - **flight_type** (string) - Optional - Filter by flight type ('arrival' or 'departure'). - **start_date** (date) - Optional - Filter by start date for the data range (YYYY-MM-DD). - **end_date** (date) - Optional - Filter by end date for the data range (YYYY-MM-DD). - **airline_code** (string) - Optional - Filter by airline IATA code (e.g., "AA"). - **flight_number** (string) - Optional - Filter by specific flight number (e.g., "123"). - **status** (string) - Optional - Filter by flight status (e.g., 'landed', 'cancelled', 'diverted'). ### Request Example ```javascript const axios = require('axios'); const apiKey = 'YOUR_API_KEY'; const airportCode = 'LAX'; const startDate = '2023-01-01'; const endDate = '2023-01-31'; axios.get(`https://api.aviation-edge.com/v1/historical/schedules?key=${apiKey}&airport_code=${airportCode}&start_date=${startDate}&end_date=${endDate}`) .then(response => { console.log(response.data); }) .catch(error => { console.error('Error fetching data:', error); }); ``` ### Response #### Success Response (200) - **schedule** (array) - An array of flight schedule objects. - **flight_date** (string) - The date of the flight. - **departure_time** (object) - Details about the scheduled and estimated departure. - **scheduled** (string) - Scheduled departure time (ISO 8601 format). - **estimated** (string) - Estimated departure time (ISO 8601 format). - **arrival_time** (object) - Details about the scheduled and estimated arrival. - **scheduled** (string) - Scheduled arrival time (ISO 8601 format). - **estimated** (string) - Estimated arrival time (ISO 8601 format). - **flight_status** (string) - The status of the flight (e.g., 'landed', 'cancelled', 'scheduled'). - **airline** (object) - Information about the airline. - **iata_code** (string) - Airline IATA code. - **name** (string) - Airline name. - **flight_number** (string) - The flight number. - **departure_airport** (object) - Information about the departure airport. - **iata_code** (string) - Airport IATA code. - **arrival_airport** (object) - Information about the arrival airport. - **iata_code** (string) - Airport IATA code. #### Response Example ```json { "schedule": [ { "flight_date": "2023-01-15", "departure_time": { "scheduled": "2023-01-15T08:00:00Z", "estimated": "2023-01-15T08:05:00Z" }, "arrival_time": { "scheduled": "2023-01-15T11:00:00Z", "estimated": "2023-01-15T11:10:00Z" }, "flight_status": "landed", "airline": { "iata_code": "AA", "name": "American Airlines" }, "flight_number": "100", "departure_airport": { "iata_code": "LAX" }, "arrival_airport": { "iata_code": "JFK" } } ] } ``` ### Error Handling - **401 Unauthorized**: Invalid or missing API key. - **400 Bad Request**: Invalid query parameters. - **404 Not Found**: No data found for the specified criteria. ``` -------------------------------- ### Fetch and Analyze Departure Flights by Arrival Airport (JavaScript) Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt This JavaScript function uses `axios` to fetch historical departure flight data and filters by the arrival airport. It then processes the response to group flights by airline, calculates the total number of flights, and the average delay for each airline on the specified route. It requires an API key, origin and destination IATA codes, and a date range. ```javascript async function fetchRouteDepartures(apiKey, originCode, destinationCode, dateFrom) { const endpoint = `https://aviation-edge.com/v2/public/flightsHistory?key=${apiKey}&code=${originCode}&type=departure&date_from=${dateFrom}&arr_iataCode=${destinationCode}`; try { const response = await axios.get(endpoint); // Group flights by airline const airlineStats = {}; response.data.forEach(flight => { const airline = flight.airline.iataCode; if (!airlineStats[airline]) { airlineStats[airline] = { name: flight.airline.name, flights: 0, totalDelay: 0 }; } airlineStats[airline].flights++; airlineStats[airline].totalDelay += (flight.departure.delay || 0); }); console.log(`\nRoute ${originCode} → ${destinationCode} on ${dateFrom}:\n`); Object.keys(airlineStats).forEach(code => { const stats = airlineStats[code]; const avgDelay = stats.totalDelay / stats.flights; console.log(`${stats.name}: ${stats.flights} flights, avg delay ${avgDelay.toFixed(2)} min`); }); return response.data; } catch (error) { console.error("Error fetching route departures:", error); return null; } } // Compare airlines on JFK to London route fetchRouteDepartures('your-api-key', 'JFK', 'LHR', '2023-03-04'); ``` -------------------------------- ### Fetch Departure Flights with Arrival Airport Filter (Bash) Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt This `curl` command demonstrates how to query the Aviation Edge API for historical departure flights from a specific origin airport (JFK) to a specific arrival airport (LHR) on a given date. It requires an API key and uses query parameters for filtering. ```bash curl -X GET "https://aviation-edge.com/v2/public/flightsHistory?key=YOUR_API_KEY&code=JFK&type=departure&date_from=2023-03-04&arr_iataCode=LHR" ``` -------------------------------- ### Display Airline Delay Information Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Formats and presents delay information with airline names for human-readable output, facilitating quick overview of delay patterns across carriers. ```APIDOC ## Display Airline Delay Information ### Description Formats and presents delay information with airline names for human-readable output, facilitating quick overview of delay patterns across carriers. ### Method GET (Implicitly, through function calls) ### Endpoint N/A (Client-side formatting) ### Parameters None (Operates on provided flight data) ### Request Example ```javascript // Example usage within generateDelayReport function displayDelayedInfo(delayedFlights); ``` ### Response #### Success Response (200) Outputs formatted delay information to the console. #### Response Example ``` 123 (American Airlines): JFK → LAX - delayed 15 minutes ``` ``` -------------------------------- ### Filter Flights by Departure Airport (Arrivals) using cURL Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Queries arrival schedules and filters the results by the originating airport's IATA code. This cURL command demonstrates how to fetch flight history for arrivals at a specific airport, filtered by the departure airport code, enabling analysis of specific route performance. ```bash curl -X GET "https://aviation-edge.com/v2/public/flightsHistory?key=YOUR_API_KEY&code=JFK&type=arrival&date_from=2023-03-04&dep_iataCode=LAX" ``` -------------------------------- ### Fetch Departure Schedule for Airport on Specific Date Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Retrieves all departure flights from a specified airport for a single date. It returns comprehensive flight information including scheduled times, actual times, delays, gates, and airline details. ```APIDOC ## GET /v2/public/flightsHistory ### Description Retrieves all departure flights from a specified airport for a single date. ### Method GET ### Endpoint `/v2/public/flightsHistory` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. - **code** (string) - Required - The IATA airport code (e.g., "JFK"). - **type** (string) - Required - Set to "departure" for departures. - **date_from** (string) - Required - The date in "YYYY-MM-DD" format. ### Request Example ```javascript const axios = require('axios'); async function fetchAirportData(apiKey, airportCode, date) { const endpoint = `https://aviation-edge.com/v2/public/flightsHistory?key=${apiKey}&code=${airportCode}&type=departure&date_from=${date}`; try { const response = await axios.get(endpoint); return response.data; } catch (error) { console.error("Error fetching airport data:", error); return null; } } const apiKey = 'your-api-key-here'; const airportCode = 'JFK'; const date = '2023-03-04'; fetchAirportData(apiKey, airportCode, date).then(data => { if (data && data.length > 0) { console.log('First flight:', data[0]); } }); ``` ### Response #### Success Response (200) - **Array of flight objects** - Each object contains detailed information about a departure flight. #### Response Example ```json [ { "departure": { "iataCode": "jfk", "scheduledTime": "2023-03-04T10:00:00.000Z" }, "arrival": { "iataCode": "lax", "scheduledTime": "2023-03-04T13:00:00.000Z" }, "airline": { "name": "Example Air", "iataCode": "ea" }, "flight": { "number": "123" } } ] ``` ``` -------------------------------- ### Track Individual Historical Flight by Flight Number Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Retrieves historical data for a specific flight number. This enables precise tracking of individual flight performance. Requires API key, airport code, flight number, and date range. ```bash curl -X GET "https://aviation-edge.com/v2/public/flightsHistory?key=YOUR_API_KEY&code=JFK&type=departure&date_from=2023-03-01&date_to=2023-03-07&flight_num=1234" ``` ```javascript async function trackSpecificFlight(apiKey, airportCode, flightNumber, dateFrom, dateTo) { const endpoint = `https://aviation-edge.com/v2/public/flightsHistory?key=${apiKey}&code=${airportCode}&type=departure&date_from=${dateFrom}&date_to=${dateTo}&flight_num=${flightNumber}`; try { const response = await axios.get(endpoint); if (response.data.length > 0) { const flight = response.data[0]; console.log(`Flight ${flight.flight.iataNumber}:`); console.log(` Route: ${flight.departure.iataCode} → ${flight.arrival.iataCode}`); console.log(` Scheduled: ${flight.departure.scheduledTime}`); console.log(` Actual: ${flight.departure.actualTime}`); console.log(` Delay: ${flight.departure.delay || 0} minutes`); console.log(` Status: ${flight.status}`); } return response.data; } catch (error) { console.error("Error tracking flight:", error); return null; } } // Track a specific flight over a week trackSpecificFlight('your-api-key', 'JFK', '1234', '2023-03-01', '2023-03-07'); ``` -------------------------------- ### Filter Flights by Status (e.g., Cancelled, Delayed) Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Retrieves flights matching a specific status (e.g., 'cancelled', 'delayed', 'landed'). This is useful for analyzing operational conditions. Requires API key, airport code, date range, and the desired status. ```bash curl -X GET "https://aviation-edge.com/v2/public/flightsHistory?key=YOUR_API_KEY&code=JFK&type=arrival&date_from=2023-03-04&date_to=2023-03-10&status=cancelled" ``` ```javascript async function fetchFlightsByStatus(apiKey, airportCode, dateFrom, dateTo, status) { const endpoint = `https://aviation-edge.com/v2/public/flightsHistory?key=${apiKey}&code=${airportCode}&type=arrival&date_from=${dateFrom}&date_to=${dateTo}&status=${status}`; try { const response = await axios.get(endpoint); console.log(`Found ${response.data.length} ${status} flights`); return response.data; } catch (error) { console.error(`Error fetching ${status} flights:`, error); return null; } } // Example: Find all cancelled arrivals fetchFlightsByStatus('your-api-key', 'JFK', '2023-03-01', '2023-03-31', 'cancelled') .then(cancelledFlights => { console.log('Cancelled flights:', cancelledFlights.length); cancelledFlights.forEach(flight => { console.log(`${flight.flight.iataNumber} from ${flight.departure.iataCode}`); }); }); ``` -------------------------------- ### Display Airline Delay Information (JavaScript) Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Formats and presents delay information with airline names for human-readable output. This function iterates through a list of delayed flights, extracting and logging details such as flight number, airline name, route, and delay duration. It aids in providing a quick overview of delay patterns. ```javascript function displayDelayedInfo(flights) { flights.forEach(flight => { const airlineName = flight.airline.name; const flightNumber = flight.flight.iataNumber; const delay = flight.departure.delay; const route = `${flight.departure.iataCode} → ${flight.arrival.iataCode}`; console.log(`${flightNumber} (${airlineName}): ${route} - delayed ${delay} minutes`); }); } async function generateDelayReport(apiKey, airportCode, date) { const allFlights = await fetchAirportData(apiKey, airportCode, date); if (!allFlights) { console.error('Failed to fetch flight data'); return; } const delayedFlights = filterDelayedFlights(allFlights); console.log(` === Delay Report for ${airportCode} on ${date} === `); displayDelayedInfo(delayedFlights); console.log(` === Total: ${delayedFlights.length} delayed flights === `); } // Generate comprehensive delay report generateDelayReport('your-api-key', 'JFK', '2023-03-04'); ``` -------------------------------- ### Display Airline Name and Delay Information (JavaScript) Source: https://github.com/aviationedgeapi/historical-schedules-api/blob/main/README.md A JavaScript function to iterate through a list of flights and display the airline name along with its departure delay in minutes. This helps in quickly summarizing delay information for affected flights. ```javascript function displayDelayedInfo(flights) { flights.forEach(flight => { const airlineName = flight.airline.name; const delay = flight.departure.delay; console.log(`${airlineName} had a delay of ${delay} minutes.`); }); } fetchAirportData(apiKey, airportCode, date).then(data => { const delayedFlights = filterDelayedFlights(data); displayDelayedInfo(delayedFlights); }); ``` -------------------------------- ### Filter Flights by Departure Airport (for Arrivals) Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt When querying arrival schedules, filters results by the originating airport IATA code to analyze specific route performance. ```APIDOC ## Filter Flights by Departure Airport (for Arrivals) ### Description When querying arrival schedules, filters results by the originating airport IATA code to analyze specific route performance. ### Method GET ### Endpoint `/v2/public/flightsHistory` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. - **code** (string) - Required - The IATA code of the destination airport. - **type** (string) - Required - Set to 'arrival' to get arrival flights. - **date_from** (string) - Required - The start date for the search in 'YYYY-MM-DD' format. - **date_to** (string) - Optional - The end date for the search in 'YYYY-MM-DD' format. - **dep_iataCode** (string) - Optional - The IATA code of the departure airport to filter by. ### Request Example ```bash curl -X GET "https://aviation-edge.com/v2/public/flightsHistory?key=YOUR_API_KEY&code=JFK&type=arrival&date_from=2023-03-04&dep_iataCode=LAX" ``` ### Response #### Success Response (200) Returns an array of flight objects matching the specified arrival criteria and departure airport. #### Response Example ```json [ { "departure": { "iataCode": "LAX", "delay": 10 }, "arrival": { "iataCode": "JFK" }, "airline": { "name": "American Airlines" }, "flight": { "iataNumber": "123" } } ] ``` ``` -------------------------------- ### JavaScript Aviation Edge Historical API Integration with Error Handling Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt This JavaScript class facilitates fetching historical flight schedules from the Aviation Edge API. It includes methods for making API requests, handling network and API errors, and processing flight data. Dependencies include the 'axios' library for HTTP requests. It returns structured data with success status, flight data, or error details. ```javascript const axios = require('axios'); class AviationEdgeHistoricalAPI { constructor(apiKey) { this.apiKey = apiKey; this.baseURL = 'https://aviation-edge.com/v2/public/flightsHistory'; } async fetchFlights(params) { const queryParams = new URLSearchParams({ key: this.apiKey, ...params }); const endpoint = `${this.baseURL}?${queryParams}`; try { const response = await axios.get(endpoint, { timeout: 10000 }); if (!Array.isArray(response.data)) { throw new Error('Invalid response format'); } return { success: true, data: response.data, count: response.data.length }; } catch (error) { if (error.response) { return { success: false, error: `API Error: ${error.response.status} - ${error.response.statusText}`, details: error.response.data }; } else if (error.request) { return { success: false, error: 'Network error: No response received' }; } else { return { success: false, error: `Request error: ${error.message}` }; } } } async getAirportSchedule(airportCode, type, dateFrom, options = {}) { const params = { code: airportCode, type: type, date_from: dateFrom, ...options }; return await this.fetchFlights(params); } calculateStatistics(flights) { const total = flights.length; const delayed = flights.filter(f => f.departure.delay > 0); const cancelled = flights.filter(f => f.status === 'cancelled'); const totalDelay = delayed.reduce((sum, f) => sum + f.departure.delay, 0); return { total, delayed: delayed.length, cancelled: cancelled.length, delayRate: ((delayed.length / total) * 100).toFixed(2) + '%', cancellationRate: ((cancelled.length / total) * 100).toFixed(2) + '%', averageDelay: delayed.length > 0 ? (totalDelay / delayed.length).toFixed(2) : 0 }; } } // Usage example async function main() { const api = new AviationEdgeHistoricalAPI('your-api-key-here'); // Example 1: Get departure schedule console.log('Fetching JFK departures...'); const departures = await api.getAirportSchedule('JFK', 'departure', '2023-03-04'); if (departures.success) { console.log(`Retrieved ${departures.count} flights`); const stats = api.calculateStatistics(departures.data); console.log('Statistics:', stats); } else { console.error('Error:', departures.error); } // Example 2: Get arrivals for specific airline console.log('\nFetching Turkish Airlines arrivals...'); const tkFlights = await api.getAirportSchedule('JFK', 'arrival', '2023-03-04', { airline_iata: 'TK' }); if (tkFlights.success) { tkFlights.data.forEach(flight => { console.log(`${flight.flight.iataNumber}: ${flight.departure.iataCode} → ${flight.arrival.iataCode}`); }); } // Example 3: Get date range with multiple filters console.log('\nAnalyzing week of data...'); const weekData = await api.getAirportSchedule('JFK', 'departure', '2023-03-01', { date_to: '2023-03-07', arr_iataCode: 'LHR', status: 'landed' }); if (weekData.success) { const stats = api.calculateStatistics(weekData.data); console.log(`JFK → LHR route statistics:`, stats); } } main().catch(console.error); ``` -------------------------------- ### Filter Flights by Status Source: https://context7.com/aviationedgeapi/historical-schedules-api/llms.txt Retrieves flights matching a specific status (e.g., cancelled, delayed, landed) for a given date range and airport. ```APIDOC ## GET /v2/public/flightsHistory ### Description Retrieves only flights matching a specific status such as cancelled, delayed, or landed, streamlining data analysis for specific operational conditions. ### Method GET ### Endpoint `/v2/public/flightsHistory` ### Parameters #### Query Parameters - **key** (string) - Required - Your API key. - **code** (string) - Required - The IATA airport code. - **type** (string) - Required - Type of flight ('arrival' or 'departure'). - **date_from** (string) - Required - Start date for the historical data (YYYY-MM-DD). - **date_to** (string) - Optional - End date for the historical data (YYYY-MM-DD). - **status** (string) - Required - The flight status to filter by (e.g., 'cancelled', 'delayed', 'landed'). ### Request Example ```bash curl -X GET "https://aviation-edge.com/v2/public/flightsHistory?key=YOUR_API_KEY&code=JFK&type=arrival&date_from=2023-03-04&date_to=2023-03-10&status=cancelled" ``` ### Response #### Success Response (200) - **data** (array) - An array of flight objects matching the specified criteria. #### Response Example ```json [ { "flight": { "number": "BA286", "iata": "BA286", "icao": "BAW286" }, "departure": { "airport": { "name": "Heathrow", "iata": "LHR", "icao": "EGLL" }, "scheduled": "2023-03-05T10:00:00Z", "estimated": "2023-03-05T10:05:00Z", "actual": null, "delay": 5, "timezone": "Europe/London" }, "arrival": { "airport": { "name": "John F Kennedy International", "iata": "JFK", "icao": "KJFK" }, "scheduled": "2023-03-05T13:00:00Z", "estimated": "2023-03-05T13:10:00Z", "actual": null, "delay": 10, "timezone": "America/New_York" }, "airline": { "name": "British Airways", "iata": "BA", "icao": "BAW" }, "flight_date": "2023-03-05", "regard": "cancelled", "status": "cancelled" } ] ``` ```