Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

API reference

Noah Hummel edited this page Feb 28, 2017 · 6 revisions

API objects

API objects are bits of json encoded data used by the API. Each API object represents a certain "thing" in the backend, for example a track, artist or album. There is an id associated with every API object, which is used to identify the object uniquely between API, backend and frontend. Each API object has at least the following information:

{ 'id': 123456, 'type': 'some_type', 'follow': '/path/to/object/123456', 'data': { ... } }

Where id is the object unique id and type is the object's type.

follow contains the URL of the API call which returns this object.

data contains any type specific data as listed below.

Gotcha: id may be reused for different types. Make sure to use the right endpoint for accessing the object by it's id.

Gotcha: some nested API objects may not contain data to keep network traffic low. Use the follow URL to obtain the complete object.

Below is a list of all API object types and contained data fields:

track

artist

The artist API object the track is from.

album

The album API object the track is on.

title

A string containing the track title.

album

title

A string containing the album title.

artist

The artist API object the album is from.

artist

name

A string containing the artists name.

Error codes

Whenever an action is performed that might not succeed (registering a user, uploading a track, etc.) an error might be returned by the API. An error is indicated by a json response containing a "success" and a "reason" field. In the case of an error, "success" is set to "false". The "reason" field contains an integer error code. Below is a list of all error codes:

0 - BAD_REQUEST

The request was malformed and couldn't be completed.

1 - INVALID_OBJECT_ID

No object exists with the requested id.

100 - UNAUTHORIZED

The user who is logged in with the given session token isn't authorized to perform the requested action.

101 - BAD_CREDENTIALS

During login: The given user credentials are not valid.

102 - USER_EXISTS

During registration: The username already exists.

200 - TRACK_UNAVAILABLE

During /queue/add: The requested Track is not available for playback.

201 - NOT_IN_QUEUE

During /queue/remove: The requested Track isn't enqueued.

300 - TRACK_EXISTS

During upload: The uploaded track already exists.

301 - PLUGIN_ERROR

During upload: The upload plugin encountered an error and the upload couldn't be completed.

302 - INVALID_PLUGIN

During upload: The given upload plugin doesn't exist on the server.

Endpoints

/tracks

/all

Returns all imported and available tracks.

http parameters:

int: start - - Specifies the id of the first track to be returned. If used, no track with an id lower than start will be returned.

int: amount - - Specifies the amount of tracks to be returned. If left empty, no limit is applied.

/unimported

Returns all tracks that're not fully imported yet.

http parameters:

int: start - - Specifies the id of the first track to be returned. If used, no track with an id lower than start will be returned.

int: amount - - Specifies the amount of tracks to be returned. If left empty, no limit is applied.

/unavailable

Returns all imported but unavailable tracks.

http parameters:

int: start - - Specifies the id of the first track to be returned. If used, no track with an id lower than start will be returned.

int: amount - - Specifies the amount of tracks to be returned. If left empty, no limit is applied.

/album/[int:album_id]

Returns all tracks on the album specified by album_id.

/artist/[int:artist_id]

Returns all tracks by the artist specified by artist_id.

/id/[int:track_id]

Returns the track specified by track_id.

/albums

/all

Returns all albums that have at least one imported and available track.

http parameters:

int: start - - Specifies the id of the first album to be returned. If used, no album with an id lower than start will be returned.

int: amount - - Specifies the amount of albums to be returned. If left empty, no limit is applied.

/artist/[int:artist_id]

Returns all albums by the artist specified by artist_id.

/id/[int:album_id]

Returns the album specified by album_id.

/artists

/all

Returns all artists that have at least one imported and available track.

http parameters:

int: start - - Specifies the id of the first artist to be returned. If used, no artist with an id lower than start will be returned.

int: amount - - Specifies the amount of artists to be returned. If left empty, no limit is applied.

/id/[int:artist_id]

Returns the artist specified by artist_id.

/queue

/items

Returns all tracks that are currently en-queued, excluding the currently playing track.

/current

Returns the track that is currently playing.

/add

http parameters:

int: track_id - - The id of the track to add to the queue

Adds a track to the queue.

/remove

http parameters:

int: track_id - - The id of the track to remove from the queue

Removes a track from the queue.

/auth

/register

http parameters:

int: username - - The new user's username.

int: password - - The new user's password.

int: privilege - - optional The new user's privilege level (0 by default).

Creates a new user with the given credentials.

/login

http parameters:

int: username - - The user's username.

int: password - - The user's password.

Logs the user with the given credentials in. Returns a user token on success, which can be passed as the http parameter "token" in every subsequent API request to indicate that the request was performed by the user associated with the token. The token auto-invalidates, the ttl can be set in the config under "user_ttl".