This module provides functions to retrieve airport and airline information based on IATA and ICAO codes.
Install air-codes using the following command
npm install aircodes
First, require the module in your JavaScript file:
const airportData = require("aircodes");
To retrieve airport information based on IATA or ICAO codes, you can use the following functions:
This function takes an IATA code as an argument and returns the airport object matching the code, or null
if not found.
Example usage:
const airport = airportData.getAirportByIata("AAA");
console.log(airport);
Output:
{
"iata": "AAA",
"icao": "NTGA",
"name": "Anaa Airport",
"city": "Anaa",
"state": "Tuamotus",
"country": "French Polynesia"
}
This function takes an ICAO code as an argument and returns the airport object matching the code, or null
if not found.
Example usage:
const airport = airportData.getAirportByIcao("NTGA");
console.log(airport);
Output:
{
"iata": "AAA",
"icao": "NTGA",
"name": "Anaa Airport",
"city": "Anaa",
"state": "Tuamotus",
"country": "French Polynesia"
}
To retrieve airline information based on IATA or ICAO codes, you can use the following functions:
This function takes an IATA code as an argument and returns the airline object matching the code, or null
if not found.
Example usage:
const airline = airportData.getAirlineByIata("AA");
console.log(airline);
Output:
{
"iata": "AA",
"icao": "AAL",
"name": "American Airlines",
"logo": "https://www.avcodes.co.uk/images/logos/AAL.png",
}
This function takes an ICAO code as an argument and returns the airline object matching the code, or null
if not found.
Example usage:
const airline = airportData.getAirlineByIcao("AAL");
console.log(airline);
Output:
{
"iata": "AA",
"icao": "AAL",
"name": "American Airlines",
"logo": "https://www.avcodes.co.uk/images/logos/AAL.png",
}
This function takes a query string as an argument and returns the airport object matching the query, or null if no match was found.
Example usage:
const airport = findAirport("cotonou");
console.log(airport);
Output:
[
{
iata: 'COO',
icao: 'DBBB',
name: 'Cadjehoun Airport',
city: 'Cotonou',
state: '',
country: 'Benin'
}
]
This function takes a query string as an argument and returns the airline object matching the query, or null if no match was found.
Example usage:
const airline = findAirline("brussel");
console.log(airline);
Output:
[
{
iata: 'SN',
icao: 'BEL',
name: 'Brussels Airlines N.V.',
logo: 'https://www.avcodes.co.uk/images/logos/BEL.png'
}
]
Contributions are welcome! If you have any suggestions, improvements, or bug fixes, please create an issue or submit a pull request.
This module is licensed under the MIT License.