Web Music Player provides and consumes some API.
Each API requires an authentication token provided in the Authorization
header with the bearer scheme :
Authorization: Bearer fyJhbGciOiJIUzI1NiIsIcpoCEC475rvrvrF.feknaaojapoZjHaopzfjapozfazf46fefzZFZCPHKGRaEGE6rvwJrherhergerpgo5fzfzfznbrptob3prt5brojmzvzemvzIiwiZW1haWwiOiJhZG1pbkBuaW9jLmV1Iiwic2NvcGcezZEPHL3tg0d12dezAWx=.ifFZFzfZFzf86GdDJ41b0gzegzegzegZEGZEGezgze4=
This token is received by posting /users/tokens with user credentials :
POST /server/api/users/tokens
{"login": "yourlogin", "password": "yourpassword"}
The response include the token in a JSON object:
{"token":"fyJhbGciOiJIUzI1NiIsIcpoCEC475rvrvrF.feknaaojapoZjHaopzfjapozfazf46fefzZFZCPHKGRaEGE6rvwJrherhergerpgo5fzfzfznbrptob3prt5brojmzvzemvzIiwiZW1haWwiOiJhZG1pbkBuaW9jLmV1Iiwic2NvcGcezZEPHL3tg0d12dezAWx=.ifFZFzfZFzf86GdDJ41b0gzegzegzegZEGZEGezgze4="}
In case of error, the following structure is returned in the body:
Name | Type | Description |
---|---|---|
code | integer | The error code describing the problem |
message | string | Message describing the error for humans understanding |
{
"code":500,
"message":"Database is unavailable"
}
Handle a user's playlist (tracks to play).
"Playlist track" ressource is structured as the following:
Name | Type | Description |
---|---|---|
id | integer | Track identifier |
title | string | Title |
file | string | Source of the track |
userId | string | Owner (user) identifiant |
sequence | integer | Track position in the playlist |
album | object | Album object (identifier and label) |
artist | object | Artist object (identifier and label) |
{
"id": 123,
"title": "Monkey gone to heaven",
"file": "/stream/123",
"userId": "1",
"sequence": 6,
"album": {
"id": 27,
"label": "Doolittle"
},
"artist": {
"id": 5,
"label": "Pixies"
}
}
GET /server/api/users/:userId/playlist/tracks
The API returns:
- 200 with an array of the tracks included in user's playlist,
- 204 if there is no track in user's playlist,
- 400 if user identifier
userId
is missing - 401 if authorization token is missing or invalid,
- 403 if the requester is not the playlist owner.
POST /server/api/users/:userId/playlist/tracks
The body request must include the track identifier in a json attribute (like this {"id": 1}
).
The API returns:
- 201 if the track is successfully added to the user's playlist (body contains the tracks sequence),
- 400 if a mandatory parameter is missing (user identifier
userId
, track identifier), - 401 if authorization token is missing or invalid,
- 403 if the requester is not the playlist owner,
- 500 in case of error.
DELETE /server/api/users/:userId/playlist/tracks
The API returns:
- 204 if the user's playlist is successfully cleared,
- 400 if a mandatory parameter is missing (user identifier
userId
), - 401 if authorization token is missing or invalid,
- 403 if the requester is not the playlist owner,
- 500 in case of error.
DELETE /server/api/users/:userId/playlist/tracks/:sequence
The API returns:
- 204 if the track is successfully removed from user's playlist,
- 400 if a mandatory parameter is missing (user identifier
userId
), - 401 if authorization token is missing or invalid,
- 403 if the requester is not the playlist owner,
- 404 if the track was not in the user's playlist.
PUT /server/api/users/:userId/playlist/tracks/:sequence
The body request must include the new sequence in a json attribute (like this {"newSequence": 1}
).
The API returns:
- 200 if user's playlist has been successfully reordered with all tracks in playlist for synchronizing with GUI,
- 204 if there is no track in user's playlist,
- 400 if a mandatory parameter is missing (user identifier
userId
, oldsequence
and new sequence of the tracknewSequence
), - 401 if authorization token is missing or invalid,
- 403 if the requester is not the playlist owner,
- 500 in case of error.
Handle the server library (tracks).
"Tracks" ressource is structured as the following:
Name | Type | Description |
---|---|---|
id | integer | Identifier |
title | string | Title |
file | string | Source of the track |
year | integer | Year of the track (1) |
time | integer | Track duration in seconds (1) |
track | integer | Track number in album (1) |
album | object | Album object (identifier and label) |
artist | object | Artist object (identifier and label) |
Notes:
1 : this information is not provided in GET without id (returning all the tracks).
{
"id": 123,
"title": "Monkey gone to heaven",
"file": "/stream/123",
"year": 1989,
"time": 176,
"track": 7,
"album": {
"id": 27,
"label": "Doolittle"
},
"artist": {
"id": 5,
"label": "Pixies"
}
}
GET /server/api/library/tracks[?trackTitle=:title|artistName=:artist|albumName=:album|search=:anything]
Following search criteria should be added in query string:
trackTitle
,artistName
,albumName
,search
(cumulative search on track title, artist and album).
The API returns:
- 200 with an array of tracks,
- 204 if there is no track in library,
- 401 if authorization token is missing or invalid,
- 500 in case of error.
GET /server/api/library/tracks/:id
The API returns:
- 200 with the requested track,
- 401 if authorization token is missing or invalid,
- 404 if track is unknown.
POST /server/api/library/tracks
{"folder":"/home/user/music/PIXIES/Doolittle/"}
The API returns:
- 201 with an array of the added tracks,
- 400 if folder attribute is omitted,
- 401 if authorization token is missing or invalid,
- 403 if requester is not granted to manage library,
- 500 in case of error.
PUT /server/api/library/tracks/:id
The body request must include track information in JSON (id property must be provided, editable properties are: year, title and track) :
{
"id":8792,
"year":1994,
"title":"The man who sold the world",
"track":4
}
The API returns:
- 200 with updated track,
- 400 if track identifier is omitted or if track in request body is not valid,
- 401 if authorization token is missing or invalid,
- 403 if requester is not granted to manage library,
- 404 if track is unknown,
- 500 in case of error.
Handle the server library folders and files.
"Folder" ressource is recursive and structured as the following:
Name | Type | Description |
---|---|---|
path | string | Path of the current folder |
subfolders | array(Folder) | Subfolders in the current folder |
files | array(string) | Files in the current folder |
[
{
"path":"/home/user/music/",
"subfolders":[
{
"path":"/home/user/music/PIXIES/",
"subfolders":[
{
"path":"/home/user/music/PIXIES/Doolittle/",
"subfolders":[
],
"files":[
"01 Debaser.mp3",
"02 Fame.mp3",
"03 Wave of mutilation.mp3",
"04 I bleed.mp3",
"05 Here comes your man.mp3",
"06 Dead.mp3",
"07 Monkey gone to heaven.mp3",
"08 Mr Grieves.mp3",
"09 Crackity Jones.mp3",
"10 La la love you.mp3",
"11 N° 13 baby.mp3",
"12 There goes my gun.mp3",
"13 Hey.mp3",
"14 Silver.mp3",
"15 Gounge away.mp3"
]
}
]
}
]
}
]
GET /server/api/library/folders
The API returns:
- 200 with an array of folders,
- 204 if current folder contains neither subfolders nor files,
- 401 if authorization token is missing or invalid,
- 403 if requester is not granted to manage library.
Handle user profile.
"User" ressource is structured as the following:
Name | Type | Description |
---|---|---|
sub | integer | Identifier |
login | string | Login |
name | string | User's full name |
string | User's email address | |
scope | string | List of scopes granted (space separated) |
{
"sub": 1,
"login": "john12",
"name": "John Doe",
"email": "john.doe@domain.com",
"scope": "user admin"
}
GET /server/api/users
The API returns:
- 200 with public profiles of all users,
- 401 if authorization token is missing or invalid,
- 403 if requester is not granted to manage users,
- 500 if there is an error during querying.
GET /server/api/users/:id
The API returns:
- 200 with user's public profile,
- 401 if authorization token is missing or invalid,
- 403 if requester is not granted to manage users and is requesting another user profile,
- 404 if user is unknown.
PUT /server/api/users/:id
The body request must include user public profile in JSON.
The API returns:
- 200 with updated user's public profile,
- 400 if user identifier is omitted or if user in request body is not valid,
- 401 if authorization token is missing or invalid,
- 403 if requester is not granted to manage users and is updating another user profile,
- 404 if user is unknown,
- 500 if there is an error during update process.
POST /server/api/users/
The body request must include user public profile in JSON.
The API returns:
- 201 with created user's public profile,
- 400 if user identifier is omitted or if user in request body is not valid,
- 401 if authorization token is missing or invalid,
- 403 if requester is not granted to manage users,
- 500 if there is an error during creation process.
Handle album informations.
"Album" ressource is structured as the following:
Name | Type | Description |
---|---|---|
id | integer | Identifier |
name | string | Album name |
mbid | string | MusicBrainz release identifier |
artist | object | Artist object (identifier and label) |
year | integer | Year when the album was released |
disk | integer | Disk number |
country | string | Country where the album is released |
mbidGroup | string | MusicBrainz release group identifier |
tracks | array | Track included in album |
coverPath | string | Path to album cover |
{
"id": 2,
"name": "Nevermind",
"mbid": "b52a8f31-b5ab-34e9-92f4-f5b7110220f0",
"artist":
{
"id": 1,
"label": "Nirvana"
},
"year": 1991,
"disk": null,
"country": "XE",
"mbidGroup": "5b11f4ce-a62d-471e-81fc-a69a8278c7da",
"tracks":[
{
"id": 7314,
"track": 1,
"title": "Smells Like Teen Spirit",
"time": 301,
"artist":
{
"id": 1,
"label": "Nirvana"
}
},
{
"id": 8775,
"track": 2,
"title": "In Bloom",
"time": 254,
"artist":
{
"id": 1,
"label": "Nirvana"
}
}
],
"coverPath": "/server/covers/2.jpeg"
}
GET /server/api/albums/:id
The API returns:
- 200 with album informations,
- 400 if album identifier is omitted,
- 401 if authorization token is missing or invalid,
- 404 if album identifier is unknown.
PUT /server/api/albums/:id
The body request must include album informations in JSON (id property must be provided, editable properties are: year, name) :
{
"id": 2,
"name": "Nevermind",
"year": 1991
}
The API returns:
- 200 with updated album informations,
- 400 if album identifier is omitted or if album in request body is not valid,
- 401 if authorization token is missing or invalid,
- 403 if requester is not granted to manage library,
- 404 if album identifier is unknown,
- 500 if there is an error during update process.
DELETE /server/api/albums/:id
The API returns:
- 204 in case of success,
- 400 if album identifier is omitted,
- 401 if authorization token is missing or invalid,
- 403 if requester is not granted to manage library,
- 500 if there is an error during delete process.
Handle album informations.
"Artist" ressource is structured as the following:
Name | Type | Description |
---|---|---|
id | integer | Identifier |
name | string | Artist name |
mbid | string | MusicBrainz artist identifier |
summary | string | Biography of the artist |
country | string | Country where the artist came from |
tracks | array | Tracks by artist |
{
"id": 1,
"name": "Nirvana",
"mbid": "5b11f4ce-a62d-471e-81fc-a69a8278c7da",
"summary": null,
"country": "US",
"tracks":[
{
"id": 7314,
"track": 1,
"title": "Smells Like Teen Spirit",
"time": 301,
"album":
{
"id": 2,
"label": "Nevermind"
}
},
{
"id": 8775,
"track": 2,
"title": "In Bloom",
"time": 254,
"album":
{
"id": 2,
"label": "Nevermind"
}
}
]
}
GET /server/api/artists/:id
The API returns:
- 200 with artist informations,
- 400 if artist identifier is omitted,
- 401 if authorization token is missing or invalid,
- 404 if artist identifier is unknown.
PUT /server/api/artists/:id
The body request must include artist informations in JSON (id property must be provided, editable properties are: year, name) :
{
"id": 2,
"name": "Nevermind",
"year": 1991
}
The API returns:
- 200 with updated artist informations,
- 400 if artist identifier is omitted or if artist in request body is not valid,
- 401 if authorization token is missing or invalid,
- 403 if requester is not granted to manage library,
- 404 if artist identifier is unknown,
- 500 if there is an error during update process.
DELETE /server/api/artists/:id
The API returns:
- 204 in case of success,
- 400 if artist identifier is omitted,
- 401 if authorization token is missing or invalid,
- 403 if requester is not granted to manage library,
- 500 if there is an error during delete process.