-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasyncapi.json
More file actions
597 lines (597 loc) · 21 KB
/
Copy pathasyncapi.json
File metadata and controls
597 lines (597 loc) · 21 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
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
{
"asyncapi": "2.6.0",
"info": {
"title": "X-Plane Local Web API — WebSocket",
"version": "3.0.0",
"description": "WebSocket interface for the X-Plane local web server. Use this to subscribe to real-time dataref updates (10Hz), stream dataref writes, and control commands.\n\nThe WebSocket endpoint shares the same TCP port as the REST API. All messages are JSON strings.\n\nEvery client message must include a unique `req_id` (numeric, non-recyclable). Each message you send must have a new, never-before-used `req_id`. The server responds with a `result` message containing the same `req_id` so you can match responses to requests. If the operation type is not recognized, the server returns the `unknown_type` error code.\n\nFor more information, see the [official documentation](https://developer.x-plane.com/article/x-plane-web-api/).",
"contact": {
"name": "X-Plane Developer",
"url": "https://developer.x-plane.com"
}
},
"servers": {
"local": {
"url": "localhost:8086/api/v3",
"protocol": "ws",
"description": "X-Plane local WebSocket server (default port). Change port with `--web_server_port=XXXX` when launching X-Plane."
}
},
"channels": {
"/": {
"publish": {
"operationId": "sendMessage",
"summary": "Messages sent from client to X-Plane",
"description": "All client-to-server messages. Each message must include a unique `req_id` and a `type` field.",
"message": {
"oneOf": [
{ "$ref": "#/components/messages/DatarefSubscribeValues" },
{ "$ref": "#/components/messages/DatarefUnsubscribeValues" },
{ "$ref": "#/components/messages/DatarefSetValues" },
{ "$ref": "#/components/messages/CommandSubscribeIsActive" },
{ "$ref": "#/components/messages/CommandUnsubscribeIsActive" },
{ "$ref": "#/components/messages/CommandSetIsActive" }
]
}
},
"subscribe": {
"operationId": "receiveMessage",
"summary": "Messages received from X-Plane",
"description": "All server-to-client messages including operation results and real-time updates.",
"message": {
"oneOf": [
{ "$ref": "#/components/messages/Result" },
{ "$ref": "#/components/messages/DatarefUpdateValues" },
{ "$ref": "#/components/messages/CommandUpdateIsActive" }
]
}
}
}
},
"components": {
"messages": {
"DatarefSubscribeValues": {
"name": "dataref_subscribe_values",
"title": "Subscribe to dataref value updates",
"summary": "Subscribe to periodic value updates for one or more datarefs (v1+). Updates are pushed at 10Hz, but only when values change. Possible error codes: `index_out_of_range`, `not_an_array`, `invalid_dataref_id`.",
"payload": {
"type": "object",
"required": ["req_id", "type", "params"],
"properties": {
"req_id": {
"$ref": "#/components/schemas/ReqId"
},
"type": {
"type": "string",
"const": "dataref_subscribe_values"
},
"params": {
"type": "object",
"required": ["datarefs"],
"properties": {
"datarefs": {
"type": "array",
"description": "List of datarefs to subscribe to",
"items": {
"type": "object",
"required": ["id"],
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "Dataref ID"
},
"index": {
"description": "For array datarefs: a single index or array of indices to subscribe to",
"oneOf": [
{ "type": "integer" },
{
"type": "array",
"items": { "type": "integer" }
}
]
}
}
}
}
}
}
}
},
"examples": [
{
"name": "subscribe_example",
"summary": "Subscribe to multiple datarefs with index selection",
"payload": {
"req_id": 9998,
"type": "dataref_subscribe_values",
"params": {
"datarefs": [
{ "id": 1223, "index": 2 },
{ "id": 1224, "index": [0, 1, 2, 3] },
{ "id": 1225 }
]
}
}
}
]
},
"DatarefUnsubscribeValues": {
"name": "dataref_unsubscribe_values",
"title": "Unsubscribe from dataref value updates",
"summary": "Stop receiving updates for one or more datarefs (v1+). The operation is idempotent. Use `\"all\"` to unsubscribe from everything. Possible error codes: `index_out_of_range`, `not_an_array`, `invalid_dataref_id`.",
"payload": {
"type": "object",
"required": ["req_id", "type", "params"],
"properties": {
"req_id": {
"$ref": "#/components/schemas/ReqId"
},
"type": {
"type": "string",
"const": "dataref_unsubscribe_values"
},
"params": {
"type": "object",
"required": ["datarefs"],
"properties": {
"datarefs": {
"description": "List of datarefs to unsubscribe from, or the string `\"all\"` to unsubscribe from everything",
"oneOf": [
{
"type": "array",
"items": {
"type": "object",
"required": ["id"],
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "Dataref ID"
},
"index": {
"description": "For array datarefs: a single index or array of indices to unsubscribe from",
"oneOf": [
{ "type": "integer" },
{
"type": "array",
"items": { "type": "integer" }
}
]
}
}
}
},
{
"type": "string",
"const": "all"
}
]
}
}
}
}
},
"examples": [
{
"name": "unsubscribe_specific",
"summary": "Unsubscribe from specific datarefs",
"payload": {
"req_id": 1234,
"type": "dataref_unsubscribe_values",
"params": {
"datarefs": [
{ "id": 1223, "index": 2 },
{ "id": 1225 }
]
}
}
},
{
"name": "unsubscribe_all",
"summary": "Unsubscribe from all datarefs",
"payload": {
"req_id": 1235,
"type": "dataref_unsubscribe_values",
"params": {
"datarefs": "all"
}
}
}
]
},
"DatarefSetValues": {
"name": "dataref_set_values",
"title": "Set dataref values",
"summary": "Set one or more dataref values via WebSocket (v1+). For array datarefs, you can set a specific index or the whole array. Possible error codes: `index_out_of_range`, `not_an_array`, `insufficient_data`, `invalid_dataref_id`.",
"payload": {
"type": "object",
"required": ["req_id", "type", "params"],
"properties": {
"req_id": {
"$ref": "#/components/schemas/ReqId"
},
"type": {
"type": "string",
"const": "dataref_set_values"
},
"params": {
"type": "object",
"required": ["datarefs"],
"properties": {
"datarefs": {
"type": "array",
"description": "List of datarefs to set",
"items": {
"type": "object",
"required": ["id", "value"],
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "Dataref ID"
},
"value": {
"description": "Value to set: a number, array of numbers, or base64 string",
"oneOf": [
{ "type": "number" },
{
"type": "array",
"items": { "type": "number" }
},
{ "type": "string" }
]
},
"index": {
"type": "integer",
"description": "For array datarefs: specific index to set"
}
}
}
}
}
}
}
},
"examples": [
{
"name": "set_values_example",
"payload": {
"req_id": 1234,
"type": "dataref_set_values",
"params": {
"datarefs": [
{ "id": 88491, "value": 6 },
{ "id": 39222, "value": [2, 2, 1, 0] },
{ "id": 37555, "value": 2, "index": 1 }
]
}
}
}
]
},
"CommandSubscribeIsActive": {
"name": "command_subscribe_is_active",
"title": "Subscribe to command activation updates",
"summary": "Subscribe to activation status updates for one or more commands (v2+). Updates are pushed when command status changes. Possible error codes: `invalid_command_id`.",
"payload": {
"type": "object",
"required": ["req_id", "type", "params"],
"properties": {
"req_id": {
"$ref": "#/components/schemas/ReqId"
},
"type": {
"type": "string",
"const": "command_subscribe_is_active"
},
"params": {
"type": "object",
"required": ["commands"],
"properties": {
"commands": {
"type": "array",
"description": "List of commands to subscribe to",
"items": {
"type": "object",
"required": ["id"],
"properties": {
"id": {
"type": "integer",
"description": "Command ID"
}
}
}
}
}
}
}
},
"examples": [
{
"name": "subscribe_commands",
"payload": {
"req_id": 9998,
"type": "command_subscribe_is_active",
"params": {
"commands": [
{ "id": 1223 },
{ "id": 1224 },
{ "id": 1225 }
]
}
}
}
]
},
"CommandUnsubscribeIsActive": {
"name": "command_unsubscribe_is_active",
"title": "Unsubscribe from command activation updates",
"summary": "Stop receiving activation updates for one or more commands (v2+). Use `\"all\"` to unsubscribe from everything. Possible error codes: `invalid_command_id`.",
"payload": {
"type": "object",
"required": ["req_id", "type", "params"],
"properties": {
"req_id": {
"$ref": "#/components/schemas/ReqId"
},
"type": {
"type": "string",
"const": "command_unsubscribe_is_active"
},
"params": {
"type": "object",
"required": ["commands"],
"properties": {
"commands": {
"description": "List of commands to unsubscribe from, or `\"all\"`",
"oneOf": [
{
"type": "array",
"items": {
"type": "object",
"required": ["id"],
"properties": {
"id": {
"type": "integer",
"description": "Command ID"
}
}
}
},
{
"type": "string",
"const": "all"
}
]
}
}
}
}
},
"examples": [
{
"name": "unsubscribe_commands",
"payload": {
"req_id": 1234,
"type": "command_unsubscribe_is_active",
"params": {
"commands": [
{ "id": 1223 },
{ "id": 1224 }
]
}
}
}
]
},
"CommandSetIsActive": {
"name": "command_set_is_active",
"title": "Set command active state",
"summary": "Activate or deactivate one or more commands (v2+). Optionally set a duration after which the command auto-deactivates. If disconnected, all commands are automatically released. Possible error codes: `invalid_command_id`, `duration_out_of_range`.",
"payload": {
"type": "object",
"required": ["req_id", "type", "params"],
"properties": {
"req_id": {
"$ref": "#/components/schemas/ReqId"
},
"type": {
"type": "string",
"const": "command_set_is_active"
},
"params": {
"type": "object",
"required": ["commands"],
"properties": {
"commands": {
"type": "array",
"description": "List of commands to activate or deactivate",
"items": {
"type": "object",
"required": ["id", "is_active"],
"properties": {
"id": {
"type": "integer",
"description": "Command ID"
},
"is_active": {
"type": "boolean",
"description": "Whether to activate (true) or deactivate (false) the command"
},
"duration": {
"type": "number",
"format": "float",
"minimum": 0,
"description": "Time in seconds after which the command auto-deactivates. Only valid when `is_active` is true. Omit to hold indefinitely (max 24 hours). Use 0 for immediate press-and-release."
}
}
}
}
}
}
}
},
"examples": [
{
"name": "set_active_example",
"payload": {
"req_id": 1234,
"type": "command_set_is_active",
"params": {
"commands": [
{ "id": 88491, "is_active": true, "duration": 0.5 },
{ "id": 37555, "is_active": true, "duration": 0 },
{ "id": 39222, "is_active": false }
]
}
}
}
]
},
"Result": {
"name": "result",
"title": "Operation result",
"summary": "Server response to any client request, indicating success or failure. If the operation type is not recognized, the server returns the `unknown_type` error code.",
"payload": {
"type": "object",
"required": ["req_id", "type", "success"],
"properties": {
"req_id": {
"$ref": "#/components/schemas/ReqId"
},
"type": {
"type": "string",
"const": "result"
},
"success": {
"type": "boolean",
"description": "Whether the operation succeeded"
},
"error_code": {
"type": "string",
"description": "Machine-readable error code (present when success is false)"
},
"error_message": {
"type": "string",
"description": "Human-readable error message (present when success is false)"
}
}
},
"examples": [
{
"name": "success",
"summary": "Successful operation",
"payload": {
"req_id": 123,
"type": "result",
"success": true
}
},
{
"name": "error",
"summary": "Failed operation",
"payload": {
"req_id": 123,
"type": "result",
"success": false,
"error_code": "invalid_dataref_id",
"error_message": "Dataref id 99999 doesn't exist"
}
},
{
"name": "unknown_type",
"summary": "Unrecognized operation type",
"payload": {
"req_id": 124,
"type": "result",
"success": false,
"error_code": "unknown_type"
}
}
]
},
"DatarefUpdateValues": {
"name": "dataref_update_values",
"title": "Dataref value updates",
"summary": "Periodic updates pushed by the server at 10Hz after a successful subscription. Only contains datarefs whose values have changed since the last update.",
"payload": {
"type": "object",
"required": ["type", "data"],
"properties": {
"type": {
"type": "string",
"const": "dataref_update_values"
},
"data": {
"type": "object",
"description": "Object with dataref IDs as keys and current values as values. Values are numbers for scalar datarefs or arrays for array datarefs.",
"additionalProperties": {
"oneOf": [
{ "type": "number" },
{
"type": "array",
"items": { "type": "number" }
}
]
}
}
}
},
"examples": [
{
"name": "update_example",
"payload": {
"type": "dataref_update_values",
"data": {
"88491": 0,
"3994": 5,
"199": [0, 0, 0, 4]
}
}
}
]
},
"CommandUpdateIsActive": {
"name": "command_update_is_active",
"title": "Command activation updates",
"summary": "Pushed by the server when subscribed commands change their activation status (v2+).",
"payload": {
"type": "object",
"required": ["type", "data"],
"properties": {
"type": {
"type": "string",
"const": "command_update_is_active"
},
"data": {
"type": "object",
"description": "Object with command IDs as keys and activation status (boolean) as values",
"additionalProperties": {
"type": "boolean"
}
}
}
},
"examples": [
{
"name": "command_update_example",
"payload": {
"type": "command_update_is_active",
"data": {
"88491": false,
"3994": false,
"199": true
}
}
}
]
}
},
"schemas": {
"ReqId": {
"type": "integer",
"description": "Unique, non-recyclable numeric identifier for the request. Each message you send must have a new, never-before-used req_id. The server response will echo this ID back in the `result` message so you can match responses to requests."
}
}
}
}