### Search Airlines for Autocomplete Source: https://aviationstack.com/documentation This example demonstrates how to use the 'search' parameter to get autocomplete suggestions for airlines. Replace 'YOUR_ACCESS_KEY' with your valid API key. ```http https://api.aviationstack.com/v1/airlines ? access_key = YOUR_ACCESS_KEY & search = american ``` -------------------------------- ### Get Airports Source: https://aviationstack.com/documentation This example demonstrates how to fetch a list of airports using the `/v1/airports` endpoint with your API access key. You can also utilize query parameters like `limit`, `offset`, and `search` for more specific results. ```APIDOC ## GET /v1/airports ### Description Retrieves a list of global airports. Supports filtering and searching capabilities. ### Method GET ### Endpoint https://api.aviationstack.com/v1/airports ### Parameters #### Query Parameters - **access_key** (string) - Required - Your API access key. - **callback** (string) - Optional - Specifies a JSONP callback function name. - **limit** (integer) - Optional - Limits the number of results returned. Max value depends on the plan. - **offset** (integer) - Optional - Specifies an offset for pagination. Default is 0. - **search** (string) - Optional - Use for autocomplete suggestions. Available for paid plans. ### Request Example ``` https://api.aviationstack.com/v1/airports?access_key=YOUR_ACCESS_KEY ``` ### Response #### Success Response (200) - **pagination** (object) - Contains pagination details like limit, offset, count, and total results. - **data** (array) - An array of airport objects. - **airport_name** (string) - The full name of the airport. - **iata_code** (string) - The IATA code of the airport. - **icao_code** (string) - The ICAO code of the airport. - **latitude** (string) - The latitude coordinate of the airport. - **longitude** (string) - The longitude coordinate of the airport. - **geoname_id** (string) - The GeoNames ID of the airport. - **timezone** (string) - The timezone of the airport. - **gmt** (string) - The GMT offset in hours. - **phone_number** (string) - The phone number of the airport. - **country_name** (string) - The name of the country the airport is in. - **country_iso2** (string) - The ISO 3166-1 alpha-2 country code. - **city_iata_code** (string) - The IATA code of the city the airport is in. ### Response Example ```json { "pagination": { "limit": 100, "offset": 0, "count": 100, "total": 6471 }, "data": [ { "airport_name": "Anaa", "iata_code": "AAA", "icao_code": "NTGA", "latitude": "-17.05", "longitude": "-145.41667", "geoname_id": "6947726", "timezone": "Pacific/Tahiti", "gmt": "-10", "phone_number": null, "country_name": "French Polynesia", "country_iso2": "PF", "city_iata_code": "AAA" } ] } ``` ``` -------------------------------- ### Request Countries Data Source: https://aviationstack.com/documentation This example demonstrates how to make a GET request to the countries endpoint to retrieve a list of countries. Replace YOUR_ACCESS_KEY with your actual API key. ```bash Sign Up to Run API Requesthttps://api.aviationstack.com/v1/countries ? access_key = YOUR_ACCESS_KEY ``` -------------------------------- ### Get Historical Flights Source: https://aviationstack.com/documentation This example demonstrates how to fetch historical flight data for a specific date using the `/v1/flights` endpoint with the `flight_date` parameter. Remember to replace `YOUR_ACCESS_KEY` with your actual API key. ```APIDOC ## GET /v1/flights ### Description Retrieves historical flight data for a specified date. ### Method GET ### Endpoint https://api.aviationstack.com/v1/flights ### Parameters #### Query Parameters - **access_key** (string) - Required - Your API access key. - **flight_date** (string) - Required - The historical flight date in `YYYY-MM-DD` format. Example: `2026-03-29`. - **callback** (string) - Optional - JSONP callback function name. - **limit** (integer) - Optional - Maximum number of results to return (max 100 or 1000 depending on plan). Default is 100. - **offset** (integer) - Optional - Offset for pagination. Default is 0. - **flight_status** (string) - Optional - Filter by flight status (`scheduled`, `active`, `landed`, `cancelled`, `incident`, `diverted`). - **dep_iata** (string) - Optional - Filter by departure airport IATA code. - **arr_iata** (string) - Optional - Filter by arrival airport IATA code. - **dep_icao** (string) - Optional - Filter by departure airport ICAO code. - **arr_icao** (string) - Optional - Filter by arrival airport ICAO code. - **airline_name** (string) - Optional - Filter by airline name. - **airline_iata** (string) - Optional - Filter by airline IATA code. - **airline_icao** (string) - Optional - Filter by airline ICAO code. - **flight_number** (string) - Optional - Filter by flight number. - **flight_iata** (string) - Optional - Filter by flight IATA code. - **flight_icao** (string) - Optional - Filter by flight ICAO code. - **min_delay_dep** (integer) - Optional - Minimum departure delay in minutes. - **min_delay_arr** (integer) - Optional - Minimum arrival delay in minutes. - **max_delay_dep** (integer) - Optional - Maximum departure delay in minutes. - **max_delay_arr** (integer) - Optional - Maximum arrival delay in minutes. - **arr_scheduled_time_arr** (string) - Optional - Filter by scheduled arrival date in `YYYY-MM-DD` format. - **dep_scheduled_time_dep** (string) - Optional - Filter by scheduled departure date in `YYYY-MM-DD` format. ### Request Example ```javascript const url = "https://api.aviationstack.com/v1/flights?access_key={PASTE_YOUR_API_KEY_HERE}&flight_date=2019-12-11"; const options = { method: "GET", }; try { const response = await fetch(url, options); const result = await response.text(); console.log(result); } catch (error) { console.error(error); } ``` ### Response #### Success Response (200) The response structure is identical to the real-time flight data response. ``` -------------------------------- ### Example API Request for Airline Routes Source: https://aviationstack.com/documentation This is an example of how to construct an API request to the 'routes' endpoint. Remember to replace 'YOUR_ACCESS_KEY' with your actual API access key. ```http https://api.aviationstack.com/v1/routes ? access_key = YOUR_ACCESS_KEY ``` -------------------------------- ### JSONP Callback Example Source: https://aviationstack.com/documentation This example shows how to use the 'callback' parameter to enable JSONP functionality, wrapping the API response in a specified JavaScript function. Replace 'MY_FUNCTION' with your desired callback function name. ```http https://api.aviationstack.com/v1/flights ? access_key = YOUR_ACCESS_KEY & callback = MY_FUNCTION ``` -------------------------------- ### Fetch All Airports Data Source: https://aviationstack.com/documentation This example demonstrates how to fetch a list of all available airports using the API. Replace YOUR_ACCESS_KEY with your actual API key. ```http https://api.aviationstack.com/v1/airports ? access_key = YOUR_ACCESS_KEY ``` -------------------------------- ### Fetch and Display Flights in Node.js Source: https://aviationstack.com/documentation Employ the 'axios' library to make an HTTP GET request to the aviationstack API. This example logs information about flights that are currently in the air. Replace 'YOUR_ACCESS_KEY' with your actual API key. ```javascript const axios = require('axios'); const params = { access_key: 'YOUR_ACCESS_KEY' } axios.get('https://api.aviationstack.com/v1/flights', {params}) .then(response => { const apiResponse = response.data; if (Array.isArray(apiResponse['results'])) { apiResponse['results'].forEach(flight => { if (!flight['live']['is_ground']) { console.log(`${flight['airline']['name']} flight ${flight['flight']['iata']}`, `from ${flight['departure']['airport']} (${flight['departure']['iata']})`, `to ${flight['arrival']['airport']} (${flight['arrival']['iata']}) is in the air.`); } }); } }).catch(error => { console.log(error); }); ``` -------------------------------- ### Flight Schedules API Request Example Source: https://aviationstack.com/documentation This is an example of how to construct an API request URL for the Flight Schedules endpoint. Ensure you replace 'YOUR_ACCESS_KEY' with your actual API key. ```http https://api.aviationstack.com/v1/timetable ? iataCode = DXB & type = departure & access_key = YOUR_ACCESS_KEY ``` -------------------------------- ### Fetch Future Flight Schedules (JavaScript) Source: https://aviationstack.com/documentation Use this JavaScript fetch example to retrieve future flight schedule data. Replace {PASTE_YOUR_API_KEY_HERE} with your actual API key. The example queries for departures from JFK on a specific date. ```javascript const url = "https://api.aviationstack.com/v1/flightsFuture?access_key={PASTE_YOUR_API_KEY_HERE}&iataCode=JFK&type=departure&date=2024-08-17"; const options = { method: "GET", }; try { const response = await fetch(url, options); const result = await response.text(); console.log(result); } catch (error) { console.error(error); } ``` -------------------------------- ### Flights Endpoint Example Source: https://aviationstack.com/documentation Example of how to fetch flight data using the aviationstack API with Ruby. ```APIDOC ## GET /v1/flights ### Description Fetches flight data. ### Method GET ### Endpoint https://api.aviationstack.com/v1/flights ### Parameters #### Query Parameters - **access_key** (string) - Required - Your API access key. ### Request Example ```ruby require 'net/http' require 'json' params = { :access_key => "YOUR_ACCESS_KEY" } uri = URI('https://api.aviationstack.com/v1/flights') uri.query = URI.encode_www_form(params) json = Net::HTTP.get(uri) api_response = JSON.parse(json) for flight in api_response['results'] unless flight['live']['is_ground'] puts sprintf("%s flight %s from %s (%s) to %s (%s) is in the air.", flight['airline']['name'], flight['flight']['iata'], flight['departure']['airport'], flight['departure']['iata'], flight['arrival']['airport'], flight['arrival']['iata'] ) end end ``` ### Response #### Success Response (200) - **results** (array) - Contains flight data. - **airline** (object) - **flight** (object) - **departure** (object) - **arrival** (object) - **live** (object) #### Response Example ```json { "results": [ { "airline": { "name": "Lufthansa", "iata": "LH", "icao": "DLH" }, "flight": { "number": "456", "iata": "LH456", "icao": "DLH456", "codeshared": null }, "departure": { "airport": "Frankfurt Airport", "iata": "FRA", "icao": "EDDF", "terminal": "2", "gate": "A12", "delay": null, "scheduled": "2023-10-26T10:00:00+00:00", "estimated": "2023-10-26T10:00:00+00:00", "actual": "2023-10-26T10:00:00+00:00", "estimated_runway": "2023-10-26T10:00:00+00:00", "actual_runway": "2023-10-26T10:00:00+00:00" }, "arrival": { "airport": "John F. Kennedy International Airport", "iata": "JFK", "icao": "KJFK", "terminal": "4", "gate": "B24", "delay": null, "scheduled": "2023-10-26T12:30:00+00:00", "estimated": "2023-10-26T12:30:00+00:00", "actual": "2023-10-26T12:30:00+00:00", "estimated_runway": "2023-10-26T12:30:00+00:00", "actual_runway": "2023-10-26T12:30:00+00:00" }, "live": { "is_ground": false, "speed": 500, "deg": 270, "alt": 35000, "dir": "W", "lat": 40.7128, "lng": -74.0060, "update": "2023-10-26T11:00:00+00:00" } } ], "pagination": { "limit": 100, "offset": 0, "count": 1, "total": 1000 } } ``` ``` -------------------------------- ### Example API Request URL Source: https://aviationstack.com/documentation Customers may connect to the API using industry-standard 256-bit HTTPS (SSL) encryption. No paid plan is needed for HTTPS access. ```bash https://api.aviationstack.com ``` -------------------------------- ### Example API Response Snippet Source: https://aviationstack.com/documentation This is a shortened example of an API response, illustrating the structure of flight data. Note that actual responses may contain more detailed information. ```json { "data": [ { "airline": { "icaoCode": "eva", "name": "eva air" }, "flight": { "iataNumber": "br32", "icaoNumber": "eva32", "number": "32" } }, "departure": { "actualRunway": "2024-06-18T20:46:00.000", "actualTime": "2024-06-18T20:46:00.000", "baggage": null, "delay": "97", "estimatedRunway": "2024-06-18T20:46:00.000", "estimatedTime": "2024-06-18T19:10:00.000", "gate": "C4", "iataCode": "TPE", "icaoCode": "RCTP", "scheduledTime": "2024-06-18T19:10:00.000", "terminal": "2" }, "flight": { "iataNumber": "AV4511", "icaoNumber": "AVA4511", "number": "4511" }, "status": "scheduled", "type": "arrival" } [...] ] } ``` -------------------------------- ### Get Airplanes Information - JavaScript Fetch Source: https://aviationstack.com/documentation Use the Airplanes endpoint to retrieve details about airplanes. Replace {PASTE_YOUR_API_KEY_HERE} with your actual API key. This example uses the Fetch API for making the request. ```javascript const url = "https://api.aviationstack.com/v1/airplanes?access_key={PASTE_YOUR_API_KEY_HERE}"; const options = { method: "GET", }; try { const response = await fetch(url, options); const result = await response.text(); console.log(result); } catch (error) { console.error(error); } ``` -------------------------------- ### Flight Schedules API Response Example Source: https://aviationstack.com/documentation This is an example of a JSON response from the Flight Schedules API, showing pagination details and a data array containing flight schedule information. ```json { "pagination": { "limit": 10, "offset": 0, "count": 10, "total": 176 }, "data": [ { "airline": { "iataCode": "AV", "icaoCode": "AVA", "name": "SA AVIANCA" }, "arrival": { "actualRunway": null, "actualTime": null, "baggage": null, "delay": "65", "estimatedRunway": null, "estimatedTime": "2024-06-18T23:10:00.000", "gate": "3", "iataCode": "JFK", "icaoCode": "KJFK", "scheduledTime": "2024-06-18T22:05:00.000", "terminal": "1" }, "codeshared": { "airline": { "iataCode": "br", ``` -------------------------------- ### Example API Response for Real-Time Flight Data Source: https://aviationstack.com/documentation This is an example of the JSON response structure when querying the real-time flights API. It includes pagination details and flight data, such as departure and arrival information. ```json { "pagination": { "limit": 100, "offset": 0, "count": 100, "total": 1669022 }, "data": [ { "flight_date": "2019-12-12", "flight_status": "active", "departure": { "airport": "San Francisco International", "timezone": "America/Los_Angeles", "iata": "SFO", "icao": "KSFO", "terminal": "2", "gate": "D11", "delay": 13, "scheduled": "2019-12-12T04:20:00+00:00", "estimated": "2019-12-12T04:20:00+00:00", "actual": "2019-12-12T04:20:13+00:00", "estimated_runway": "2019-12-12T04:20:13+00:00", "actual_runway": "2019-12-12T04:20:13+00:00" }, "arrival": { "airport": "Dallas/Fort Worth International", "timezone": "America/Chicago", "iata": "DFW", "icao": "KDFW", "terminal": "A", "gate": "A22", "baggage": "A17", "delay": 0, "scheduled": "2019-12-12T04:20:00+00:00" } } ] } ``` -------------------------------- ### JSONP Callback Response Example Source: https://aviationstack.com/documentation This illustrates the structure of an API response when using the JSONP callback parameter. The actual data is wrapped within the specified function name. ```json MY_FUNCTION ({ { [...] } }) ``` -------------------------------- ### Fetch Cities Data with JavaScript Source: https://aviationstack.com/documentation Use this JavaScript fetch example to retrieve city data from the aviationstack API. Ensure you replace YOUR_ACCESS_KEY with your actual API key. ```javascript const url = "https://api.aviationstack.com/v1/cities?access_key={PASTE_YOUR_API_KEY_HERE}"; const options = { method: "GET", }; try { const response = await fetch(url, options); const result = await response.text(); console.log(result); } catch (error) { console.error(error); } ``` -------------------------------- ### Get Flight Departures - JavaScript Fetch Source: https://aviationstack.com/documentation Use the Fetch API in JavaScript to retrieve flight departure schedules. Replace {PASTE_YOUR_API_KEY_HERE} with your actual API key. This example fetches data for JFK airport. ```javascript const url = "https://api.aviationstack.com/v1/timetable?access_key={PASTE_YOUR_API_KEY_HERE}&iataCode=JFK&type=departure"; const options = { method: "GET", }; try { const response = await fetch(url, options); const result = await response.text(); console.log(result); } catch (error) { console.error(error); } ``` -------------------------------- ### Fetch Aviation Taxes Data (JavaScript) Source: https://aviationstack.com/documentation Use this JavaScript code to make a GET request to the aviation taxes endpoint. Replace YOUR_ACCESS_KEY with your actual API key. This example uses the Fetch API to retrieve tax data. ```javascript const url = "https://api.aviationstack.com/v1/taxes?access_key={PASTE_YOUR_API_KEY_HERE}"; const options = { method: "GET", }; try { const response = await fetch(url, options); const result = await response.text(); console.log(result); } catch (error) { console.error(error); } ``` -------------------------------- ### Example Airplanes API Response Source: https://aviationstack.com/documentation This is an example of the JSON response structure for the airplanes endpoint. The response includes pagination details and an array of airplane data objects. The example is shortened for readability. ```json { "pagination": { "limit": 100, "offset": 0, "count": 100, "total": 19052 }, "data": [ { "id": "5919451", "iata_type": "B737-300", "airplane_id": "1", "airline_iata_code": "0B", "iata_code_long": "B733", "iata_code_short": "733", "airline_icao_code": null, "construction_number": "23653", "delivery_date": "1986-08-21T22:00:00.000Z", "engines_count": "2", "engines_type": "JET", "first_flight_date": "1986-08-02T22:00:00.000Z", "icao_code_hex": "4A0823", "line_number": "1260", "model_code": "B737-377", "registration_number": "YR-BAC", "test_registration_number": null, "plane_age": "31", "plane_class": null, "model_name": "737", "plane_owner": "Airwork Flight Operations Ltd", "plane_series": "377", "plane_status": "active", "production_line": "Boeing 737 Classic", "registration_date": "0000-00-00", "rollout_date": null }, [...] ] } ``` -------------------------------- ### Fetch and Display Flights in Go Source: https://aviationstack.com/documentation This Go program demonstrates how to make an HTTP GET request to the aviationstack API, parse the JSON response, and print details of flights that are currently airborne. Replace 'YOUR_ACCESS_KEY' with your actual API key. ```go package main import ( "encoding/json" "fmt" "net/http" ) type Airline struct { Name string `json:"name"` } type FlightInfo struct { IATACode string `json:"iata"` } type Destination struct { Airport string `json:"airport"` IATACode string `json:"iata"` } type LiveData struct { IsGround bool `json:"is_ground"` } type Flight struct { Airline Airline `json:"airline"` FlightInfo FlightInfo `json:"flight"` Departure Destination `json:"departure"` Arrival Destination `json:"arrival"` Live LiveData `json:"live"` } type Response struct { Flights []Flight `json:"results"` } func main() { httpClient := http.Client{} req, err := http.NewRequest("GET", "https://api.aviationstack.com/v1/flights", nil) if err != nil { panic(err) } q := req.URL.Query() q.Add("access_key", "YOUR_ACCESS_KEY") req.URL.RawQuery = q.Encode() res, err := httpClient.Do(req) if err != nil { panic(err) } defer res.Body.Close() var apiResponse Response json.NewDecoder(res.Body).Decode(&apiResponse) for _, flight := range apiResponse.Flights { if (!flight.Live.IsGround) { fmt.Println(fmt.Sprintf("%s flight %s from %s (%s) to %s (%s) is in the air.", flight.Airline.Name, flight.FlightInfo.IATACode, flight.Departure.Airport, flight.Departure.IATACode, flight.Arrival.Airport, flight.Arrival.IATACode)) } } } ``` -------------------------------- ### Fetch Aircraft Types Data (JavaScript) Source: https://aviationstack.com/documentation Use this JavaScript fetch example to retrieve a list of aircraft types from the API. Replace YOUR_API_KEY_HERE with your actual access key. Ensure you handle potential errors during the fetch operation. ```javascript const url = "https://api.aviationstack.com/v1/aircraft_types?access_key={PASTE_YOUR_API_KEY_HERE}"; const options = { method: "GET", }; try { const response = await fetch(url, options); const result = await response.text(); console.log(result); } catch (error) { console.error(error); } ``` -------------------------------- ### API Request with Access Key Source: https://aviationstack.com/documentation Attach the `access_key` parameter to any valid API endpoint URL and set it to your access key. Keep your key safe at all times. ```bash https://api.aviationstack.com/v1/flights ? access_key = YOUR_ACCESS_KEY ``` -------------------------------- ### Timetable - Basic Plan and higher Source: https://aviationstack.com/documentation This endpoint provides timetable information. The Basic plan and higher are required to access this data. Note the specific rate limits for free and paid plans. ```APIDOC ## GET /timetable ### Description Retrieves flight timetable data. Available on Basic plan and higher. ### Endpoint `/timetable` ### Rate Limits - **Paid plans:** 1 request/10s - **Free plans:** 1 request/60s ### Response Example (Partial) ```json { "pagination": { "limit": 50, "offset": 0, "count": 1, "total": 1000 }, "data": [ { "flight_date": "2024-06-18", "departure": { "iataCode": "TPE", "icaoCode": "RCTP", "scheduledTime": "2024-06-18T19:10:00.000Z", "estimatedTime": "2024-06-18T19:10:00.000Z", "actualTime": "2024-06-18T20:46:00.000Z", "estimatedRunway": "2024-06-18T20:46:00.000Z", "actualRunway": "2024-06-18T20:46:00.000Z", "delay": "97", "terminal": "2", "gate": "C4", "airport": { "iataCode": "TPE", "icaoCode": "RCTP", "name": "Taiwan Taoyuan International Airport" } }, "arrival": { "iataCode": "LAX", "icaoCode": "KLAX", "scheduledTime": "2024-06-19T10:00:00.000Z", "estimatedTime": "2024-06-19T10:00:00.000Z", "actualTime": null, "estimatedRunway": null, "actualRunway": null, "delay": null, "terminal": "B", "gate": "30", "airport": { "iataCode": "LAX", "icaoCode": "KLAX", "name": "Los Angeles International Airport" } }, "airline": { "iataCode": "BR", "icaoCode": "EVA", "name": "EVA Air" }, "flight": { "iataNumber": "BR32", "icaoNumber": "EVA32", "number": "32" }, "codeshared": null, "is_codeshare": false, "cancellation": null, "realTime": null, "flight_status": "scheduled" } ] } ``` ### API Response Objects **`pagination`** - `limit` (integer): Returns the specified limit of results per pagination page. - `offset` (integer): Returns the specified pagination offset. - `count` (integer): Returns the number of results found on the current pagination page. - `total` (integer): Returns the total number of results found for your API request. **`data`** (array of objects) - `flight_date` (string): The date of the flight. - `departure` (object): Details about the departure. - `iataCode` (string): IATA code of the departure airport. - `icaoCode` (string): ICAO code of the departure airport. - `scheduledTime` (string): Scheduled departure time. - `estimatedTime` (string): Estimated departure time. - `actualTime` (string): Actual departure time. - `estimatedRunway` (string): Estimated runway departure time. - `actualRunway` (string): Actual runway departure time. - `delay` (string): Departure delay in minutes. - `terminal` (string): Departure terminal. - `gate` (string): Departure gate. - `airport` (object): Departure airport details. - `iataCode` (string): IATA code of the departure airport. - `icaoCode` (string): ICAO code of the departure airport. - `name` (string): Name of the departure airport. - `arrival` (object): Details about the arrival. - `iataCode` (string): IATA code of the arrival airport. - `icaoCode` (string): ICAO code of the arrival airport. - `scheduledTime` (string): Scheduled arrival time. - `estimatedTime` (string): Estimated arrival time. - `actualTime` (string): Actual arrival time. - `estimatedRunway` (string): Estimated runway arrival time. - `actualRunway` (string): Actual runway arrival time. - `delay` (string): Arrival delay in minutes. - `terminal` (string): Arrival terminal. - `gate` (string): Arrival gate. - `airport` (object): Arrival airport details. - `iataCode` (string): IATA code of the arrival airport. - `icaoCode` (string): ICAO code of the arrival airport. - `name` (string): Name of the arrival airport. - `airline` (object): Details about the airline. - `iataCode` (string): IATA code of the airline. - `icaoCode` (string): ICAO code of the airline. - `name` (string): Full name of the airline. - `flight` (object): Details about the flight number. - `iataNumber` (string): IATA flight number. - `icaoNumber` (string): ICAO flight number. - `number` (string): Flight number without the airline code. - `codeshared` (object or null): Details about a codeshare flight, if applicable. - `airline` (object): Codeshare airline details. - `iataCode` (string): IATA code of the codeshare airline. - `icaoCode` (string): ICAO code of the codeshare airline. - `name` (string): Full name of the codeshare airline. - `flight` (object): Codeshare flight number details. - `iataNumber` (string): IATA flight number of the codeshare flight. - `icaoNumber` (string): ICAO flight number of the codeshare flight. - `number` (string): Flight number without the airline code. - `is_codeshare` (boolean): Indicates if the flight is a codeshare. - `cancellation` (object or null): Details about flight cancellation, if applicable. - `realTime` (object or null): Real-time flight data, if available. - `flight_status` (string): The current status of the flight (e.g., "scheduled", "cancelled"). ``` -------------------------------- ### Get Airplanes Source: https://aviationstack.com/documentation Retrieve a list of airplanes. Paid subscribers can use the 'search' parameter for autocomplete suggestions. ```APIDOC ## GET /v1/airplanes ### Description Retrieves a list of airplanes. Paid subscribers can use the 'search' parameter for autocomplete suggestions. ### Method GET ### Endpoint https://api.aviationstack.com/v1/airplanes ### Parameters #### Query Parameters - **access_key** (string) - Required - Your API access key. - **callback** (string) - Optional - Use this parameter to specify a JSONP callback function name. - **limit** (integer) - Optional - Specify a limit of results to return. Maximum value is 100 (below Professional Plan) or 1000 (Professional Plan and above). Default is 100. - **offset** (integer) - Optional - Specify an offset for pagination. Default is 0. - **search** (string) - Optional - Use this parameter to get autocomplete suggestions for airplanes by specifying any search term. Only available for paid plan subscribers. ### Request Example ``` https://api.aviationstack.com/v1/airplanes?access_key=YOUR_ACCESS_KEY ``` ### Response #### Success Response (200) - **pagination** (object) - Contains pagination details. - **limit** (integer) - The limit of results per page. - **offset** (integer) - The offset for pagination. - **count** (integer) - The number of results found on the current page. - **total** (integer) - The total number of results found. - **data** (array) - An array of airplane objects. - **id** (string) - The unique identifier for the airplane. - **iata_type** (string) - The IATA type of the airplane. - **airplane_id** (string) - The internal ID of the airplane. - **airline_iata_code** (string) - The IATA code of the airline. - **iata_code_long** (string) - The long IATA code of the airplane. - **iata_code_short** (string) - The short IATA code of the airplane. - **airline_icao_code** (string) - The ICAO code of the airline. - **construction_number** (string) - The construction number of the airplane. - **delivery_date** (string) - The delivery date of the airplane. - **engines_count** (string) - The number of engines on the airplane. - **engines_type** (string) - The type of engines on the airplane. - **first_flight_date** (string) - The date of the first flight. - **icao_code_hex** (string) - The HEX ICAO code of the airplane. - **line_number** (string) - The production line number. - **model_code** (string) - The model code of the airplane. - **registration_number** (string) - The registration number of the airplane. - **test_registration_number** (string) - The test registration number. - **plane_age** (string) - The age of the airplane in years. - **plane_class** (string) - The class of the airplane. - **model_name** (string) - The model name of the airplane. - **plane_owner** (string) - The owner of the airplane. - **plane_series** (string) - The series of the airplane. - **plane_status** (string) - The status of the airplane. - **production_line** (string) - The production line of the airplane. - **registration_date** (string) - The registration date. - **rollout_date** (string) - The rollout date. #### Response Example ```json { "pagination": { "limit": 100, "offset": 0, "count": 100, "total": 19052 }, "data": [ { "id": "5919451", "iata_type": "B737-300", "airplane_id": "1", "airline_iata_code": "0B", "iata_code_long": "B733", "iata_code_short": "733", "airline_icao_code": null, "construction_number": "23653", "delivery_date": "1986-08-21T22:00:00.000Z", "engines_count": "2", "engines_type": "JET", "first_flight_date": "1986-08-02T22:00:00.000Z", "icao_code_hex": "4A0823", "line_number": "1260", "model_code": "B737-377", "registration_number": "YR-BAC", "test_registration_number": null, "plane_age": "31", "plane_class": null, "model_name": "737", "plane_owner": "Airwork Flight Operations Ltd", "plane_series": "377", "plane_status": "active", "production_line": "Boeing 737 Classic", "registration_date": "0000-00-00", "rollout_date": null }, [...] ] } ``` ``` -------------------------------- ### Get Airplanes Source: https://aviationstack.com/documentation Retrieve information about airplanes, such as registration numbers and production lines. This endpoint is available on all plans. ```APIDOC ## GET /v1/airplanes ### Description Retrieves information about airplanes, including registration numbers and production lines. ### Method GET ### Endpoint /v1/airplanes ### Query Parameters - **access_key** (string) - Required - Your API access key. ### Request Example ```javascript const url = "https://api.aviationstack.com/v1/airplanes?access_key={PASTE_YOUR_API_KEY_HERE}"; const options = { method: "GET", }; try { const response = await fetch(url, options); const result = await response.text(); console.log(result); } catch (error) { console.error(error); } ``` ``` -------------------------------- ### Get Cities Data Source: https://aviationstack.com/documentation Retrieve a list of cities using the /cities endpoint. Paid plan subscribers can use the 'search' parameter for autocomplete suggestions. ```APIDOC ## GET /v1/cities ### Description Retrieves data about available cities. Supports optional parameters for filtering and pagination. The `search` parameter is available for paid plan subscribers to get autocomplete suggestions. ### Method GET ### Endpoint https://api.aviationstack.com/v1/cities ### Parameters #### Query Parameters - **access_key** (string) - Required - Your API access key. - **callback** (string) - Optional - Specifies a JSONP callback function name. - **limit** (integer) - Optional - Limits the number of results returned. Max 100 for non-Professional plans, 1000 for Professional plans and above. Default is 100. - **offset** (integer) - Optional - Specifies the offset for pagination. Default is 0. - **search** (string) - Optional - Use to get autocomplete suggestions for cities. Available only for paid plan subscribers. ### Request Example ``` https://api.aviationstack.com/v1/cities?access_key=YOUR_ACCESS_KEY ``` ### Response #### Success Response (200) - **pagination** (object) - Contains pagination details (`limit`, `offset`, `count`, `total`). - **data** (array) - An array of city objects. - **id** (string) - The city's ID. - **gmt** (string) - The GMT offset in hours. - **city_id** (string) - The city's unique identifier. - **iata_code** (string) - The IATA code for the city. - **country_iso2** (string) - The 2-letter ISO country code. - **geoname_id** (string|null) - The GeoName ID. - **latitude** (string) - The city's latitude coordinate. - **longitude** (string) - The city's longitude coordinate. - **city_name** (string) - The name of the city. - **timezone** (string) - The city's timezone. #### Response Example ```json { "pagination": { "limit": 100, "offset": 0, "count": 100, "total": 9368 }, "data": [ { "id": "2895475", "gmt": "-10", "city_id": "1", "iata_code": "AAA", "country_iso2": "PF", "geoname_id": null, "latitude": "-17.05", "longitude": "-145.41667", "city_name": "Anaa", "timezone": "Pacific/Tahiti" }, [...] ] } ``` ``` -------------------------------- ### Fetch and Display Flights in Python Source: https://aviationstack.com/documentation Utilize the 'requests' library to query the aviationstack API for flight data and print details of flights that are airborne. Remember to substitute 'YOUR_ACCESS_KEY' with your valid API key. ```python import requests params = { 'access_key': 'YOUR_ACCESS_KEY' } api_result = requests.get('https://api.aviationstack.com/v1/flights', params) api_response = api_result.json() for flight in api_response['results']: if (flight['live']['is_ground'] is False): print(u'%s flight %s from %s (%s) to %s (%s) is in the air.' % ( flight['airline']['name'], flight['flight']['iata'], flight['departure']['airport'], flight['departure']['iata'], flight['arrival']['airport'], flight['arrival']['iata'])) ``` -------------------------------- ### Request Airplanes Data Source: https://aviationstack.com/documentation Use this endpoint to get data about different airplanes. Paid plan subscribers can use the 'search' parameter for autocomplete suggestions. ```bash https://api.aviationstack.com/v1/airplanes ? access_key = YOUR_ACCESS_KEY ```