airport-data-js 3.1.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +163 -36
- package/dist/airport-data.lite.min.js +1 -0
- package/dist/airport-data.min.js +1 -1
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -0
- package/lib/lite.js +1 -0
- package/lib/lite.mjs +1 -0
- package/lib/tools.js +1 -1
- package/lib/tools.mjs +1 -0
- package/package.json +71 -32
- package/types/core.d.mts +705 -0
- package/types/core.d.ts +705 -0
- package/types/index.d.mts +9 -0
- package/types/index.d.ts +5 -513
- package/types/lite.d.mts +7 -0
- package/types/lite.d.ts +7 -0
- package/types/state.d.mts +13 -0
- package/types/state.d.ts +13 -0
- package/types/tools.d.mts +50 -0
package/types/core.d.mts
ADDED
|
@@ -0,0 +1,705 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a single airport record from the database.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* const [airport] = await getAirportByIata('SIN');
|
|
7
|
+
* console.log(airport.airport); // "Singapore Changi Airport"
|
|
8
|
+
* console.log(airport.country_code); // "SG"
|
|
9
|
+
* ```
|
|
10
|
+
*/
|
|
11
|
+
export interface Airport {
|
|
12
|
+
/** 3-letter IATA airport code (e.g., "SIN", "LHR", "JFK") */
|
|
13
|
+
iata: string;
|
|
14
|
+
/** 4-letter ICAO airport code (e.g., "WSSS", "EGLL", "KJFK") */
|
|
15
|
+
icao: string;
|
|
16
|
+
/** IANA timezone identifier (e.g., "Asia/Singapore") */
|
|
17
|
+
time: string;
|
|
18
|
+
/**
|
|
19
|
+
* UTC offset in hours (e.g., 8, 5.5, -3.5), captured as a July snapshot.
|
|
20
|
+
* It does not follow daylight saving time, so it is wrong for roughly half the year
|
|
21
|
+
* in DST regions. Use {@link getUtcOffset} or {@link getLocalTime} for the real offset at a given moment.
|
|
22
|
+
* @deprecated Use getUtcOffset(code, date) instead.
|
|
23
|
+
*/
|
|
24
|
+
utc: number;
|
|
25
|
+
/** ISO 3166-1 alpha-2 country code (e.g., "SG", "GB", "US") */
|
|
26
|
+
country_code: string;
|
|
27
|
+
/** 2-letter continent code: AF, AN, AS, EU, NA, OC, SA */
|
|
28
|
+
continent: string;
|
|
29
|
+
/** Full airport name (e.g., "Singapore Changi Airport") */
|
|
30
|
+
airport: string;
|
|
31
|
+
/** City or municipality served (e.g., "Singapore", "New York"). Empty string when unknown. */
|
|
32
|
+
city: string;
|
|
33
|
+
/**
|
|
34
|
+
* IATA city/metropolitan area code (e.g., "NYC" for JFK/LGA/EWR, "LON" for LHR/LGW).
|
|
35
|
+
* Equals the airport's own IATA code for single-airport cities. Empty string when unknown.
|
|
36
|
+
*/
|
|
37
|
+
city_code: string;
|
|
38
|
+
/** Latitude in decimal degrees */
|
|
39
|
+
latitude: number;
|
|
40
|
+
/** Longitude in decimal degrees */
|
|
41
|
+
longitude: number;
|
|
42
|
+
/** Elevation above sea level in feet, or null when unknown */
|
|
43
|
+
elevation_ft: number | null;
|
|
44
|
+
/** Airport classification: "large_airport" | "medium_airport" | "small_airport" | "heliport" | "seaplane_base" | "closed" */
|
|
45
|
+
type: string;
|
|
46
|
+
/** Whether the airport has scheduled commercial service */
|
|
47
|
+
scheduled_service: boolean | string;
|
|
48
|
+
/** Wikipedia article URL */
|
|
49
|
+
wikipedia?: string;
|
|
50
|
+
/** Airport official website URL */
|
|
51
|
+
website?: string;
|
|
52
|
+
/** Longest runway length in feet, or null when unknown */
|
|
53
|
+
runway_length?: number | null;
|
|
54
|
+
/** FlightRadar24 tracking URL */
|
|
55
|
+
flightradar24_url?: string;
|
|
56
|
+
/** RadarBox tracking URL */
|
|
57
|
+
radarbox_url?: string;
|
|
58
|
+
/** FlightAware tracking URL */
|
|
59
|
+
flightaware_url?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* An airport record with distance from a reference point, returned by proximity search functions.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const nearest = await findNearestAirport(1.35, 103.99);
|
|
67
|
+
* console.log(nearest.distance); // 0.52 (km)
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export interface AirportWithDistance extends Airport {
|
|
71
|
+
/** Distance from the search point in kilometers */
|
|
72
|
+
distance: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Filter criteria for searching airports. All fields are optional and combined with AND logic.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* // Find large airports in the US with scheduled service
|
|
80
|
+
* const airports = await findAirports({
|
|
81
|
+
* country_code: 'US',
|
|
82
|
+
* type: 'large_airport',
|
|
83
|
+
* has_scheduled_service: true
|
|
84
|
+
* });
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export interface AirportFilters {
|
|
88
|
+
iata?: string;
|
|
89
|
+
icao?: string;
|
|
90
|
+
time?: string;
|
|
91
|
+
utc?: number;
|
|
92
|
+
country_code?: string;
|
|
93
|
+
continent?: string;
|
|
94
|
+
airport?: string;
|
|
95
|
+
city?: string;
|
|
96
|
+
city_code?: string;
|
|
97
|
+
latitude?: number;
|
|
98
|
+
longitude?: number;
|
|
99
|
+
elevation_ft?: number | null;
|
|
100
|
+
type?: string;
|
|
101
|
+
scheduled_service?: boolean | string;
|
|
102
|
+
wikipedia?: string;
|
|
103
|
+
website?: string;
|
|
104
|
+
runway_length?: number | null;
|
|
105
|
+
flightradar24_url?: string;
|
|
106
|
+
radarbox_url?: string;
|
|
107
|
+
flightaware_url?: string;
|
|
108
|
+
/** Filter by scheduled service availability (true = has scheduled service) */
|
|
109
|
+
has_scheduled_service?: boolean;
|
|
110
|
+
/** Minimum runway length in feet */
|
|
111
|
+
min_runway_ft?: number;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* External links associated with an airport.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const links = await getAirportLinks('LHR');
|
|
119
|
+
* console.log(links.wikipedia); // "https://en.wikipedia.org/wiki/Heathrow_Airport"
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export interface AirportLinks {
|
|
123
|
+
website?: string;
|
|
124
|
+
wikipedia?: string;
|
|
125
|
+
flightradar24?: string;
|
|
126
|
+
radarbox?: string;
|
|
127
|
+
flightaware?: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Aggregated statistics for airports in a country.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* const stats = await getAirportStatsByCountry('US');
|
|
135
|
+
* console.log(stats.total); // 19000+
|
|
136
|
+
* console.log(stats.byType.large_airport); // 180+
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
export interface AirportCountryStats {
|
|
140
|
+
/** Total number of airports */
|
|
141
|
+
total: number;
|
|
142
|
+
/** Count of airports grouped by type */
|
|
143
|
+
byType: Record<string, number>;
|
|
144
|
+
/** Number of airports with scheduled commercial service */
|
|
145
|
+
withScheduledService: number;
|
|
146
|
+
/** Average runway length in feet across airports that have runway data */
|
|
147
|
+
averageRunwayLength: number;
|
|
148
|
+
/** Average elevation in feet */
|
|
149
|
+
averageElevation: number;
|
|
150
|
+
/** List of unique IANA timezones */
|
|
151
|
+
timezones: string[];
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Aggregated statistics for airports on a continent.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const stats = await getAirportStatsByContinent('EU');
|
|
159
|
+
* console.log(stats.byCountry['GB']); // number of UK airports
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
export interface AirportContinentStats extends AirportCountryStats {
|
|
163
|
+
/** Count of airports grouped by country code */
|
|
164
|
+
byCountry: Record<string, number>;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Result of a distance matrix calculation between multiple airports.
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```typescript
|
|
171
|
+
* const matrix = await calculateDistanceMatrix(['SIN', 'LHR', 'JFK']);
|
|
172
|
+
* console.log(matrix.distances['SIN']['LHR']); // 10846
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
export interface DistanceMatrix {
|
|
176
|
+
/** Summary info for each airport in the matrix */
|
|
177
|
+
airports: Array<{
|
|
178
|
+
code: string;
|
|
179
|
+
name: string;
|
|
180
|
+
iata: string;
|
|
181
|
+
icao: string;
|
|
182
|
+
}>;
|
|
183
|
+
/** Symmetric distance matrix: distances[codeA][codeB] = km (rounded) */
|
|
184
|
+
distances: Record<string, Record<string, number>>;
|
|
185
|
+
}
|
|
186
|
+
/** Sort criteria for ranking airports */
|
|
187
|
+
export type SortBy = 'runway' | 'elevation';
|
|
188
|
+
/** Which field a {@link search} result matched on. */
|
|
189
|
+
export type SearchMatchType = 'iata' | 'icao' | 'city_code' | 'city' | 'name' | 'fuzzy';
|
|
190
|
+
/** Options for {@link search}. */
|
|
191
|
+
export interface SearchOptions {
|
|
192
|
+
/** Maximum number of results (1-100, default: 10). */
|
|
193
|
+
limit?: number;
|
|
194
|
+
/** Only return airports with scheduled commercial service. */
|
|
195
|
+
scheduledOnly?: boolean;
|
|
196
|
+
/** Restrict to these airport types (e.g., ['large_airport', 'medium_airport']). */
|
|
197
|
+
types?: string[];
|
|
198
|
+
/** Restrict to a 2-letter country code. */
|
|
199
|
+
country_code?: string;
|
|
200
|
+
/** Allow typo-tolerant matching (default: true). */
|
|
201
|
+
fuzzy?: boolean;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* An airport returned by {@link search}, with ranking details.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const [best] = await search('new york');
|
|
209
|
+
* console.log(best.iata, best.matchType); // "JFK" "city"
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export interface AirportSearchResult extends Airport {
|
|
213
|
+
/** Relevance score; higher is better. Only meaningful for ordering. */
|
|
214
|
+
score: number;
|
|
215
|
+
/** The field that produced the match. */
|
|
216
|
+
matchType: SearchMatchType;
|
|
217
|
+
}
|
|
218
|
+
/** A date input accepted by the time functions: a Date, epoch milliseconds, or an ISO string. */
|
|
219
|
+
export type DateInput = Date | number | string;
|
|
220
|
+
/**
|
|
221
|
+
* The local time at an airport for a given instant.
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* const t = await getLocalTime('JFK', '2026-11-10T12:00:00Z');
|
|
226
|
+
* console.log(t?.iso); // "2026-11-10T07:00:00-05:00"
|
|
227
|
+
* console.log(t?.utcOffset); // -5
|
|
228
|
+
* console.log(t?.isDst); // false
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
export interface AirportLocalTime {
|
|
232
|
+
/** IANA time zone of the airport (e.g., "America/New_York") */
|
|
233
|
+
timeZone: string;
|
|
234
|
+
/** Local date-time with offset in ISO 8601 form (e.g., "2026-11-10T07:00:00-05:00") */
|
|
235
|
+
iso: string;
|
|
236
|
+
/** Local calendar date, "YYYY-MM-DD" */
|
|
237
|
+
date: string;
|
|
238
|
+
/** Local wall-clock time, "HH:mm:ss" (24-hour) */
|
|
239
|
+
time: string;
|
|
240
|
+
/** UTC offset in hours at that instant (e.g., -5, 5.5) */
|
|
241
|
+
utcOffset: number;
|
|
242
|
+
/** UTC offset as a string (e.g., "-05:00", "+05:30") */
|
|
243
|
+
utcOffsetString: string;
|
|
244
|
+
/** Whether daylight saving time is in effect at that instant */
|
|
245
|
+
isDst: boolean;
|
|
246
|
+
}
|
|
247
|
+
/** Options for {@link formatAirportTime}: any Intl.DateTimeFormat option plus `date` and `locale`. */
|
|
248
|
+
export interface FormatAirportTimeOptions extends Intl.DateTimeFormatOptions {
|
|
249
|
+
/** The instant to format (default: now). */
|
|
250
|
+
date?: DateInput;
|
|
251
|
+
/** BCP 47 locale (default: "en-US"). */
|
|
252
|
+
locale?: string | string[];
|
|
253
|
+
dateStyle?: 'full' | 'long' | 'medium' | 'short';
|
|
254
|
+
timeStyle?: 'full' | 'long' | 'medium' | 'short';
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Finds airports by their 3-letter IATA code.
|
|
258
|
+
*
|
|
259
|
+
* @param iataCode - The IATA code of the airport (e.g., 'LHR').
|
|
260
|
+
* @returns Array of matching airport objects.
|
|
261
|
+
* @throws If the IATA code format is invalid or no data is found.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* const [airport] = await getAirportByIata('LHR');
|
|
266
|
+
* console.log(airport.airport); // "London Heathrow Airport"
|
|
267
|
+
* console.log(airport.country_code); // "GB"
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
export declare function getAirportByIata(iataCode?: string): Promise<Airport[]>;
|
|
271
|
+
/**
|
|
272
|
+
* Finds airports by their 4-character ICAO code.
|
|
273
|
+
*
|
|
274
|
+
* @param icaoCode - The ICAO code of the airport (e.g., 'EGLL').
|
|
275
|
+
* @returns Array of matching airport objects.
|
|
276
|
+
* @throws If the ICAO code format is invalid or no data is found.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* const [airport] = await getAirportByIcao('EGLL');
|
|
281
|
+
* console.log(airport.airport); // "London Heathrow Airport"
|
|
282
|
+
* ```
|
|
283
|
+
*/
|
|
284
|
+
export declare function getAirportByIcao(icaoCode?: string): Promise<Airport[]>;
|
|
285
|
+
/**
|
|
286
|
+
* Finds airports by their 2-letter ISO country code.
|
|
287
|
+
* Uses a pre-built index for O(1) lookup.
|
|
288
|
+
*
|
|
289
|
+
* @param countryCode - The ISO 3166-1 alpha-2 country code (e.g., 'US').
|
|
290
|
+
* @returns Array of matching airport objects.
|
|
291
|
+
* @throws If the country code format is invalid or no data is found.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* ```typescript
|
|
295
|
+
* const airports = await getAirportByCountryCode('US');
|
|
296
|
+
* console.log(airports.length); // 19000+
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
export declare function getAirportByCountryCode(countryCode?: string): Promise<Airport[]>;
|
|
300
|
+
/**
|
|
301
|
+
* Finds airports by their 2-letter continent code.
|
|
302
|
+
* Uses a pre-built index for O(1) lookup.
|
|
303
|
+
*
|
|
304
|
+
* Valid continent codes: AF (Africa), AN (Antarctica), AS (Asia),
|
|
305
|
+
* EU (Europe), NA (North America), OC (Oceania), SA (South America).
|
|
306
|
+
*
|
|
307
|
+
* @param continentCode - The continent code (e.g., 'AS' for Asia).
|
|
308
|
+
* @returns Array of matching airport objects.
|
|
309
|
+
* @throws If the continent code format is invalid or no data is found.
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```typescript
|
|
313
|
+
* const airports = await getAirportByContinent('EU');
|
|
314
|
+
* console.log(airports.every(a => a.continent === 'EU')); // true
|
|
315
|
+
* ```
|
|
316
|
+
*/
|
|
317
|
+
export declare function getAirportByContinent(continentCode?: string): Promise<Airport[]>;
|
|
318
|
+
/**
|
|
319
|
+
* Searches for airports by name. Case- and accent-insensitive partial matching
|
|
320
|
+
* ("Zurich" matches "Zürich"). For city-aware, ranked results use {@link search}.
|
|
321
|
+
*
|
|
322
|
+
* @param query - The name or partial name to search for (2-100 characters).
|
|
323
|
+
* @returns Array of matching airport objects.
|
|
324
|
+
* @throws If the query is too short or too long.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* ```typescript
|
|
328
|
+
* const airports = await searchByName('Heathrow');
|
|
329
|
+
* console.log(airports[0].iata); // "LHR"
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
export declare function searchByName(query?: string): Promise<Airport[]>;
|
|
333
|
+
/**
|
|
334
|
+
* Finds airports within a specified radius of a geographic point.
|
|
335
|
+
* Uses a bounding-box pre-filter to skip expensive Haversine calculations for distant airports.
|
|
336
|
+
*
|
|
337
|
+
* @param lat - Latitude of the center point (-90 to 90).
|
|
338
|
+
* @param lon - Longitude of the center point (-180 to 180).
|
|
339
|
+
* @param radiusKm - The search radius in kilometers (default: 100).
|
|
340
|
+
* @returns Array of airports within the radius.
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```typescript
|
|
344
|
+
* // Find airports within 50km of central London
|
|
345
|
+
* const airports = await findNearbyAirports(51.5074, -0.1278, 50);
|
|
346
|
+
* console.log(airports.some(a => a.iata === 'LHR')); // true
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
export declare function findNearbyAirports(lat: number, lon: number, radiusKm?: number): Promise<Airport[]>;
|
|
350
|
+
/**
|
|
351
|
+
* Finds airports by their type classification.
|
|
352
|
+
* Uses a pre-built index for O(1) lookup on exact matches.
|
|
353
|
+
*
|
|
354
|
+
* Valid types: "large_airport", "medium_airport", "small_airport", "heliport",
|
|
355
|
+
* "seaplane_base", "closed". Pass "airport" to match all airport types.
|
|
356
|
+
*
|
|
357
|
+
* @param type - The type of airport to filter by (case-insensitive).
|
|
358
|
+
* @returns Array of matching airport objects.
|
|
359
|
+
* @throws If the type is not a non-empty string.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* ```typescript
|
|
363
|
+
* const largeAirports = await getAirportsByType('large_airport');
|
|
364
|
+
* console.log(largeAirports.length); // 300+
|
|
365
|
+
* ```
|
|
366
|
+
*/
|
|
367
|
+
export declare function getAirportsByType(type?: string): Promise<Airport[]>;
|
|
368
|
+
/**
|
|
369
|
+
* Calculates the great-circle distance between two airports using the Haversine formula.
|
|
370
|
+
*
|
|
371
|
+
* @param code1 - The IATA or ICAO code of the first airport.
|
|
372
|
+
* @param code2 - The IATA or ICAO code of the second airport.
|
|
373
|
+
* @returns The distance in kilometers, or null if an airport is not found.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```typescript
|
|
377
|
+
* const km = await calculateDistance('LHR', 'JFK');
|
|
378
|
+
* console.log(Math.round(km!)); // 5541
|
|
379
|
+
* ```
|
|
380
|
+
*/
|
|
381
|
+
export declare function calculateDistance(code1: string, code2: string): Promise<number | null>;
|
|
382
|
+
/**
|
|
383
|
+
* Provides autocomplete suggestions based on a partial query.
|
|
384
|
+
* Matches IATA/ICAO codes, city names, city codes, and airport names, ranked like {@link search}
|
|
385
|
+
* (major airports with scheduled service first). Returns up to 10 results.
|
|
386
|
+
*
|
|
387
|
+
* @param query - The partial query string (2-100 characters).
|
|
388
|
+
* @returns Array of up to 10 matching airports.
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```typescript
|
|
392
|
+
* const suggestions = await getAutocompleteSuggestions('Lon');
|
|
393
|
+
* // Returns airports matching "Lon" (London Heathrow, London Gatwick, etc.)
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
export declare function getAutocompleteSuggestions(query?: string): Promise<Airport[]>;
|
|
397
|
+
/**
|
|
398
|
+
* Unified, ranked airport search across codes, cities, and names.
|
|
399
|
+
*
|
|
400
|
+
* Ranking: exact IATA > exact ICAO > IATA city/metro code ("NYC", "LON") > exact city >
|
|
401
|
+
* city prefix > name prefix > name word prefix > substring > typo-tolerant match.
|
|
402
|
+
* Within each tier, large airports with scheduled service rank first.
|
|
403
|
+
* Matching is case- and accent-insensitive ("zurich" finds "Zürich").
|
|
404
|
+
*
|
|
405
|
+
* @param query - Search text (2-100 characters): a code, a city, or part of a name.
|
|
406
|
+
* @param options - Optional limit and filters.
|
|
407
|
+
* @returns Ranked results, each with a `score` and `matchType`.
|
|
408
|
+
* @throws If the query is too short/long or the limit is out of range.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```typescript
|
|
412
|
+
* const results = await search('New York');
|
|
413
|
+
* console.log(results.map(a => a.iata)); // ["JFK", "LGA", ...]
|
|
414
|
+
*
|
|
415
|
+
* await search('LON'); // LHR, LGW, STN, LTN, LCY...
|
|
416
|
+
* await search('heathrow'); // LHR
|
|
417
|
+
* await search('frankfrut'); // typo-tolerant: FRA
|
|
418
|
+
* await search('paris', { scheduledOnly: true, limit: 3 });
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
export declare function search(query?: string, options?: SearchOptions): Promise<AirportSearchResult[]>;
|
|
422
|
+
/**
|
|
423
|
+
* Finds airports serving a city. Case- and accent-insensitive exact match on the city name,
|
|
424
|
+
* ordered with major scheduled-service airports first. Common former and alternative names
|
|
425
|
+
* are recognized ("Bombay", "Bangalore", "Peking", "Athens", "Roma").
|
|
426
|
+
*
|
|
427
|
+
* Note that some airports list the municipality they sit in rather than the metro area they
|
|
428
|
+
* serve (e.g., EWR is "Newark"). Use {@link getAirportsByCityCode} for metro-area lookups.
|
|
429
|
+
*
|
|
430
|
+
* @param city - City name (e.g., "London", "São Paulo", "sao paulo").
|
|
431
|
+
* @returns Array of matching airports (empty if none).
|
|
432
|
+
* @throws If the city is not a non-empty string.
|
|
433
|
+
*
|
|
434
|
+
* @example
|
|
435
|
+
* ```typescript
|
|
436
|
+
* const airports = await getAirportsByCity('London');
|
|
437
|
+
* console.log(airports[0].iata); // "LHR"
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
export declare function getAirportsByCity(city?: string): Promise<Airport[]>;
|
|
441
|
+
/**
|
|
442
|
+
* Finds all airports sharing an IATA city/metropolitan area code
|
|
443
|
+
* (e.g., "NYC" → JFK, LGA, EWR; "LON" → LHR, LGW, STN, LTN, LCY, SEN).
|
|
444
|
+
* Ordered with major scheduled-service airports first.
|
|
445
|
+
*
|
|
446
|
+
* @param cityCode - 3-letter uppercase IATA city code.
|
|
447
|
+
* @returns Array of matching airports (empty if none).
|
|
448
|
+
* @throws If the code format is invalid.
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* ```typescript
|
|
452
|
+
* const nyc = await getAirportsByCityCode('NYC');
|
|
453
|
+
* console.log(nyc.map(a => a.iata)); // ["JFK", "EWR", "LGA", ...]
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
export declare function getAirportsByCityCode(cityCode?: string): Promise<Airport[]>;
|
|
457
|
+
/**
|
|
458
|
+
* Gets an airport's real UTC offset at a given moment, accounting for daylight saving time.
|
|
459
|
+
* Prefer this over the static `utc` field, which is a July snapshot.
|
|
460
|
+
*
|
|
461
|
+
* @param code - IATA or ICAO code.
|
|
462
|
+
* @param date - The instant to evaluate (default: now).
|
|
463
|
+
* @returns Offset in hours (e.g., -5, 5.5), or null if the airport is not found.
|
|
464
|
+
* @throws If the date is invalid.
|
|
465
|
+
*
|
|
466
|
+
* @example
|
|
467
|
+
* ```typescript
|
|
468
|
+
* await getUtcOffset('JFK', '2026-07-01T12:00:00Z'); // -4 (EDT)
|
|
469
|
+
* await getUtcOffset('JFK', '2026-12-01T12:00:00Z'); // -5 (EST)
|
|
470
|
+
* await getUtcOffset('DEL'); // 5.5
|
|
471
|
+
* ```
|
|
472
|
+
*/
|
|
473
|
+
export declare function getUtcOffset(code: string, date?: DateInput): Promise<number | null>;
|
|
474
|
+
/**
|
|
475
|
+
* Gets the local date and time at an airport, accounting for daylight saving time.
|
|
476
|
+
*
|
|
477
|
+
* @param code - IATA or ICAO code.
|
|
478
|
+
* @param date - The instant to convert (default: now).
|
|
479
|
+
* @returns Local time details, or null if the airport is not found.
|
|
480
|
+
* @throws If the date is invalid.
|
|
481
|
+
*
|
|
482
|
+
* @example
|
|
483
|
+
* ```typescript
|
|
484
|
+
* const t = await getLocalTime('LHR', '2026-07-01T12:00:00Z');
|
|
485
|
+
* console.log(t?.iso); // "2026-07-01T13:00:00+01:00"
|
|
486
|
+
* console.log(t?.isDst); // true
|
|
487
|
+
* ```
|
|
488
|
+
*/
|
|
489
|
+
export declare function getLocalTime(code: string, date?: DateInput): Promise<AirportLocalTime | null>;
|
|
490
|
+
/**
|
|
491
|
+
* Formats an instant in an airport's local time using `Intl.DateTimeFormat`.
|
|
492
|
+
*
|
|
493
|
+
* @param code - IATA or ICAO code.
|
|
494
|
+
* @param options - `date` (default: now), `locale` (default: "en-US"), and any
|
|
495
|
+
* Intl.DateTimeFormat options. Defaults to `{ dateStyle: 'medium', timeStyle: 'short' }`
|
|
496
|
+
* when no date/time fields are given.
|
|
497
|
+
* @returns The formatted string, or null if the airport is not found.
|
|
498
|
+
* @throws If the date is invalid.
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
501
|
+
* ```typescript
|
|
502
|
+
* await formatAirportTime('NRT', { date: '2026-11-10T00:00:00Z' });
|
|
503
|
+
* // "Nov 10, 2026, 9:00 AM"
|
|
504
|
+
* await formatAirportTime('CDG', { locale: 'fr-FR', timeStyle: 'short' });
|
|
505
|
+
* // "14:05"
|
|
506
|
+
* ```
|
|
507
|
+
*/
|
|
508
|
+
export declare function formatAirportTime(code: string, options?: FormatAirportTimeOptions): Promise<string | null>;
|
|
509
|
+
/**
|
|
510
|
+
* Finds airports that match multiple filter criteria (combined with AND logic).
|
|
511
|
+
* Uses indexed lookups where possible for performance.
|
|
512
|
+
*
|
|
513
|
+
* @param filters - An object of filter criteria to apply.
|
|
514
|
+
* @returns Array of matching airports.
|
|
515
|
+
* @throws If an unrecognized filter key is provided.
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```typescript
|
|
519
|
+
* const airports = await findAirports({
|
|
520
|
+
* country_code: 'GB',
|
|
521
|
+
* type: 'large_airport',
|
|
522
|
+
* has_scheduled_service: true
|
|
523
|
+
* });
|
|
524
|
+
* ```
|
|
525
|
+
*/
|
|
526
|
+
export declare function findAirports(filters?: AirportFilters): Promise<Airport[]>;
|
|
527
|
+
/**
|
|
528
|
+
* Finds all airports within a specific IANA timezone.
|
|
529
|
+
* Uses a pre-built index for O(1) lookup.
|
|
530
|
+
*
|
|
531
|
+
* @param timezone - The IANA timezone identifier (e.g., 'Europe/London', 'Asia/Singapore').
|
|
532
|
+
* @returns Array of matching airports.
|
|
533
|
+
* @throws If the timezone string is empty.
|
|
534
|
+
*
|
|
535
|
+
* @example
|
|
536
|
+
* ```typescript
|
|
537
|
+
* const airports = await getAirportsByTimezone('Europe/London');
|
|
538
|
+
* console.log(airports.every(a => a.time === 'Europe/London')); // true
|
|
539
|
+
* ```
|
|
540
|
+
*/
|
|
541
|
+
export declare function getAirportsByTimezone(timezone?: string): Promise<Airport[]>;
|
|
542
|
+
/**
|
|
543
|
+
* Gets a map of external links (Wikipedia, FlightRadar24, etc.) for an airport.
|
|
544
|
+
*
|
|
545
|
+
* @param code - The IATA or ICAO code of the airport.
|
|
546
|
+
* @returns An object of links, or null if the airport is not found.
|
|
547
|
+
*
|
|
548
|
+
* @example
|
|
549
|
+
* ```typescript
|
|
550
|
+
* const links = await getAirportLinks('LHR');
|
|
551
|
+
* console.log(links?.wikipedia); // "https://en.wikipedia.org/wiki/Heathrow_Airport"
|
|
552
|
+
* ```
|
|
553
|
+
*/
|
|
554
|
+
export declare function getAirportLinks(code: string): Promise<AirportLinks | null>;
|
|
555
|
+
/**
|
|
556
|
+
* Gets comprehensive statistics about airports in a specific country.
|
|
557
|
+
* Includes counts by type, average runway length, average elevation, and timezones.
|
|
558
|
+
*
|
|
559
|
+
* @param countryCode - The 2-letter ISO country code (e.g., 'US').
|
|
560
|
+
* @returns Aggregated statistics object.
|
|
561
|
+
* @throws If the country code format is invalid or no airports are found.
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```typescript
|
|
565
|
+
* const stats = await getAirportStatsByCountry('US');
|
|
566
|
+
* console.log(stats.total); // 19000+
|
|
567
|
+
* console.log(stats.byType.large_airport); // 180+
|
|
568
|
+
* console.log(stats.withScheduledService); // number
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
571
|
+
export declare function getAirportStatsByCountry(countryCode?: string): Promise<AirportCountryStats>;
|
|
572
|
+
/**
|
|
573
|
+
* Gets comprehensive statistics about airports on a specific continent.
|
|
574
|
+
* Includes counts by type, by country, average runway length, average elevation, and timezones.
|
|
575
|
+
*
|
|
576
|
+
* @param continentCode - The 2-letter continent code (e.g., 'AS' for Asia).
|
|
577
|
+
* @returns Aggregated statistics object with country breakdown.
|
|
578
|
+
* @throws If the continent code format is invalid or no airports are found.
|
|
579
|
+
*
|
|
580
|
+
* @example
|
|
581
|
+
* ```typescript
|
|
582
|
+
* const stats = await getAirportStatsByContinent('EU');
|
|
583
|
+
* console.log(stats.byCountry['GB']); // number of UK airports
|
|
584
|
+
* console.log(stats.byCountry['FR']); // number of French airports
|
|
585
|
+
* ```
|
|
586
|
+
*/
|
|
587
|
+
export declare function getAirportStatsByContinent(continentCode?: string): Promise<AirportContinentStats>;
|
|
588
|
+
/**
|
|
589
|
+
* Gets the largest airports on a continent, ranked by runway length or elevation.
|
|
590
|
+
*
|
|
591
|
+
* @param continentCode - The 2-letter continent code (e.g., 'AS').
|
|
592
|
+
* @param limit - Maximum number of airports to return (1-1000, default: 10).
|
|
593
|
+
* @param sortBy - Sort criteria: 'runway' or 'elevation' (default: 'runway').
|
|
594
|
+
* @returns Array of airports sorted by the specified criteria (descending).
|
|
595
|
+
* @throws If the continent code format is invalid.
|
|
596
|
+
*
|
|
597
|
+
* @example
|
|
598
|
+
* ```typescript
|
|
599
|
+
* const top5 = await getLargestAirportsByContinent('AS', 5, 'runway');
|
|
600
|
+
* console.log(top5[0].runway_length); // longest runway in Asia
|
|
601
|
+
* ```
|
|
602
|
+
*/
|
|
603
|
+
export declare function getLargestAirportsByContinent(continentCode?: string, limit?: number, sortBy?: SortBy): Promise<Airport[]>;
|
|
604
|
+
/**
|
|
605
|
+
* Fetches multiple airports by their IATA or ICAO codes in a single call.
|
|
606
|
+
* Returns null for codes that don't match any airport.
|
|
607
|
+
*
|
|
608
|
+
* @param codes - Array of IATA or ICAO codes (max 500).
|
|
609
|
+
* @returns Array of airport objects (null for unresolved codes), in the same order as input.
|
|
610
|
+
* @throws If codes is not an array or exceeds 500 entries.
|
|
611
|
+
*
|
|
612
|
+
* @example
|
|
613
|
+
* ```typescript
|
|
614
|
+
* const airports = await getMultipleAirports(['SIN', 'LHR', 'JFK']);
|
|
615
|
+
* console.log(airports[0]?.iata); // "SIN"
|
|
616
|
+
* console.log(airports[1]?.iata); // "LHR"
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
export declare function getMultipleAirports(codes?: string[]): Promise<(Airport | null)[]>;
|
|
620
|
+
/**
|
|
621
|
+
* Calculates the great-circle distance between all pairs of airports.
|
|
622
|
+
* Exploits distance symmetry (d(A,B) === d(B,A)) to halve calculations.
|
|
623
|
+
*
|
|
624
|
+
* @param codes - Array of IATA or ICAO codes (2-100).
|
|
625
|
+
* @returns Distance matrix with airport summaries and symmetric distance table.
|
|
626
|
+
* @throws If fewer than 2 codes or any code is invalid.
|
|
627
|
+
*
|
|
628
|
+
* @example
|
|
629
|
+
* ```typescript
|
|
630
|
+
* const matrix = await calculateDistanceMatrix(['SIN', 'LHR', 'JFK']);
|
|
631
|
+
* console.log(matrix.distances['SIN']['LHR']); // distance in km
|
|
632
|
+
* console.log(matrix.distances['LHR']['SIN']); // same value (symmetric)
|
|
633
|
+
* ```
|
|
634
|
+
*/
|
|
635
|
+
export declare function calculateDistanceMatrix(codes?: string[]): Promise<DistanceMatrix>;
|
|
636
|
+
/**
|
|
637
|
+
* Finds the single nearest airport to given coordinates, optionally filtered.
|
|
638
|
+
*
|
|
639
|
+
* @param lat - Latitude of the search point (-90 to 90).
|
|
640
|
+
* @param lon - Longitude of the search point (-180 to 180).
|
|
641
|
+
* @param filters - Optional filter criteria (e.g., `{ type: 'large_airport' }`).
|
|
642
|
+
* @returns The nearest airport with a `distance` field (km), or null if none found.
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
* ```typescript
|
|
646
|
+
* // Nearest large airport to central NYC
|
|
647
|
+
* const nearest = await findNearestAirport(40.7128, -74.006, { type: 'large_airport' });
|
|
648
|
+
* console.log(nearest?.iata); // e.g., "EWR"
|
|
649
|
+
* console.log(nearest?.distance); // distance in km
|
|
650
|
+
* ```
|
|
651
|
+
*/
|
|
652
|
+
export declare function findNearestAirport(lat: number, lon: number, filters?: AirportFilters): Promise<AirportWithDistance | null>;
|
|
653
|
+
/**
|
|
654
|
+
* Validates whether an IATA code exists in the airport database.
|
|
655
|
+
*
|
|
656
|
+
* @param code - The 3-letter IATA code to validate.
|
|
657
|
+
* @returns True if the code exists, false otherwise.
|
|
658
|
+
*
|
|
659
|
+
* @example
|
|
660
|
+
* ```typescript
|
|
661
|
+
* await validateIataCode('SIN'); // true
|
|
662
|
+
* await validateIataCode('ZZZ'); // false
|
|
663
|
+
* ```
|
|
664
|
+
*/
|
|
665
|
+
export declare function validateIataCode(code?: string): Promise<boolean>;
|
|
666
|
+
/**
|
|
667
|
+
* Validates whether an ICAO code exists in the airport database.
|
|
668
|
+
*
|
|
669
|
+
* @param code - The 4-character ICAO code to validate.
|
|
670
|
+
* @returns True if the code exists, false otherwise.
|
|
671
|
+
*
|
|
672
|
+
* @example
|
|
673
|
+
* ```typescript
|
|
674
|
+
* await validateIcaoCode('WSSS'); // true
|
|
675
|
+
* await validateIcaoCode('XXXX'); // false
|
|
676
|
+
* ```
|
|
677
|
+
*/
|
|
678
|
+
export declare function validateIcaoCode(code?: string): Promise<boolean>;
|
|
679
|
+
/**
|
|
680
|
+
* Gets the count of airports matching the given filters without returning full airport data.
|
|
681
|
+
*
|
|
682
|
+
* @param filters - Optional filter criteria. Omit for total count.
|
|
683
|
+
* @returns Count of matching airports.
|
|
684
|
+
*
|
|
685
|
+
* @example
|
|
686
|
+
* ```typescript
|
|
687
|
+
* const total = await getAirportCount(); // all airports
|
|
688
|
+
* const usLarge = await getAirportCount({ country_code: 'US', type: 'large_airport' });
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
export declare function getAirportCount(filters?: AirportFilters): Promise<number>;
|
|
692
|
+
/**
|
|
693
|
+
* Checks if an airport has scheduled commercial service.
|
|
694
|
+
*
|
|
695
|
+
* @param code - The IATA or ICAO code of the airport.
|
|
696
|
+
* @returns True if the airport has scheduled service.
|
|
697
|
+
* @throws If the airport is not found.
|
|
698
|
+
*
|
|
699
|
+
* @example
|
|
700
|
+
* ```typescript
|
|
701
|
+
* await isAirportOperational('SIN'); // true (Changi has scheduled flights)
|
|
702
|
+
* await isAirportOperational('WSSS'); // true (same airport, ICAO code)
|
|
703
|
+
* ```
|
|
704
|
+
*/
|
|
705
|
+
export declare function isAirportOperational(code: string): Promise<boolean>;
|