npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

airport-data-js

v3.0.0

Published

A comprehensive library providing easy retrieval of airport data based on IATA, ICAO, city codes, country codes, and continents.

Readme

Airport Data JS

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.

Installation

npm install airport-data-js

Features

  • 🌍 Comprehensive airport database with worldwide coverage
  • 🔍 Search by IATA codes, ICAO codes, country, continent, and more
  • 📍 Geographic proximity search with customizable radius
  • 🔗 External links to Wikipedia, airport websites, and flight tracking services
  • 📏 Distance calculation between airports
  • 🏷️ Filter by airport type (large_airport, medium_airport, small_airport, heliport, seaplane_base)
  • 🕒 Timezone-based airport lookup
  • 💡 Autocomplete suggestions for search interfaces
  • 🎯 Advanced multi-criteria filtering
  • 📊 Statistical analysis by country and continent
  • 🔢 Bulk operations for multiple airports
  • ✅ Code validation utilities
  • 🎚️ Airport ranking by runway length and elevation

Airport Data Structure

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"
}

Basic Usage

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

API Reference

Core Search Functions

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

Geographic Functions

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)

Filtering Functions

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

Advanced Functions

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"
// }

Statistical & Analytical Functions

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');

Bulk Operations

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
});

Validation & Utilities

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

Error Handling

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"
}

Examples

Find airports near a city

// Find airports within 100km of Paris
const parisAirports = await findNearbyAirports(48.8566, 2.3522, 100);
console.log(`Found ${parisAirports.length} airports near Paris`);

Get flight distance

// Calculate distance between Singapore and London
const distance = await calculateDistance('SIN', 'LHR');
console.log(`Distance: ${Math.round(distance)} km`);

Build an airport search interface

// Get autocomplete suggestions
const suggestions = await getAutocompleteSuggestions('New York');
suggestions.forEach(airport => {
  console.log(`${airport.iata} - ${airport.airport}`);
});

Filter airports by multiple criteria

// Find large airports in Asia with scheduled service
const asianHubs = await findAirports({
  continent: 'AS',
  type: 'large_airport',
  has_scheduled_service: true
});

Get airport statistics

// 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}`);

Bulk operations

// 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`);

Validation utilities

// 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

// 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
});

Changelog

See CHANGELOG.md for the full version history and release notes.

Data Source

This library uses a comprehensive dataset of worldwide airports with regular updates to ensure accuracy and completeness.

License

This project is licensed under the Creative Commons Attribution 4.0 International (CC BY 4.0) - see the LICENSE file for details.

Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.