-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathapi-spec.yml
More file actions
724 lines (720 loc) · 22.4 KB
/
Copy pathapi-spec.yml
File metadata and controls
724 lines (720 loc) · 22.4 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
openapi: 3.0.0
info:
version: 0.1.0
title: go-librespot API
description: go-librespot daemon API
# This spec is the source of truth for the API: the request/response models and
# the HTTP routing in daemon/api_gen.go are generated from it by oapi-codegen.
# Changing a payload here and regenerating is the way to change the API.
#
# Response schemas mark every field required so the generated structs keep
# emitting them; request schemas use x-go-type-skip-optional-pointer so optional
# fields stay plain values that default to their zero value, matching how the
# daemon has always read them.
components:
schemas:
track:
x-go-name: ApiTrack
description: A track or podcast episode
type: object
required:
- uri
- name
- artist_names
- album_name
- album_cover_url
- position
- duration
- release_date
- track_number
- disc_number
- format
- codec
- bitrate
- sample_rate
- bit_depth
properties:
uri:
description: URI
type: string
name:
description: Name
type: string
artist_names:
description: Artists name
type: array
items:
description: Artist name
type: string
album_name:
description: Album name
type: string
album_cover_url:
description: Album cover URL
type: string
nullable: true
position:
description: Playback position in milliseconds
type: integer
format: int64
duration:
description: Duration in milliseconds
type: integer
release_date:
description: Album release date, empty for episodes
type: string
track_number:
description: Track number within the disc, zero for episodes
type: integer
disc_number:
description: Disc number within the album, zero for episodes
type: integer
format:
description: >-
Spotify name of the audio file being decoded, for example
OGG_VORBIS_160
type: string
codec:
description: Codec family of the audio file
type: string
enum:
- vorbis
- flac
- mp3
- aac
- unknown
- ''
bitrate:
description: >-
Nominal bitrate in kbps, null for formats without a fixed one such
as FLAC
type: integer
nullable: true
sample_rate:
description: Sample rate of the decoded audio in Hz
type: integer
nullable: true
bit_depth:
description: >-
Bits per sample of the source audio, null for lossy formats which
have no meaningful source bit depth
type: integer
nullable: true
status:
x-go-name: ApiStatus
description: The player status
type: object
required:
- username
- device_id
- device_type
- device_name
- play_origin
- play_origin_device_id
- context_uri
- context_name
- stopped
- paused
- buffering
- volume
- volume_steps
- repeat_context
- repeat_track
- shuffle_context
- track
properties:
username:
description: Currently active account's username
type: string
device_id:
description: The player device ID
type: string
device_type:
description: The player device type, for example COMPUTER or SPEAKER
type: string
device_name:
description: The player device name
type: string
play_origin:
description: >-
Who started the playback, "go-librespot" identifies the API as the
play origin, everything else is Spotify own stuff, null when
nothing has started playback yet
type: string
nullable: true
play_origin_device_id:
description: >-
The device ID that sent the command starting the playback, null
when the playback was started locally through this API
type: string
nullable: true
context_uri:
description: >-
The URI of the context playback is coming from, null when there is
no context
type: string
nullable: true
context_name:
description: >-
The display name of the context, for example the playlist or album
name, null when there is no context or the resolver did not provide
a description
type: string
nullable: true
stopped:
description: Whether the player is stopped
type: boolean
paused:
description: Whether the player is paused
type: boolean
buffering:
description: Whether the player is buffering
type: boolean
volume:
description: The player current volume from 0 to max
type: integer
format: uint32
minimum: 0
volume_steps:
description: The player max volume value
type: integer
format: uint32
repeat_context:
description: Whether the repeat context feature is enabled
type: boolean
repeat_track:
description: Whether the repeat track feature is enabled
type: boolean
shuffle_context:
description: Whether the shuffle context feature is enabled
type: boolean
track:
allOf:
- $ref: '#/components/schemas/track'
nullable: true
next_track:
description: >-
The upcoming track when its metadata is cached (metadata.enabled),
so clients can pre-warm its name and cover art before the user
skips to it. Absent when unknown.
allOf:
- $ref: '#/components/schemas/track'
nullable: true
x-omitempty: true
contextTrackItem:
x-go-name: ApiContextTrackItem
description: One entry of a context listing
type: object
required: [ uri, track ]
properties:
uri:
description: The track URI
type: string
track:
description: >-
Full track metadata, or null while the background sweep has not
resolved this entry yet
allOf:
- $ref: '#/components/schemas/track'
nullable: true
contextTracks:
x-go-name: ApiContextTracks
description: A context's track listing
type: object
required: [ uri, ready, length, cached, tracks ]
properties:
uri:
description: The context URI
type: string
ready:
description: >-
False while the context is still being enumerated in the
background; the listing is empty until it is true
type: boolean
length:
description: Number of track entries
type: integer
cached:
description: >-
Entries with full metadata; poll again while cached < length
type: integer
tracks:
type: array
items:
$ref: '#/components/schemas/contextTrackItem'
root:
x-go-name: ApiRoot
description: API reachability and playback readiness
type: object
required: [ playback_ready ]
properties:
playback_ready:
description: >-
Whether the daemon is fully bootstrapped and ready to accept
/player/play
type: boolean
volume:
x-go-name: ApiVolume
description: The player volume settings
type: object
required: [ value, max ]
properties:
value:
description: The current volume, ranging from 0 to max
type: integer
format: uint32
max:
description: The max volume value
type: integer
format: uint32
token:
x-go-name: ApiToken
description: A Spotify access token for the active session
type: object
required: [ token ]
properties:
token:
description: The access token
type: string
deviceAuth:
x-go-name: ApiDeviceAuth
description: The pairing details of an in-flight device authorization flow
type: object
required: [ url, code, expires_at ]
properties:
url:
description: >-
The URL the user must visit to approve the request. It usually
embeds the code already, in which case entering it is not needed.
type: string
code:
description: The code the user must enter at the URL, if prompted
type: string
expires_at:
description: When the code stops being accepted
type: string
format: date-time
play:
x-go-name: ApiPlay
description: An initiate playback payload
type: object
required: [ uri ]
properties:
uri:
description: Spotify URI to start playing
type: string
skip_to_uri:
description: Spotify URI to skip to (when playing playlists)
type: string
x-go-type-skip-optional-pointer: true
paused:
description: Start playback as paused
type: boolean
x-go-type-skip-optional-pointer: true
position:
description: >-
Position in milliseconds to start playback at within the selected
track (0 starts from the beginning)
type: integer
format: int64
x-go-type-skip-optional-pointer: true
next:
x-go-name: ApiNext
description: A skip to next payload
type: object
properties:
uri:
description: >-
The track URI to skip to. When omitted the next track in the
context is played.
type: string
seek:
x-go-name: ApiSeek
description: A seek payload
type: object
required: [ position ]
properties:
position:
description: >-
Seek position in milliseconds. Must not be negative unless relative
is set.
type: integer
format: int64
relative:
description: Whether the seek position is relative to the current one
type: boolean
default: false
x-go-type-skip-optional-pointer: true
setVolume:
x-go-name: ApiSetVolume
description: A set volume payload
type: object
required: [ volume ]
properties:
volume:
description: >-
Volume from 0 to max. Must not be negative unless relative is set.
type: integer
format: int32
relative:
description: Whether to change the volume relative to the current volume
type: boolean
default: false
x-go-type-skip-optional-pointer: true
repeatContext:
x-go-name: ApiRepeatContext
description: A toggle repeating context payload
type: object
required: [ repeat_context ]
properties:
repeat_context:
description: Whether repeating context should be enabled
type: boolean
repeatTrack:
x-go-name: ApiRepeatTrack
description: A toggle repeating track payload
type: object
required: [ repeat_track ]
properties:
repeat_track:
description: Whether repeating track should be enabled
type: boolean
shuffleContext:
x-go-name: ApiShuffleContext
description: A toggle shuffling context payload
type: object
required: [ shuffle_context ]
properties:
shuffle_context:
description: Whether shuffling context should be enabled
type: boolean
addToQueue:
x-go-name: ApiAddToQueue
description: An add to queue payload
type: object
required: [ uri ]
properties:
uri:
description: The URI for the track that should be added
type: string
setDeviceName:
x-go-name: ApiSetDeviceName
description: A set device name payload
type: object
required: [ name ]
properties:
name:
description: The new device name
type: string
output:
x-go-name: ApiOutput
description: A reopen audio output payload
type: object
properties:
device:
description: >-
The output device name to open (backend-specific, e.g. an ALSA
device). Empty selects the configured default.
type: string
x-go-type-skip-optional-pointer: true
paths:
/:
get:
operationId: getRoot
description: Returns API reachability and playback readiness
responses:
200:
description: API is ok
content:
application/json:
schema:
$ref: '#/components/schemas/root'
/status:
get:
operationId: getStatus
description: Returns the player status
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/status'
204:
description: No active session
/token:
post:
operationId: getToken
description: Returns a Spotify access token for the active session
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/token'
204:
description: No active session
/auth/code:
get:
operationId: getAuthCode
description: >-
Returns the pairing URL and code of the device authorization flow the
daemon is waiting on, so a UI can show them instead of having the user
read the logs. Only the `device_auth` credentials type ever has one, and
only until the user approves the request or the code expires.
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/deviceAuth'
204:
description: No device authorization flow is waiting for the user
/events:
get:
operationId: getEvents
description: >-
WebSocket endpoint streaming player events as JSON objects of the form
`{"type": "...", "data": {...}}`. This is a protocol upgrade, not a
plain HTTP response.
responses:
101:
description: Switching protocols to WebSocket
/set_device_name:
post:
operationId: setDeviceName
description: Set the player device name
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/setDeviceName'
responses:
200:
description: Successful response
400:
description: The name is missing or empty
/context/tracks:
get:
operationId: getContextTracks
description: >-
List a context's tracks in order with metadata (name, artists, cover
art), fetched via the internal API (not the rate-limited public Web
API). Any context the player can play is accepted — playlist, album,
artist, show, a user's Liked Songs collection — and enumerated the
same way. The response never waits on the network: the first call for
an unknown context starts a background enumeration and returns
ready=false with an empty listing. Once ready is true, entries whose
metadata is not cached yet have a null track while a background sweep
fills them in. Poll until ready is true and cached == length. Clients
can render a browsable song list from this and start any entry via
POST /player/play with the context uri and the track as skip_to_uri.
Tracks and episodes are both listed, so shows enumerate to their
episodes. Long contexts are truncated to metadata.max_tracks. Listings
are reused for five minutes, so an edit made to a playlist within that
window is not reflected. Requires metadata.enabled; responds 404
otherwise.
parameters:
- name: uri
in: query
required: true
description: Spotify context URI (playlist, album, artist, show, collection)
schema:
type: string
responses:
200:
description: Successful response
content:
application/json:
schema:
$ref: '#/components/schemas/contextTracks'
400:
description: The uri does not name a listable context
404:
description: The metadata cache is disabled
/player/play:
post:
operationId: playerPlay
description: >-
Starts playing new content. To start a context shuffled (on a random
track), enable shuffle first via /player/shuffle_context and then call
this. Calling /player/shuffle_context after play only shuffles the
upcoming queue and keeps the current (first) track, so play alone (or
shuffle after play) always begins on the context's first track.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/play'
responses:
200:
description: Successful response
400:
description: The uri is missing or empty
/player/resume:
post:
operationId: playerResume
description: Resume playback (from paused state)
responses:
200:
description: Successful response
/player/pause:
post:
operationId: playerPause
description: Pause playback (from playing state)
responses:
200:
description: Successful response
/player/playpause:
post:
operationId: playerPlayPause
description: Resume playback when paused, or pause playback when playing
responses:
200:
description: Successful response
/player/stop:
post:
operationId: playerStop
description: Stop playback and disconnect session
responses:
200:
description: Successful response
/player/output:
post:
operationId: playerOutput
description: >-
Reopen the audio output on a different device without touching the
Spotify session, preserving the current track, playback position,
paused state and volume. Useful for switching speakers (e.g. ALSA or
bluealsa) live without reconnecting. If playback is active it switches
devices immediately (with a brief audio gap); if nothing is playing the
device is recorded and takes effect on the next output open. An empty
device selects the configured default output device.
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/output'
responses:
200:
description: Successful response
/player/next:
post:
operationId: playerNext
description: Skip to next track
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/next'
responses:
200:
description: Successful response
/player/prev:
post:
operationId: playerPrev
description: Skip to previous track (or rewind current track)
responses:
200:
description: Successful response
/player/seek:
post:
operationId: playerSeek
description: Seek current track
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/seek'
responses:
200:
description: Successful response
400:
description: The position is negative and the seek is not relative
/player/volume:
get:
operationId: playerGetVolume
description: Get player volume
responses:
200:
description: Returns the player volume settings
content:
application/json:
schema:
$ref: '#/components/schemas/volume'
post:
operationId: playerSetVolume
description: Set player volume
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/setVolume'
responses:
200:
description: Successful response
400:
description: The volume is negative and the change is not relative
/player/repeat_context:
post:
operationId: playerRepeatContext
description: Toggle repeating context
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/repeatContext'
responses:
200:
description: Successful response
/player/repeat_track:
post:
operationId: playerRepeatTrack
description: Toggle repeating track
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/repeatTrack'
responses:
200:
description: Successful response
/player/shuffle_context:
post:
operationId: playerShuffleContext
description: >-
Toggle shuffling the context. Enabling it BEFORE /player/play makes
playback start on a random track; enabling it after play only reshuffles
the upcoming queue and keeps the current (first) track.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/shuffleContext'
responses:
200:
description: Successful response
/player/add_to_queue:
post:
operationId: playerAddToQueue
description: Add a track to the queue
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/addToQueue'
responses:
200:
description: Successful response
400:
description: The uri is missing or empty