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 🙏

© 2026 – Pkg Stats / Ryan Hefner

iata-city-codes

v0.1.0

Published

Map IATA city (metro-area) codes to the airports they group, and back.

Readme

iata-city-codes

npm version bundle size license downloads

Map IATA city codes (metropolitan-area codes) to the individual airport codes they group, and back. Example: LON[LHR, LGW, STN, LTN, LCY, SEN, BQH].

import { getAirportsByCityCode } from "iata-city-codes";

getAirportsByCityCode("LON").map((a) => a.iata);
// ["BQH", "LCY", "LGW", "LHR", "LTN", "SEN", "STN"]

Unofficial data — read this first

This is community-sourced, unofficial data, not IATA's own City Code Directory (which is a paid product — see iata.org if you need guaranteed-authoritative, contractually-supported data).

Not every city code is accepted as search input by every flight-search API or GDS. This package gives you the mapping; whether a given booking engine treats LON as a searchable origin/destination is a decision made by that engine, not by this package.

See DATA_SOURCES.md for exact provenance and fetch dates.

Install

npm install iata-city-codes

Zero runtime dependencies. Ships ESM + CJS + types.

Size

The dataset covers the full worldwide IATA airport list (9,250 airports, 8,827 city codes, 286 of them multi-airport). Minified bundle is ~1.2MB per module format — most of that is airport names/countries for single-airport codes, which gzip well in transit. If you only need multi-airport groupings, getAllMultiAirportCities() narrows that down to 286 cities.

API

getAirportsByCityCode(cityCode: string): Airport[]

getAirportsByCityCode("WAS");
// [{ iata: "BWI", ... }, { iata: "DCA", ... }, { iata: "IAD", ... }]

getCityCodeForAirport(airportCode: string): string | null

Returns the city code an airport belongs to — or the airport's own code if it IS the city code (single-airport city).

getCityCodeForAirport("LHR"); // "LON"
getCityCodeForAirport("GVA"); // "GVA" (Geneva: single-airport city)
getCityCodeForAirport("ZZZ"); // null

getCityForAirport(airportCode: string): City | null

getCityForAirport("LGW");
// { code: "LON", name: "London", countryCode: "GB", airports: [...] }

getCity(cityCode: string): City | null

getCity("LON");
// { code: "LON", name: "London", countryCode: "GB", airports: [...] }

isCityCode(code: string): boolean

isCityCode("LON"); // true
isCityCode("GVA"); // true (single-airport city, code doubles as both)
isCityCode("LHR"); // false — LHR is an airport, not a city code

isAirportCode(code: string): boolean

isAirportCode("LHR"); // true
isAirportCode("LON"); // false — LON has no airport of its own
isAirportCode("GVA"); // true

getAllMultiAirportCities(): City[]

Returns all 286 cities with 2+ airports grouped under them.

Known edge cases

  • Basel–Mulhouse–Freiburg: one physical airport, three codes — EAP (binational), BSL (Swiss side), MLH (French side). All three are exposed as distinct entries under city code EAP, each with a notes field explaining the relationship (pricing/domestic-status differs by code).
  • Washington, D.C. (WAS): groups DCA, IAD, and BWI.
  • Single-airport cities (e.g. Geneva GVA): the city code and airport code coincide. isCityCode() and isAirportCode() both return true for these.

Regenerating the data

npm run build:data

Fetches the source CSVs fresh, re-derives src/data/airports.generated.ts and src/data/cities.generated.ts, and cross-checks the multi-airport city list against Wikipedia (warns on discrepancies, doesn't fail the build).

License

MIT