
Security News
pnpm 11.5 Adds Support for Recognizing npm Staged Publishes
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.
airport-data-js
Advanced tools
A comprehensive TypeScript library providing easy retrieval of airport data based on IATA, ICAO, city codes, country codes, and continents. Includes LLM tool definitions for AI integration.
A comprehensive JavaScript library for retrieving airport information by IATA codes, ICAO codes, and various other criteria. This library provides easy access to a large dataset of airports worldwide with detailed information including coordinates, timezone, type, and external links.
npm install airport-data-js
Each airport object contains the following fields:
{
iata: "SIN", // 3-letter IATA code
icao: "WSSS", // 4-letter ICAO code
time: "Asia/Singapore", // Timezone identifier
country_code: "SG", // 2-letter country code
continent: "AS", // 2-letter continent code (AS, EU, NA, SA, AF, OC, AN)
airport: "Singapore Changi Airport", // Airport name
latitude: "1.35019", // Latitude coordinate
longitude: "103.994003", // Longitude coordinate
elevation: "22", // Elevation in feet
type: "large_airport", // Airport type
scheduled_service: true, // Has scheduled commercial service
wikipedia: "https://en.wikipedia.org/wiki/Singapore_Changi_Airport",
website: "https://www.changiairport.com",
runway_length: "13200", // Longest runway in feet
flightradar24_url: "https://www.flightradar24.com/airport/SIN",
radarbox_url: "https://www.radarbox.com/airport/WSSS",
flightaware_url: "https://www.flightaware.com/live/airport/WSSS"
}
const {
getAirportByIata,
getAirportByIcao,
searchByName,
findNearbyAirports
} = require('airport-data-js');
// Get airport by IATA code
const [airport] = await getAirportByIata('SIN');
console.log(airport.airport); // "Singapore Changi Airport"
// Get airport by ICAO code
const [airport] = await getAirportByIcao('WSSS');
console.log(airport.country_code); // "SG"
// Search airports by name
const airports = await searchByName('Singapore');
console.log(airports.length); // Multiple airports matching "Singapore"
// Find nearby airports (within 50km of coordinates)
const nearby = await findNearbyAirports(1.35019, 103.994003, 50);
console.log(nearby); // Airports near Singapore Changi
getAirportByIata(iataCode)Finds airports by their 3-letter IATA code.
const airports = await getAirportByIata('LHR');
// Returns array of airports with IATA code 'LHR'
getAirportByIcao(icaoCode)Finds airports by their 4-character ICAO code.
const airports = await getAirportByIcao('EGLL');
// Returns array of airports with ICAO code 'EGLL'
searchByName(query)Searches for airports by name (case-insensitive, minimum 2 characters).
const airports = await searchByName('Heathrow');
// Returns airports with 'Heathrow' in their name
findNearbyAirports(lat, lon, radiusKm)Finds airports within a specified radius of given coordinates.
const nearby = await findNearbyAirports(51.5074, -0.1278, 100);
// Returns airports within 100km of London coordinates
calculateDistance(code1, code2)Calculates the great-circle distance between two airports using IATA or ICAO codes.
const distance = await calculateDistance('LHR', 'JFK');
// Returns distance in kilometers (approximately 5540)
getAirportByCountryCode(countryCode)Finds all airports in a specific country.
const usAirports = await getAirportByCountryCode('US');
// Returns all airports in the United States
getAirportByContinent(continentCode)Finds all airports on a specific continent.
const asianAirports = await getAirportByContinent('AS');
// Returns all airports in Asia
// Continent codes: AS, EU, NA, SA, AF, OC, AN
getAirportsByType(type)Finds airports by their type.
const largeAirports = await getAirportsByType('large_airport');
// Available types: large_airport, medium_airport, small_airport, heliport, seaplane_base
// Convenience search for all airports
const allAirports = await getAirportsByType('airport');
// Returns large_airport, medium_airport, and small_airport
getAirportsByTimezone(timezone)Finds all airports within a specific timezone.
const londonAirports = await getAirportsByTimezone('Europe/London');
// Returns airports in London timezone
findAirports(filters)Finds airports matching multiple criteria.
// Find large airports in Great Britain with scheduled service
const airports = await findAirports({
country_code: 'GB',
type: 'large_airport',
has_scheduled_service: true
});
// Find airports with minimum runway length
const longRunwayAirports = await findAirports({
min_runway_ft: 10000
});
getAutocompleteSuggestions(query)Provides autocomplete suggestions for search interfaces (returns max 10 results).
const suggestions = await getAutocompleteSuggestions('Lon');
// Returns up to 10 airports matching 'Lon' in name or IATA code
getAirportLinks(code)Gets external links for an airport using IATA or ICAO code.
const links = await getAirportLinks('SIN');
// Returns:
// {
// website: "https://www.changiairport.com",
// wikipedia: "https://en.wikipedia.org/wiki/Singapore_Changi_Airport",
// flightradar24: "https://www.flightradar24.com/airport/SIN",
// radarbox: "https://www.radarbox.com/airport/WSSS",
// flightaware: "https://www.flightaware.com/live/airport/WSSS"
// }
getAirportStatsByCountry(countryCode)Gets comprehensive statistics about airports in a specific country.
const stats = await getAirportStatsByCountry('US');
// Returns:
// {
// total: 5432,
// byType: {
// large_airport: 139,
// medium_airport: 467,
// small_airport: 4826
// },
// withScheduledService: 606,
// averageRunwayLength: 5234,
// averageElevation: 1245,
// timezones: ['America/New_York', 'America/Chicago', ...]
// }
getAirportStatsByContinent(continentCode)Gets comprehensive statistics about airports on a specific continent.
const stats = await getAirportStatsByContinent('AS');
// Returns statistics including count by type, by country,
// scheduled service count, average runway length, elevation, and timezones
getLargestAirportsByContinent(continentCode, limit, sortBy)Gets the largest airports on a continent by runway length or elevation.
// Get top 5 airports in Asia by runway length
const airports = await getLargestAirportsByContinent('AS', 5, 'runway');
// Get top 10 airports in South America by elevation
const highAltitude = await getLargestAirportsByContinent('SA', 10, 'elevation');
getMultipleAirports(codes)Fetches multiple airports by their IATA or ICAO codes in one call.
const airports = await getMultipleAirports(['SIN', 'LHR', 'JFK', 'WSSS']);
// Returns array of airport objects (null for codes not found)
// Efficiently fetches multiple airports at once
calculateDistanceMatrix(codes)Calculates distances between all pairs of airports in a list.
const matrix = await calculateDistanceMatrix(['SIN', 'LHR', 'JFK']);
// Returns:
// {
// airports: [
// { code: 'SIN', name: 'Singapore Changi Airport', iata: 'SIN', icao: 'WSSS' },
// { code: 'LHR', name: 'London Heathrow Airport', iata: 'LHR', icao: 'EGLL' },
// { code: 'JFK', name: 'John F Kennedy International Airport', iata: 'JFK', icao: 'KJFK' }
// ],
// distances: {
// SIN: { SIN: 0, LHR: 10872, JFK: 15344 },
// LHR: { SIN: 10872, LHR: 0, JFK: 5540 },
// JFK: { SIN: 15344, LHR: 5540, JFK: 0 }
// }
// }
findNearestAirport(lat, lon, filters)Finds the single nearest airport to given coordinates, optionally with filters.
// Find nearest airport to coordinates
const nearest = await findNearestAirport(1.35019, 103.994003);
// Returns airport object with additional 'distance' field in km
// Find nearest large airport with scheduled service
const nearestHub = await findNearestAirport(1.35019, 103.994003, {
type: 'large_airport',
has_scheduled_service: true
});
validateIataCode(code)Validates if an IATA code exists in the database.
const isValid = await validateIataCode('SIN'); // true
const isInvalid = await validateIataCode('XYZ'); // false
const isBadFormat = await validateIataCode('ABCD'); // false
validateIcaoCode(code)Validates if an ICAO code exists in the database.
const isValid = await validateIcaoCode('WSSS'); // true
const isInvalid = await validateIcaoCode('XXXX'); // false
getAirportCount(filters)Gets the count of airports matching the given filters without fetching all data.
// Get total airport count
const total = await getAirportCount();
// Get count of large airports in the US
const count = await getAirportCount({
country_code: 'US',
type: 'large_airport'
});
isAirportOperational(code)Checks if an airport has scheduled commercial service.
const operational = await isAirportOperational('SIN'); // true
const notOperational = await isAirportOperational('SOME_SMALL_AIRPORT'); // false
All functions return promises and may throw errors for invalid input or when no data is found.
try {
const airport = await getAirportByIata('XYZ');
} catch (error) {
console.error(error.message); // "No data found for IATA code: XYZ"
}
// Find airports within 100km of Paris
const parisAirports = await findNearbyAirports(48.8566, 2.3522, 100);
console.log(`Found ${parisAirports.length} airports near Paris`);
// Calculate distance between Singapore and London
const distance = await calculateDistance('SIN', 'LHR');
console.log(`Distance: ${Math.round(distance)} km`);
// Get autocomplete suggestions
const suggestions = await getAutocompleteSuggestions('New York');
suggestions.forEach(airport => {
console.log(`${airport.iata} - ${airport.airport}`);
});
// Find large airports in Asia with scheduled service
const asianHubs = await findAirports({
continent: 'AS',
type: 'large_airport',
has_scheduled_service: true
});
// Get comprehensive statistics for US airports
const usStats = await getAirportStatsByCountry('US');
console.log(`Total airports: ${usStats.total}`);
console.log(`Large airports: ${usStats.byType.large_airport}`);
console.log(`Average runway length: ${usStats.averageRunwayLength} ft`);
// Get statistics for Asian airports
const asiaStats = await getAirportStatsByContinent('AS');
console.log(`Countries with airports: ${Object.keys(asiaStats.byCountry).length}`);
// Fetch multiple airports at once
const airports = await getMultipleAirports(['SIN', 'LHR', 'JFK', 'NRT']);
airports.forEach(airport => {
if (airport) {
console.log(`${airport.iata}: ${airport.airport}`);
}
});
// Calculate distance matrix for route planning
const matrix = await calculateDistanceMatrix(['SIN', 'LHR', 'JFK']);
console.log(`Distance from SIN to LHR: ${matrix.distances.SIN.LHR} km`);
console.log(`Distance from LHR to JFK: ${matrix.distances.LHR.JFK} km`);
// Validate airport codes before processing
const codes = ['SIN', 'XYZ', 'LHR', 'ABCD'];
for (const code of codes) {
const isValid = await validateIataCode(code);
console.log(`${code}: ${isValid ? 'Valid' : 'Invalid'}`);
}
// Check if airport is operational
const operational = await isAirportOperational('SIN');
console.log(`Singapore Changi is operational: ${operational}`);
// Find nearest airport to current location
const nearest = await findNearestAirport(1.35019, 103.994003);
console.log(`Nearest airport: ${nearest.airport} (${nearest.distance} km away)`);
// Find nearest large airport with scheduled service
const nearestHub = await findNearestAirport(1.35019, 103.994003, {
type: 'large_airport',
has_scheduled_service: true
});
See CHANGELOG.md for the full version history and release notes.
This library uses a comprehensive dataset of worldwide airports with regular updates to ensure accuracy and completeness.
This project is licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0) - see the LICENSE file for details.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
# Clone the repository
git clone https://github.com/aashishvanand/airport-data-js.git
cd airport-data-js
# Install dependencies
npm install
# Run the test suite
npm test
# Build both Node.js and browser bundles
npm run build
airport-data-js/
├── src/
│ ├── index.js # Library source code
│ └── airports.compressed # Compressed airport dataset
├── lib/ # Node.js CJS build output
├── dist/ # Browser build output
├── data/
│ └── airports.json # Raw airport data (source of truth)
├── scripts/
│ ├── compress_json.js # Compresses airports.json for distribution
│ ├── check_duplicates.js # Validates no duplicate IATA/ICAO codes
│ ├── extract_latest_changelog.js # Extracts changelog for GitHub releases
│ └── benchmark.js # Performance benchmarks
├── tests/
│ └── index.test.js # Jest test suite
├── webpack.node.cjs # Webpack config for Node.js bundle
└── webpack.browser.cjs # Webpack config for browser bundle
| Command | Description |
|---|---|
npm test | Run the Jest test suite |
npm run build | Build both Node.js (lib/) and browser (dist/) bundles |
npm run build:lib | Build only the Node.js bundle |
npm run build:dist | Build only the browser bundle |
npm run check:duplicates | Check for duplicate airport codes in the dataset |
main for your changessrc/index.js or data/airports.jsontests/index.test.jsnpm testnpm run buildmainIf you are adding or updating airport entries:
data/airports.json directlynpm run check:duplicates to ensure no duplicate IATA/ICAO codesnode scripts/compress_json.js to regenerate the compressed datasetnpm test to verify the changesReleases are automated via the release workflow. To publish a new version:
package.json (follow Semantic Versioning)CHANGELOG.md with a new section for the version (follow Keep a Changelog format)npm run build && npm test
mainrelease branch -- this triggers the CI pipeline which will:
npm audit --audit-level=critical)package.json against the published npm versionCHANGELOG.mdThe workflow can also be triggered manually via workflow_dispatch from the Actions tab.
FAQs
A comprehensive TypeScript library providing easy retrieval of airport data based on IATA, ICAO, city codes, country codes, and continents. Includes LLM tool definitions for AI integration.
The npm package airport-data-js receives a total of 6,736 weekly downloads. As such, airport-data-js popularity was classified as popular.
We found that airport-data-js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.

Research
/Security News
A mini Shai-Hulud campaign compromised Red Hat Cloud Services npm packages to steal developer and CI/CD secrets during installation.