-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenapi.yaml
More file actions
468 lines (433 loc) · 13.8 KB
/
Copy pathopenapi.yaml
File metadata and controls
468 lines (433 loc) · 13.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
openapi: 3.0.3
info:
title: Flight Enrichment API
description: |
REST API for accessing flight enrichment data extracted from ACARS messages.
This API provides access to operational flight data including routes, runways,
SIDs, squawk codes, and passenger counts. Data is keyed by aircraft ICAO hex
address, callsign, and flight date.
Data is written to PostgreSQL by `acars_parser live` and
`acars_parser reparse -enrich`; this API only reads it. "Today" means the
current UTC date. Path values for `icao_hex` and `callsign` are converted to
upper case and are not otherwise validated.
## Authentication
Authentication is optional and disabled by default. When the server is
started with `-auth`, every endpoint (including `/health`) requires an API
key supplied via the first present of:
- `X-API-Key` header
- `Authorization: Bearer <key>` header
- `api_key` query parameter
A missing key returns `401`; a key that is not configured returns `403`.
## Errors
Errors raised by the handlers are returned as `{"error": "<message>"}`.
Requests that match no route receive a plain-text `404` or `405` from the
router instead.
## Rate Limiting
No rate limiting is enforced.
version: 1.0.0
contact:
name: ACARS Parser
servers:
- url: http://localhost:8081/api/v1
description: Local development server
tags:
- name: Health
description: Health check endpoints
- name: Enrichment
description: Flight enrichment data endpoints
paths:
/health:
get:
tags:
- Health
summary: Health check
description: |
Returns the health status of the API server. The database is not
queried. When authentication is enabled, this endpoint also requires an
API key.
operationId: getHealth
responses:
'200':
description: Server is healthy
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
/enrichment/{icao_hex}:
get:
tags:
- Enrichment
summary: Get enrichments by aircraft
description: |
Returns all flight enrichments for an aircraft on today's date (UTC),
ordered by most recently updated first. An aircraft may have multiple
enrichments if it operated multiple flights. When there are none, the
response is `404` rather than an empty array.
operationId: getEnrichmentByAircraft
parameters:
- $ref: '#/components/parameters/ICAOHex'
responses:
'200':
description: Enrichment data found
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/FlightEnrichment'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
description: No enrichment data found for the aircraft
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: 'No enrichment data found for aircraft'
'500':
$ref: '#/components/responses/InternalError'
/enrichment/{icao_hex}/{callsign}:
get:
tags:
- Enrichment
summary: Get enrichment by aircraft and callsign
description: |
Returns the enrichment for a specific flight (aircraft and callsign) on
today's date (UTC). The callsign is matched on its trailing digits, so
IATA and ICAO forms of the same flight number return the same record.
operationId: getEnrichmentByCallsign
parameters:
- $ref: '#/components/parameters/ICAOHex'
- $ref: '#/components/parameters/Callsign'
responses:
'200':
description: Enrichment data found
content:
application/json:
schema:
$ref: '#/components/schemas/FlightEnrichment'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
/enrichment/{icao_hex}/{callsign}/{date}:
get:
tags:
- Enrichment
summary: Get enrichment by aircraft, callsign, and date
description: |
Returns the enrichment for a specific flight on a specific date. Use
this for historical lookups. Callsign matching is the same as for
`getEnrichmentByCallsign`.
operationId: getEnrichmentByDate
parameters:
- $ref: '#/components/parameters/ICAOHex'
- $ref: '#/components/parameters/Callsign'
- $ref: '#/components/parameters/FlightDate'
responses:
'200':
description: Enrichment data found
content:
application/json:
schema:
$ref: '#/components/schemas/FlightEnrichment'
'400':
$ref: '#/components/responses/BadRequest'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
'404':
$ref: '#/components/responses/NotFound'
'500':
$ref: '#/components/responses/InternalError'
/enrichment/batch:
post:
tags:
- Enrichment
summary: Batch lookup enrichments
description: |
Look up enrichments for multiple aircraft in a single request.
Maximum 100 aircraft per request. Returns today's (UTC) data.
Entries with an empty `icao_hex` are skipped. Aircraft with no data are
omitted from `results`. A database error for an individual aircraft is
reported in `errors` and does not fail the request.
operationId: batchEnrichment
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/BatchRequest'
responses:
'200':
description: Batch results
content:
application/json:
schema:
$ref: '#/components/schemas/BatchResponse'
'400':
description: |
The body is not valid JSON, `aircraft` is empty, or `aircraft` has
more than 100 entries.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: 'Maximum 100 aircraft per batch request'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/Forbidden'
components:
parameters:
ICAOHex:
name: icao_hex
in: path
required: true
description: |
Aircraft ICAO 24-bit address in hexadecimal (e.g., "7C6CA3"). The value
is converted to upper case; its format is not validated.
schema:
type: string
example: '7C6CA3'
Callsign:
name: callsign
in: path
required: true
description: |
Flight callsign or flight number in IATA or ICAO form (e.g., "QF9",
"QFA9"). The value is converted to upper case; its format is not
validated. Leading zeros in the numeric part are not removed, so
"QFA008" does not match a stored "QFA8".
schema:
type: string
example: 'QFA9'
FlightDate:
name: date
in: path
required: true
description: Flight date in YYYY-MM-DD format (UTC).
schema:
type: string
format: date
example: '2026-01-30'
schemas:
HealthResponse:
type: object
required:
- status
- time
properties:
status:
type: string
description: Health status
example: 'ok'
time:
type: string
format: date-time
description: Current server time (UTC)
example: '2026-01-30T14:30:00Z'
FlightEnrichment:
type: object
required:
- icao_hex
- callsign
- flight_date
- last_updated
properties:
icao_hex:
type: string
description: Aircraft ICAO 24-bit hex address
example: '7C6CA3'
callsign:
type: string
description: Flight callsign as stored; may be IATA or ICAO form
example: 'QFA9'
flight_date:
type: string
format: date
description: Flight date (the date the data was received)
example: '2026-01-30'
origin:
type: string
description: Origin airport code as reported; may be ICAO or IATA
example: 'YPPH'
destination:
type: string
description: Destination airport code as reported; may be ICAO or IATA
example: 'EGLL'
route:
type: array
description: Route waypoints
items:
type: string
example: ['JULIM', 'BEVLY', 'ORRSU', 'LONSU']
eta:
type: string
description: Estimated time of arrival (HH:MM). Currently never populated.
example: '14:30'
departure_runway:
type: string
description: Departure runway
example: '03'
arrival_runway:
type: string
description: Arrival runway. Currently never populated.
example: '27R'
sid:
type: string
description: Standard Instrument Departure procedure
example: 'JULIM6'
squawk:
type: string
description: Assigned transponder code
example: '4521'
pax_count:
type: integer
description: Total passenger count; omitted when zero or unknown
example: 350
pax_breakdown:
type: object
description: Passenger count by cabin class. Currently never populated.
additionalProperties:
type: integer
example:
J: 14
W: 56
Y: 280
last_updated:
type: string
format: date-time
description: |
When this enrichment was last updated (RFC 3339). The offset is the
local time zone of the host running the API, so it may not be `Z`.
example: '2026-01-30T08:45:00Z'
BatchRequest:
type: object
required:
- aircraft
properties:
aircraft:
type: array
description: List of aircraft to look up (max 100)
minItems: 1
maxItems: 100
items:
$ref: '#/components/schemas/BatchAircraftQuery'
BatchAircraftQuery:
type: object
required:
- icao_hex
properties:
icao_hex:
type: string
description: Aircraft ICAO 24-bit hex address; entries with an empty value are skipped
example: '7C6CA3'
callsign:
type: string
description: Optional callsign; when set, at most one record is returned
example: 'QFA9'
BatchResponse:
type: object
required:
- results
properties:
results:
type: object
description: |
Enrichments keyed by upper-case ICAO hex. Aircraft with no data are
omitted.
additionalProperties:
type: array
items:
$ref: '#/components/schemas/FlightEnrichment'
errors:
type: object
description: |
Database error text keyed by ICAO hex. Omitted when no lookup
failed.
additionalProperties:
type: string
Error:
type: object
required:
- error
properties:
error:
type: string
description: Error message
example: 'No enrichment data found'
responses:
BadRequest:
description: Invalid date format
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: 'Invalid date format (use YYYY-MM-DD)'
Unauthorized:
description: Authentication is enabled and no API key was supplied
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: 'API key required'
Forbidden:
description: Authentication is enabled and the API key is not valid
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: 'Invalid API key'
NotFound:
description: No enrichment data found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: 'No enrichment data found'
InternalError:
description: Database error; the message contains the underlying error text
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
securitySchemes:
ApiKeyHeader:
type: apiKey
in: header
name: X-API-Key
description: API key passed in X-API-Key header
BearerAuth:
type: http
scheme: bearer
description: API key passed as Bearer token
ApiKeyQuery:
type: apiKey
in: query
name: api_key
description: API key passed as query parameter (for testing only)
# Authentication is optional (disabled by default). The empty requirement `{}`
# indicates that requests without a key are accepted when it is disabled.
security:
- {}
- ApiKeyHeader: []
- BearerAuth: []
- ApiKeyQuery: []