-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
860 lines (825 loc) · 23.5 KB
/
openapi.yaml
File metadata and controls
860 lines (825 loc) · 23.5 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
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
openapi: 3.0.3
info:
title: SpaceAPI Endpoint
version: 1.0.0
description: |
An API server for a [SpaceAPI](https://spaceapi.io/) endpoint that follows the SpaceAPI v15 specification to expose real-time information about hackerspace status.
## Authentication
Protected endpoints (POST operations) require API key authentication via the `X-API-Key` header.
## Rate Limiting
Failed authentication attempts are rate limited to prevent brute force attacks:
- **Limit**: 5 failed attempts within 15 minutes
- **Block Duration**: 1 hour
- **Response**: HTTP 429 Too Many Requests with `Retry-After` header
- **Scope**: Per IP address
contact:
name: SpaceAPI Endpoint Project
url: https://github.com/q30-space/spaceapi-endpoint
license:
name: GNU General Public License v3.0
url: https://www.gnu.org/licenses/gpl-3.0.html
servers:
- url: http://localhost:8080
description: Local development server
- url: http://localhost:8089
description: Docker development server
tags:
- name: public
description: Public endpoints (no authentication required)
- name: protected
description: Protected endpoints (API key required)
paths:
/:
get:
tags:
- public
summary: Get SpaceAPI data (root endpoint)
description: Returns the complete SpaceAPI JSON response containing information about the hackerspace.
operationId: getSpaceAPIRoot
responses:
'200':
description: Successful response with SpaceAPI data
content:
application/json:
schema:
$ref: '#/components/schemas/SpaceAPI'
examples:
example:
$ref: '#/components/examples/SpaceAPIExample'
/api/space:
get:
tags:
- public
summary: Get SpaceAPI data
description: Returns the complete SpaceAPI JSON response containing information about the hackerspace status, location, contact info, sensors, and more.
operationId: getSpaceAPI
responses:
'200':
description: Successful response with SpaceAPI data
content:
application/json:
schema:
$ref: '#/components/schemas/SpaceAPI'
examples:
example:
$ref: '#/components/examples/SpaceAPIExample'
/api/space/state:
post:
tags:
- protected
summary: Update space state
description: |
Updates the space state (open/closed status). Requires API key authentication.
The `lastchange` timestamp is automatically set to the current time.
operationId: updateState
security:
- ApiKeyAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/StateUpdate'
examples:
openSpace:
summary: Open the space
value:
open: true
message: "Space is open for members"
trigger_person: "John Doe"
closeSpace:
summary: Close the space
value:
open: false
message: "Closed for maintenance"
trigger_person: "Jane Smith"
responses:
'200':
description: State updated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/State'
'400':
description: Invalid JSON
content:
text/plain:
schema:
type: string
example: "Invalid JSON"
'401':
description: Missing or invalid API key
content:
text/plain:
schema:
type: string
example: "Invalid API key"
'403':
description: Access forbidden (API key format invalid)
content:
text/plain:
schema:
type: string
example: "Access forbidden"
'429':
description: Too many failed authentication attempts
headers:
Retry-After:
schema:
type: integer
description: Number of seconds to wait before retrying
content:
text/plain:
schema:
type: string
example: "Too many failed authentication attempts. Please try again later."
/api/space/people:
post:
tags:
- protected
summary: Update people count
description: |
Updates the people count in the space. Requires API key authentication.
The sensor's `lastchange` timestamp is automatically set to the current time.
If the location doesn't exist, a new sensor entry is created.
operationId: updatePeopleCount
security:
- ApiKeyAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/PeopleCountUpdate'
examples:
updateMainSpace:
summary: Update main space people count
value:
value: 5
location: "Main Space"
setToZero:
summary: Set people count to zero
value:
value: 0
responses:
'200':
description: People count updated successfully
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/SensorValue'
'400':
description: Invalid JSON
content:
text/plain:
schema:
type: string
example: "Invalid JSON"
'401':
description: Missing or invalid API key
content:
text/plain:
schema:
type: string
example: "Invalid API key"
'403':
description: Access forbidden
content:
text/plain:
schema:
type: string
example: "Access forbidden"
'429':
description: Too many failed authentication attempts
headers:
Retry-After:
schema:
type: integer
description: Number of seconds to wait before retrying
content:
text/plain:
schema:
type: string
example: "Too many failed authentication attempts. Please try again later."
/api/space/event:
post:
tags:
- protected
summary: Add an event
description: |
Adds an event to the space timeline. Requires API key authentication.
The `timestamp` is automatically set to the current time.
Only the last 10 events are kept in memory.
operationId: addEvent
security:
- ApiKeyAuth: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/EventCreate'
examples:
checkIn:
summary: Check-in event
value:
name: "John Doe"
type: "check-in"
extra: "Working on Arduino project"
checkOut:
summary: Check-out event
value:
name: "Jane Smith"
type: "check-out"
responses:
'200':
description: Event added successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Event'
'400':
description: Invalid JSON
content:
text/plain:
schema:
type: string
example: "Invalid JSON"
'401':
description: Missing or invalid API key
content:
text/plain:
schema:
type: string
example: "Invalid API key"
'403':
description: Access forbidden
content:
text/plain:
schema:
type: string
example: "Access forbidden"
'429':
description: Too many failed authentication attempts
headers:
Retry-After:
schema:
type: integer
description: Number of seconds to wait before retrying
content:
text/plain:
schema:
type: string
example: "Too many failed authentication attempts. Please try again later."
/health:
get:
tags:
- public
summary: Health check
description: Simple health check endpoint that returns "OK" if the service is running.
operationId: healthCheck
responses:
'200':
description: Service is healthy
content:
text/plain:
schema:
type: string
example: "OK"
components:
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: X-API-Key
description: API key for authenticated endpoints. Set via SPACEAPI_AUTH_KEY environment variable.
schemas:
SpaceAPI:
type: object
required:
- api_compatibility
- space
- logo
- url
- contact
properties:
api_compatibility:
type: array
items:
type: string
description: List of SpaceAPI versions supported
example: ["15"]
space:
type: string
description: Name of the space
example: "Hackerspace XYZ"
logo:
type: string
format: uri
description: URL to the space logo
example: "https://example.com/images/logo.png"
url:
type: string
format: uri
description: URL to the space website
example: "https://example.com"
location:
$ref: '#/components/schemas/Location'
spacefed:
$ref: '#/components/schemas/Spacefed'
cam:
type: array
items:
type: string
format: uri
description: URLs of webcams in the space
state:
$ref: '#/components/schemas/State'
events:
type: array
items:
$ref: '#/components/schemas/Event'
description: Recent events in the space (max 10)
contact:
$ref: '#/components/schemas/Contact'
sensors:
$ref: '#/components/schemas/Sensors'
feeds:
$ref: '#/components/schemas/Feeds'
projects:
type: array
items:
type: string
format: uri
description: URLs to space projects
links:
type: array
items:
$ref: '#/components/schemas/Link'
membership_plans:
type: array
items:
$ref: '#/components/schemas/MembershipPlan'
linked_spaces:
type: array
items:
$ref: '#/components/schemas/LinkedSpace'
Location:
type: object
properties:
address:
type: string
description: Physical address of the space
example: "123 Main Street, City, 12345"
lat:
type: number
format: double
description: Latitude coordinate
example: 52.520008
lon:
type: number
format: double
description: Longitude coordinate
example: 13.404954
timezone:
type: string
description: IANA timezone identifier
example: "Europe/Berlin"
country_code:
type: string
description: ISO 3166-1 alpha-2 country code
example: "DE"
hint:
type: string
description: Additional location hint or access instructions
example: "The door code is 1234."
areas:
type: array
items:
$ref: '#/components/schemas/Area'
Area:
type: object
required:
- name
- square_meters
properties:
name:
type: string
description: Name of the area
example: "Workshop"
description:
type: string
description: Description of the area
square_meters:
type: number
format: double
description: Size of the area in square meters
example: 42.5
Spacefed:
type: object
properties:
spacenet:
type: boolean
description: Space is part of SpaceNet
spacesaml:
type: boolean
description: Space supports SpaceSAML
State:
type: object
properties:
open:
type: boolean
nullable: true
description: Whether the space is currently open
example: true
lastchange:
type: integer
format: int64
description: Unix timestamp of the last state change
example: 1640000000
trigger_person:
type: string
description: Person who triggered the state change
example: "John Doe"
message:
type: string
description: Additional message about the current state
example: "Space is open for members"
icon:
$ref: '#/components/schemas/Icon'
Icon:
type: object
required:
- open
- closed
properties:
open:
type: string
format: uri
description: Icon URL for open state
closed:
type: string
format: uri
description: Icon URL for closed state
StateUpdate:
type: object
properties:
open:
type: boolean
nullable: true
description: Whether the space is currently open
example: true
message:
type: string
description: Additional message about the state
example: "Space is open for members"
trigger_person:
type: string
description: Person triggering the state change
example: "John Doe"
Event:
type: object
required:
- name
- type
- timestamp
properties:
name:
type: string
description: Name associated with the event (usually a person)
example: "John Doe"
type:
type: string
description: Type of event
example: "check-in"
timestamp:
type: integer
format: int64
description: Unix timestamp of the event
example: 1640000000
extra:
type: string
description: Additional information about the event
example: "Working on Arduino project"
EventCreate:
type: object
required:
- name
- type
properties:
name:
type: string
description: Name associated with the event (usually a person)
example: "John Doe"
type:
type: string
description: Type of event
example: "check-in"
extra:
type: string
description: Additional information about the event
example: "Working on Arduino project"
Contact:
type: object
properties:
phone:
type: string
description: Phone number
example: "+1-555-0123"
sip:
type: string
description: SIP address
keymasters:
type: array
items:
$ref: '#/components/schemas/Keymaster'
irc:
type: string
description: IRC channel
example: "irc://irc.example.com/#hackerspace"
twitter:
type: string
description: Twitter handle
example: "@hackerspace"
mastodon:
type: string
description: Mastodon handle
example: "@hackerspace@mastodon.social"
facebook:
type: string
description: Facebook page
identica:
type: string
description: Identica handle
foursquare:
type: string
description: Foursquare venue ID
email:
type: string
format: email
description: Contact email
example: "contact@example.com"
ml:
type: string
description: Mailing list
xmpp:
type: string
description: XMPP/Jabber address
issue_mail:
type: string
format: email
description: Email for issue reports
Keymaster:
type: object
properties:
name:
type: string
description: Name of the keymaster
irc_nick:
type: string
description: IRC nickname
phone:
type: string
description: Phone number
email:
type: string
format: email
description: Email address
twitter:
type: string
description: Twitter handle
xmpp:
type: string
description: XMPP/Jabber address
mastodon:
type: string
description: Mastodon handle
matrix:
type: string
description: Matrix ID
Sensors:
type: object
properties:
temperature:
type: array
items:
$ref: '#/components/schemas/SensorValue'
door_locked:
type: array
items:
$ref: '#/components/schemas/SensorValue'
barometer:
type: array
items:
$ref: '#/components/schemas/SensorValue'
radiation:
type: array
items:
$ref: '#/components/schemas/SensorValue'
humidity:
type: array
items:
$ref: '#/components/schemas/SensorValue'
beverage_supply:
type: array
items:
$ref: '#/components/schemas/SensorValue'
power_consumption:
type: array
items:
$ref: '#/components/schemas/SensorValue'
wind:
type: array
items:
$ref: '#/components/schemas/SensorValue'
network_connections:
type: array
items:
$ref: '#/components/schemas/SensorValue'
account_balance:
type: array
items:
$ref: '#/components/schemas/SensorValue'
total_member_count:
type: array
items:
$ref: '#/components/schemas/SensorValue'
people_now_present:
type: array
items:
$ref: '#/components/schemas/SensorValue'
network_traffic:
type: array
items:
$ref: '#/components/schemas/SensorValue'
SensorValue:
type: object
required:
- value
properties:
value:
anyOf:
- type: integer
- type: number
- type: string
- type: boolean
description: The sensor value
example: 5
unit:
type: string
description: Unit of measurement
example: "°C"
location:
type: string
description: Location of the sensor
example: "Main Space"
name:
type: string
description: Name of the sensor
example: "People Counter"
description:
type: string
description: Description of the sensor
lastchange:
type: integer
format: int64
description: Unix timestamp of the last change
example: 1640000000
PeopleCountUpdate:
type: object
required:
- value
properties:
value:
type: integer
description: Number of people present
example: 5
location:
type: string
description: Location in the space (defaults to "Main Space" if not provided)
example: "Main Space"
Feeds:
type: object
properties:
blog:
$ref: '#/components/schemas/Feed'
wiki:
$ref: '#/components/schemas/Feed'
calendar:
$ref: '#/components/schemas/Feed'
flickr:
$ref: '#/components/schemas/Feed'
Feed:
type: object
required:
- url
properties:
type:
type: string
description: Feed type (e.g., rss, atom, ical)
example: "rss"
url:
type: string
format: uri
description: URL to the feed
example: "https://example.com/posts/index.xml"
Link:
type: object
required:
- name
- url
properties:
name:
type: string
description: Name of the link
example: "Wiki"
description:
type: string
description: Description of the link
url:
type: string
format: uri
description: URL of the link
example: "https://wiki.example.com"
MembershipPlan:
type: object
required:
- name
- value
- currency
- billing_interval
properties:
name:
type: string
description: Name of the membership plan
example: "Regular Member"
value:
type: number
format: double
description: Cost of the membership
example: 25.0
currency:
type: string
description: ISO 4217 currency code
example: "EUR"
billing_interval:
type: string
description: Billing interval
example: "monthly"
description:
type: string
description: Description of the plan
LinkedSpace:
type: object
properties:
endpoint:
type: string
format: uri
description: URL to the linked space's SpaceAPI endpoint
website:
type: string
format: uri
description: URL to the linked space's website
example: "https://q30.space/"
examples:
SpaceAPIExample:
summary: Example SpaceAPI response
value:
api_compatibility:
- "15"
space: "Hackerspace XYZ"
logo: "https://example.com/images/logo.png"
url: "https://example.com"
location:
address: "123 Main Street, City, 12345"
lat: 52.520008
lon: 13.404954
timezone: "Europe/Berlin"
country_code: "DE"
hint: "The door code is 1234."
contact:
email: "contact@example.com"
state:
icon:
open: "https://example.com/images/logo_open.png"
closed: "https://example.com/images/logo_closed.png"
open: true
lastchange: 1640000000
message: "Space is open"
sensors:
people_now_present:
- value: 5
location: "Main Space"
name: "People Counter"
description: "Number of people currently in the space"
lastchange: 1640000000
feeds:
blog:
type: "rss"
url: "https://example.com/posts/index.xml"
projects:
- "https://github.com/example"
linked_spaces:
- website: "https://q30.space/"