This article covers the following platforms
MSFS 2024
MSFS 2020
ATS
FSX
Prepar3D
Use the Airports API to search by ICAO code — an airport’s identifier, like KJFK — or to find airports around a geographic position. Both methods deliver results through callbacks.
find_airport_by_icao()
Find airports whose ICAO code matches a full or partial search value.
SignatureTypeScript contract
find_airport_by_icao(
uid: string,
icao: string,
callback: (airports: Airport[]) => void
): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
uid | string | Yes | Reusable identifier for this search. It must be unique within the widget. |
icao | string | Yes | Full or partial ICAO code to search for. |
callback | (airports: Airport[]) => void | Yes | Function that receives the matching airports. |
ExampleJavaScript
const searchId = "airport-search-by-icao";
this.$api.airports.find_airport_by_icao(searchId, "KJFK", (airports) => {
console.log(airports);
});Returns
voidNo value is returned directly. Matching airports are delivered to the callback.Callback data
| Name | Type | Description |
|---|---|---|
airports | Airport[] | Array of airports matching the full or partial ICAO code. |
find_airports_by_coords()
Find the nearest airports within a radius of a geographic position.
SignatureTypeScript contract
find_airports_by_coords(
uid: string,
longitude: number,
latitude: number,
radius: number,
limit: number,
onAdded: (airports: Airport[]) => void,
onRemoved: (airports: Airport[]) => void,
onError: (error: object) => void,
init: boolean
): voidParameters
| Name | Type | Required | Description |
|---|---|---|---|
uid | string | Yes | Reusable identifier for this search. It must be unique within the widget. |
longitude | number | Yes | Longitude of the search center. |
latitude | number | Yes | Latitude of the search center. |
radius | number | Yes | Search radius in meters. |
limit | number | Yes | Maximum number of airports to keep. The farthest matches are removed first. |
onAdded | (airports: Airport[]) => void | Yes | Receives airports added since the previous search. |
onRemoved | (airports: Airport[]) => void | Yes | Receives airports removed since the previous search. |
onError | (error: object) => void | Yes | Receives an error object when the search fails. |
init | boolean | Yes | When true, onAdded receives every matching airport instead of only changes. |
ExampleJavaScript
const searchId = "airports-near-position";
this.$api.airports.find_airports_by_coords(
searchId,
-73.7781,
40.6413,
50000,
10,
(added) => console.log("Added", added),
(removed) => console.log("Removed", removed),
(error) => console.error(error),
true
);Returns
voidNo value is returned directly. Search changes and failures are delivered to callbacks.Callback data
| Name | Type | Description |
|---|---|---|
added | Airport[] | Airports added to the result set. |
removed | Airport[] | Airports removed from the result set. |
error | object | Error details when the search cannot be completed. |