airport-data-js 1.0.5 → 2.0.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 CHANGED
@@ -1,174 +1,282 @@
1
- # airport-data-js
1
+ # Airport Data JS
2
2
 
3
- A comprehensive library providing easy retrieval of airport data based on IATA, ICAO, city codes, country codes, and continents. Ideal for developers building applications related to aviation, travel, and geography.
3
+ 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.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install airport-data-js
9
+ ```
4
10
 
5
- #### NPM: https://www.npmjs.com/package/airport-data-js
6
-
7
11
  ## Features
8
12
 
9
- - Retrieve airport data using IATA code.
10
- - Retrieve airport data using ICAO code.
11
- - Fetch data using city codes.
12
- - Fetch data using country codes.
13
- - Retrieve data based on continents.
14
- - Built-in error handling for invalid input formats.
15
- - Efficiently packaged with minimized and gzipped data.
16
- - **Comprehensive Data Access**: Retrieve airport data using IATA code, ICAO code, city codes, country codes, and continents.
17
- - **Unique Link Integration**: The first library to provide direct links to [FlightRadar24](https://www.flightradar24.com/), [Radarbox](https://www.radarbox.com/), and [FlightAware](https://www.flightaware.com/) for each airport, giving users immediate access to live flight tracking and airport data.
18
- - 9143 Aiports in total.
19
-
20
- ## Updates from 1.0.4 to 1.0.5
21
- - Added 500+ aiports
22
- - Fixed cities
23
- - Added Wikipedia links
13
+ - 🌍 Comprehensive airport database with worldwide coverage
14
+ - 🔍 Search by IATA codes, ICAO codes, country, continent, and more
15
+ - 📍 Geographic proximity search with customizable radius
16
+ - 🔗 External links to Wikipedia, airport websites, and flight tracking services
17
+ - 📏 Distance calculation between airports
18
+ - 🏷️ Filter by airport type (large_airport, medium_airport, small_airport, heliport, seaplane_base)
19
+ - 🕒 Timezone-based airport lookup
20
+ - 💡 Autocomplete suggestions for search interfaces
21
+ - 🎯 Advanced multi-criteria filtering
24
22
 
25
- ## Installation
23
+ ## Airport Data Structure
26
24
 
27
- You can install `airport-data-js` using npm:
25
+ Each airport object contains the following fields:
28
26
 
29
- ```bash
30
- npm install airport-data-js
27
+ ```javascript
28
+ {
29
+ iata: "SIN", // 3-letter IATA code
30
+ icao: "WSSS", // 4-letter ICAO code
31
+ time: "Asia/Singapore", // Timezone identifier
32
+ country_code: "SG", // 2-letter country code
33
+ continent: "AS", // 2-letter continent code (AS, EU, NA, SA, AF, OC, AN)
34
+ airport: "Singapore Changi Airport", // Airport name
35
+ latitude: "1.35019", // Latitude coordinate
36
+ longitude: "103.994003", // Longitude coordinate
37
+ elevation: "22", // Elevation in feet
38
+ type: "large_airport", // Airport type
39
+ scheduled_service: true, // Has scheduled commercial service
40
+ wikipedia: "https://en.wikipedia.org/wiki/Singapore_Changi_Airport",
41
+ website: "https://www.changiairport.com",
42
+ runway_length: "13200", // Longest runway in feet
43
+ flightradar24_url: "https://www.flightradar24.com/airport/SIN",
44
+ radarbox_url: "https://www.radarbox.com/airport/WSSS",
45
+ flightaware_url: "https://www.flightaware.com/live/airport/WSSS"
46
+ }
31
47
  ```
32
48
 
33
- For detailed instructions on how to use this library in different environments, please refer to the following links:
34
-
35
- - [Node.js Instructions](https://github.com/aashishvanand/airport-data-js/blob/nodejs-sample/README.md)
36
- - [React Instructions](https://github.com/aashishvanand/airport-data-js/blob/reactjs-sample/README.md)
37
-
38
- ## Usage
39
-
40
- Here's how you can use the library:
41
-
42
- ```javascript
43
- const airportData = require('airport-data-js');
44
-
45
- // Retrieve airport data using IATA code
46
- const airportByIATA = airportData.getAirportByIata("AAA");
47
- console.log(airportByIATA);
48
-
49
- // Retrieve airport data using ICAO code
50
- const airportByICAO = airportData.getAirportByIcao("NTGA");
51
- console.log(airportByICAO);
52
-
53
- // Fetch data using city codes
54
- const airportByCityCode = airportData.getAirportByCityCode("NYC");
55
- console.log(airportByCityCode);
56
-
57
- // Fetch data using country codes
58
- const airportByCountryCode = airportData.getAirportByCountryCode("US");
59
- console.log(airportByCountryCode);
60
-
61
- // Retrieve data based on continents
62
- const airportByContinent = airportData.getAirportByContinent("AS");
63
- console.log(airportByContinent);
64
-
65
-
66
- ```
67
-
68
- ## Example Data Fields
69
-
70
- For Chennai International Airport:
71
-
72
- | Field Name | Data |
73
- |----------------------|----------------------------------------------------------|
74
- | IATA | MAA |
75
- | ICAO | VOMM |
76
- | Time Zone | Asia/Kolkata |
77
- | City Code | MAA |
78
- | Country Code | IN |
79
- | Name | Chennai International Airport |
80
- | Latitude | 12.99 |
81
- | Longitude | 80.1693 |
82
- | Altitude (in feet) | 52 |
83
- | State | Tamil Nadu |
84
- | City | Chennai |
85
- | County | Kancheepuram |
86
- | State Code | Tamil Nadu |
87
- | Airport Type | large_airport |
88
- | Continent | AS |
89
- | State Abbreviation | IN-TN |
90
- | International | TRUE |
91
- | Wikipedia Link | [Wikipedia](https://en.wikipedia.org/wiki/Chennai_International_Airport)|
92
- | Official Website | [Chennai Airport](http://chennaiairport.com) |
93
- | Location ID | 12513629 |
94
- | Phone Number | 044-2340551 |
95
- | Runway Length (in meters) | 10050 |
96
- | Flightradar24 | [Flightradar24](https://www.flightradar24.com/airport/MAA)|
97
- | Radarbox | [Radarbox](https://www.radarbox.com/airport/VOMM) |
98
- | Flightaware Link | [Flightaware](https://www.flightaware.com/live/airport/VOMM)|
99
-
100
- ### Singapore Changi Airport:
101
-
102
- | Field Name | Data |
103
- |----------------------|----------------------------------------------------------|
104
- | IATA | SIN |
105
- | ICAO | WSSS |
106
- | Time Zone | Asia/Singapore |
107
- | City Code | SIN |
108
- | Country Code | SG |
109
- | Name | Singapore Changi Airport |
110
- | Latitude | 1.35019 |
111
- | Longitude | 103.994 |
112
- | Altitude (in feet) | 22 |
113
- | State | Singapore |
114
- | City | Singapore |
115
- | County | Singapore |
116
- | State Code | South East |
117
- | Airport Type | large_airport |
118
- | Continent | AS |
119
- | State Abbreviation | SG-04 |
120
- | International | TRUE |
121
- | Wikipedia Link | [Wikipedia](https://en.wikipedia.org/wiki/Singapore_Changi_Airport)|
122
- | Official Website | [Changi Airport](http://www.changiairport.com/) |
123
- | Location ID | 12517525 |
124
- | Phone Number | (65) 6542 1122 |
125
- | Runway Length (in meters) | 13200 |
126
- | Flightradar24 | [Flightradar24](https://www.flightradar24.com/airport/SIN)|
127
- | Radarbox | [Radarbox](https://www.radarbox.com/airport/WSSS) |
128
- | Flightaware | [Flightaware](https://www.flightaware.com/live/airport/WSSS)|
129
-
130
-
131
- ## Running the Project Locally
132
-
133
- 1. Clone the repository:
49
+ ## Basic Usage
134
50
 
135
- ```bash
136
- git clone https://github.com/aashishvanand/airport-data-js.git
51
+ ```javascript
52
+ const {
53
+ getAirportByIata,
54
+ getAirportByIcao,
55
+ searchByName,
56
+ findNearbyAirports
57
+ } = require('airport-data-js');
58
+
59
+ // Get airport by IATA code
60
+ const [airport] = await getAirportByIata('SIN');
61
+ console.log(airport.airport); // "Singapore Changi Airport"
62
+
63
+ // Get airport by ICAO code
64
+ const [airport] = await getAirportByIcao('WSSS');
65
+ console.log(airport.country_code); // "SG"
66
+
67
+ // Search airports by name
68
+ const airports = await searchByName('Singapore');
69
+ console.log(airports.length); // Multiple airports matching "Singapore"
70
+
71
+ // Find nearby airports (within 50km of coordinates)
72
+ const nearby = await findNearbyAirports(1.35019, 103.994003, 50);
73
+ console.log(nearby); // Airports near Singapore Changi
137
74
  ```
138
75
 
139
- 2. Change into the cloned directory:
76
+ ## API Reference
140
77
 
141
- ```bash
142
- cd airport-data-js
78
+ ### Core Search Functions
79
+
80
+ #### `getAirportByIata(iataCode)`
81
+ Finds airports by their 3-letter IATA code.
82
+
83
+ ```javascript
84
+ const airports = await getAirportByIata('LHR');
85
+ // Returns array of airports with IATA code 'LHR'
143
86
  ```
144
87
 
145
- 3. Install the necessary dependencies:
88
+ #### `getAirportByIcao(icaoCode)`
89
+ Finds airports by their 4-character ICAO code.
146
90
 
147
- ```bash
148
- npm install
91
+ ```javascript
92
+ const airports = await getAirportByIcao('EGLL');
93
+ // Returns array of airports with ICAO code 'EGLL'
149
94
  ```
150
95
 
151
- 4. To bundle the source code using Webpack:
96
+ #### `searchByName(query)`
97
+ Searches for airports by name (case-insensitive, minimum 2 characters).
152
98
 
153
- ```bash
154
- npm run build
99
+ ```javascript
100
+ const airports = await searchByName('Heathrow');
101
+ // Returns airports with 'Heathrow' in their name
155
102
  ```
156
103
 
157
- 5. To run tests:
104
+ ### Geographic Functions
158
105
 
159
- ```bash
160
- npm test
106
+ #### `findNearbyAirports(lat, lon, radiusKm)`
107
+ Finds airports within a specified radius of given coordinates.
108
+
109
+ ```javascript
110
+ const nearby = await findNearbyAirports(51.5074, -0.1278, 100);
111
+ // Returns airports within 100km of London coordinates
112
+ ```
113
+
114
+ #### `calculateDistance(code1, code2)`
115
+ Calculates the great-circle distance between two airports using IATA or ICAO codes.
116
+
117
+ ```javascript
118
+ const distance = await calculateDistance('LHR', 'JFK');
119
+ // Returns distance in kilometers (approximately 5540)
120
+ ```
121
+
122
+ ### Filtering Functions
123
+
124
+ #### `getAirportByCountryCode(countryCode)`
125
+ Finds all airports in a specific country.
126
+
127
+ ```javascript
128
+ const usAirports = await getAirportByCountryCode('US');
129
+ // Returns all airports in the United States
130
+ ```
131
+
132
+ #### `getAirportByContinent(continentCode)`
133
+ Finds all airports on a specific continent.
134
+
135
+ ```javascript
136
+ const asianAirports = await getAirportByContinent('AS');
137
+ // Returns all airports in Asia
138
+ // Continent codes: AS, EU, NA, SA, AF, OC, AN
161
139
  ```
162
140
 
163
- ## Troubleshooting
141
+ #### `getAirportsByType(type)`
142
+ Finds airports by their type.
143
+
144
+ ```javascript
145
+ const largeAirports = await getAirportsByType('large_airport');
146
+ // Available types: large_airport, medium_airport, small_airport, heliport, seaplane_base
147
+
148
+ // Convenience search for all airports
149
+ const allAirports = await getAirportsByType('airport');
150
+ // Returns large_airport, medium_airport, and small_airport
151
+ ```
152
+
153
+ #### `getAirportsByTimezone(timezone)`
154
+ Finds all airports within a specific timezone.
155
+
156
+ ```javascript
157
+ const londonAirports = await getAirportsByTimezone('Europe/London');
158
+ // Returns airports in London timezone
159
+ ```
160
+
161
+ ### Advanced Functions
162
+
163
+ #### `findAirports(filters)`
164
+ Finds airports matching multiple criteria.
165
+
166
+ ```javascript
167
+ // Find large airports in Great Britain with scheduled service
168
+ const airports = await findAirports({
169
+ country_code: 'GB',
170
+ type: 'large_airport',
171
+ has_scheduled_service: true
172
+ });
173
+
174
+ // Find airports with minimum runway length
175
+ const longRunwayAirports = await findAirports({
176
+ min_runway_ft: 10000
177
+ });
178
+ ```
179
+
180
+ #### `getAutocompleteSuggestions(query)`
181
+ Provides autocomplete suggestions for search interfaces (returns max 10 results).
182
+
183
+ ```javascript
184
+ const suggestions = await getAutocompleteSuggestions('Lon');
185
+ // Returns up to 10 airports matching 'Lon' in name or IATA code
186
+ ```
187
+
188
+ #### `getAirportLinks(code)`
189
+ Gets external links for an airport using IATA or ICAO code.
190
+
191
+ ```javascript
192
+ const links = await getAirportLinks('SIN');
193
+ // Returns:
194
+ // {
195
+ // website: "https://www.changiairport.com",
196
+ // wikipedia: "https://en.wikipedia.org/wiki/Singapore_Changi_Airport",
197
+ // flightradar24: "https://www.flightradar24.com/airport/SIN",
198
+ // radarbox: "https://www.radarbox.com/airport/WSSS",
199
+ // flightaware: "https://www.flightaware.com/live/airport/WSSS"
200
+ // }
201
+ ```
202
+
203
+ ## Error Handling
204
+
205
+ All functions return promises and may throw errors for invalid input or when no data is found.
206
+
207
+ ```javascript
208
+ try {
209
+ const airport = await getAirportByIata('XYZ');
210
+ } catch (error) {
211
+ console.error(error.message); // "No data found for IATA code: XYZ"
212
+ }
213
+ ```
214
+
215
+ ## Examples
216
+
217
+ ### Find airports near a city
218
+ ```javascript
219
+ // Find airports within 100km of Paris
220
+ const parisAirports = await findNearbyAirports(48.8566, 2.3522, 100);
221
+ console.log(`Found ${parisAirports.length} airports near Paris`);
222
+ ```
223
+
224
+ ### Get flight distance
225
+ ```javascript
226
+ // Calculate distance between Singapore and London
227
+ const distance = await calculateDistance('SIN', 'LHR');
228
+ console.log(`Distance: ${Math.round(distance)} km`);
229
+ ```
230
+
231
+ ### Build an airport search interface
232
+ ```javascript
233
+ // Get autocomplete suggestions
234
+ const suggestions = await getAutocompleteSuggestions('New York');
235
+ suggestions.forEach(airport => {
236
+ console.log(`${airport.iata} - ${airport.airport}`);
237
+ });
238
+ ```
239
+
240
+ ### Filter airports by multiple criteria
241
+ ```javascript
242
+ // Find large airports in Asia with scheduled service
243
+ const asianHubs = await findAirports({
244
+ continent: 'AS',
245
+ type: 'large_airport',
246
+ has_scheduled_service: true
247
+ });
248
+ ```
249
+
250
+ ## Changelog
251
+
252
+ ### Version 2.0.0 (Latest)
253
+
254
+ #### 🆕 New Features
255
+ - **`getAirportsByTimezone(timezone)`** - Find airports by timezone
256
+ - **`getAirportLinks(code)`** - Get external links for airports
257
+ - **`findAirports(filters)`** - Advanced multi-criteria filtering
258
+ - **`getAutocompleteSuggestions(query)`** - Autocomplete functionality
259
+ - **Enhanced `getAirportsByType(type)`** - Now supports convenience search for "airport" type
260
+ - **External links support** - Wikipedia, websites, and flight tracking URLs
261
+ - **Timezone information** - Complete timezone data for all airports
262
+ - **Runway length data** - Airport runway information included
263
+ - **Scheduled service indicator** - Whether airports have commercial scheduled service
264
+
265
+ #### 🔄 Improvements
266
+ - Better error handling and validation
267
+ - More comprehensive airport data structure
268
+ - Improved type filtering with partial matching
269
+ - Enhanced geographic calculations
270
+ - Case-insensitive search improvements
164
271
 
165
- 1. **Issue**: "Module not found: Error: Can't resolve 'babel-loader'".
166
- **Solution**: Ensure that you have installed all the necessary dependencies. If the issue persists, reinstall the library.
272
+ #### ❌ Removed from v1.x
273
+ - Legacy data format support
274
+ - Simplified airport objects (expanded to include more fields)
275
+ - Basic filtering (replaced with advanced `findAirports` function)
167
276
 
168
- 2. **Issue**: "Error: Automatic publicPath is not supported in this browser".
169
- **Solution**: Ensure that you're using the library in a supported environment (Node.js or a modern browser).
277
+ ## Data Source
170
278
 
171
- If you encounter other issues, consider raising an issue on the [GitHub repository](https://github.com/aashishvanand/airport-data-js/issues).
279
+ This library uses a comprehensive dataset of worldwide airports with regular updates to ensure accuracy and completeness.
172
280
 
173
281
  ## License
174
282