Subsonic API
The Subsonic API allows anyone to build their own programs using Subsonic as the server, whether they're on the web, the desktop or on mobile devices. As an example, the Subsonic Android and iPhone apps are built using the Subsonic API.
Feel free to join the Subsonic App Developers group for discussions, suggestions and questions.
Introduction
The Subsonic API allows you to call methods that respond in REST style xml. Individual methods are detailed below.
Please note that all methods take the following parameters:
| Parameter | Required | Default | Comment |
|---|---|---|---|
u |
Yes | The username. | |
p |
Yes | The password, either in clear text or hex-encoded with a "enc:" prefix. | |
v |
Yes | The protocol version implemented by the client, i.e., the version of the
subsonic-rest-api.xsd schema used (see below).
|
|
c |
Yes | A unique string identifying the client application. |
For example:
http://your-server/rest/getIndexes.view?u=joe&p=sesame&v=1.1.0&c=myapp, or
http://your-server/rest/getIndexes.view?u=joe&p=enc:736573616d65&v=1.1.0&c=myapp
Starting with API version 1.2.0 it is deprecated to send the username and password as part of the URL. Instead, HTTP Basic authentication should be used. (Only preemptive authentication is supported, meaning that the credentials should be supplied by the client without being challenged for it.)
Note that UTF-8 should be used when sending parameters to API methods. The XML returned will also be encoded with UTF-8.
All methods (except those that return binary data) returns XML documents conforming to the
subsonic-rest-api.xsd schema. This schema (as well as example XML documents) can be found
at http://your-server/xsd/
Error handling
If a method fails it will return an error code and message in an <error> element.
In addition, the status attribute of the <subsonic-response> root element
will be set to failed instead of ok. For example:
<?xml version="1.0" encoding="UTF-8"?>
<subsonic-response xmlns="http://subsonic.org/restapi"
status="failed" version="1.1.0">
<error code="40" message="Wrong username or password"/>
</subsonic-response>
The following error codes are defined:
| Code | Description |
|---|---|
0 |
A generic error. |
10 |
Required parameter is missing. |
20 |
Incompatible Subsonic REST protocol version. Client must upgrade. |
30 |
Incompatible Subsonic REST protocol version. Server must upgrade. |
40 |
Wrong username or password. |
50 |
User is not authorized for the given operation. |
60 |
The trial period for the Subsonic server is over. Please donate to get a license key. Visit subsonic.org for details. |
70 |
The requested data was not found. |
Versions
This table shows the REST API version implemented in different Subsonic versions:
| Subsonic version | REST API version |
|---|---|
| 3.8 | 1.0.0 |
| 3.9 | 1.1.1 |
| 4.0 | 1.2.0 |
| 4.1 | 1.3.0 |
Note that a Subsonic server is backward compatible with a REST client if and only if the major version is the same, and the minor version of the client is less than or equal to the server's. For example, if the server has REST API version 2.2, it supports client versions 2.0, 2.1 and 2.2, but not versions 1.x, 2.3+ or 3.x. The third part of the version number is not used to determine compatibility.
ping
http://your-server/rest/ping.view
Since 1.0.0
Used to test connectivity with the server. Takes no extra parameters.
Returns an empty <subsonic-response> element on success.
getLicense
http://your-server/rest/getLicense.view
Since 1.0.0
Get details about the software license. Takes no extra parameters. Please note that access to the REST API requires that the server has a valid license (after a 30-day trial period). To get a license key you can give a donation to the Subsonic project.
Returns a <subsonic-response> element with a nested <license>
element on success.
getMusicFolders
http://your-server/rest/getMusicFolders.view
Since 1.0.0
Returns all configured music folders. Takes no extra parameters.
Returns a <subsonic-response> element with a nested <musicFolders>
element on success.
getNowPlaying
http://your-server/rest/getNowPlaying.view
Since 1.0.0
Returns what is currently being played by all users. Takes no extra parameters.
Returns a <subsonic-response> element with a nested <nowPlaying>
element on success.
getIndexes
http://your-server/rest/getIndexes.view
Since 1.0.0
Returns an indexed structure of all artists.
| Parameter | Required | Default | Comment |
|---|---|---|---|
musicFolderId |
No | If specified, only return artists in the music folder with the given ID. See getMusicFolders.
|
|
ifModifiedSince |
No | If specified, only return a result if the artist collection has changed since the given time. |
Returns a <subsonic-response> element with a nested <indexes>
element on success.
getMusicDirectory
http://your-server/rest/getMusicDirectory.view
Since 1.0.0
Returns a listing of all files in a music directory. Typically used to get list of albums for an artist, or list of songs for an album.
| Parameter | Required | Default | Comment |
|---|---|---|---|
id |
Yes | A string which uniquely identifies the music folder. Obtained by calls to getIndexes or getMusicDirectory. |
Returns a <subsonic-response> element with a nested <directory>
element on success.
search
http://your-server/rest/search.view
Since 1.0.0
Returns a listing of files matching the given search criteria. Supports paging through the result.
| Parameter | Required | Default | Comment |
|---|---|---|---|
artist |
No | Artist to search for. | |
album |
No | Album to searh for. | |
title |
No | Song title to search for. | |
any |
No | Searches all fields. | |
count |
No | 20 | Maximum number of results to return. |
offset |
No | 0 | Search result offset. Used for paging. |
newerThan |
No | Only return matches that are newer than this. Given as milliseconds since 1970. |
Returns a <subsonic-response> element with a nested <searchResult>
element on success.
getPlaylists
http://your-server/rest/getPlaylists.view
Since 1.0.0
Returns the ID and name of all saved playlists.
Returns a <subsonic-response> element with a nested <playlists>
element on success.
getPlaylist
http://your-server/rest/getPlaylist.view
Since 1.0.0
Returns a listing of files in a saved playlist.
| Parameter | Required | Default | Comment |
|---|---|---|---|
id |
yes | ID of the playlist to return, as obtained by getPlaylists. |
Returns a <subsonic-response> element with a nested <playlist>
element on success.
createPlaylist
http://your-server/rest/createPlaylist.view
Since 1.2.0
Creates or updates a saved playlist. Note: The user must be authorized to create playlists (see Settings > Users > User is allowed to create and delete playlists).
| Parameter | Required | Default | Comment |
|---|---|---|---|
playlistId |
Yes (if updating) | The playlist ID. | |
name |
Yes (if creating) | The human-readable name of the playlist. | |
songId |
Yes | ID of a song in the playlist. Use one songId parameter for each song in the playlist. |
Returns an empty <subsonic-response> element on success.
deletePlaylist
http://your-server/rest/deletePlaylist.view
Since 1.2.0
Deletes a saved playlist.
| Parameter | Required | Default | Comment |
|---|---|---|---|
id |
yes | ID of the playlist to delete, as obtained by getPlaylists. |
Returns an empty <subsonic-response> element on success.
download
http://your-server/rest/download.view
Since 1.0.0
Downloads a given music file.
| Parameter | Required | Default | Comment |
|---|---|---|---|
id |
Yes | A string which uniquely identifies the file to download. Obtained by calls to getMusicDirectory. |
Returns binary data on success, or an XML document on error (in which case the HTTP content type will start with "text/xml").
stream
http://your-server/rest/stream.view
Since 1.0.0
Streams a given music file.
| Parameter | Required | Default | Comment |
|---|---|---|---|
id |
Yes | A string which uniquely identifies the file to stream. Obtained by calls to getMusicDirectory. | |
maxBitRate |
No | (Since 1.2.0) If specified, the server will attempt to limit the bitrate to this value, in kilobits per second. If set to zero, no limit is imposed. Legal values are: 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320. |
Returns binary data on success, or an XML document on error (in which case the HTTP content type will start with "text/xml").
getCoverArt
http://your-server/rest/getCoverArt.view
Since 1.0.0
Returns a cover art image.
| Parameter | Required | Default | Comment |
|---|---|---|---|
id |
Yes | A string which uniquely identifies the cover art file to download. Obtained by calls to getMusicDirectory. | |
size |
No | If specified, scale image to this size. |
Returns binary data on success, or an XML document on error (in which case the HTTP content type will start with "text/xml").
changePassword
http://your-server/rest/changePassword.view
Since 1.1.0
Changes the password of an existing Subsonic user, using the following parameters. You can only change your own password unless you have admin privileges.
| Parameter | Required | Default | Comment |
|---|---|---|---|
username |
Yes | The name of the user which should change its password. | |
password |
Yes | The new password of the new user, either in clear text of hex-encoded (see above). |
Returns an empty <subsonic-response> element on success.
getUser
http://your-server/rest/getUser.view
Since 1.3.0
Get details about a given user, including which authorization roles it has. Can be used to enable/disable certain features in the client, such as jukebox control.
| Parameter | Required | Default | Comment |
|---|---|---|---|
username |
Yes | The name of the user to retrieve. You can only retrieve your own user unless you have admin privileges. |
Returns a <subsonic-response> element with a nested <user>
element on success.
createUser
http://your-server/rest/createUser.view
Since 1.1.0
Creates a new Subsonic user, using the following parameters:
| Parameter | Required | Default | Comment |
|---|---|---|---|
username |
Yes | The name of the new user. | |
password |
Yes | The password of the new user, either in clear text of hex-encoded (see above). | |
ldapAuthenticated |
No | false | Whether the user is authenicated in LDAP. |
adminRole |
No | false | Whether the user is administrator. |
settingsRole |
No | true | Whether the user is allowed to change settings and password. |
streamRole |
No | true | Whether the user is allowed to play files. |
jukeboxRole |
No | false | Whether the user is allowed to play files in jukebox mode. |
downloadRole |
No | false | Whether the user is allowed to download files. |
uploadRole |
No | false | Whether the user is allowed to upload files. |
playlistRole |
No | false | Whether the user is allowed to create and delete playlists. |
coverArtRole |
No | false | Whether the user is allowed to change cover art and tags. |
commentRole |
No | false | Whether the user is allowed to create and edit comments and ratings. |
podcastRole |
No | false | Whether the user is allowed to administrate Podcasts. |
Returns an empty <subsonic-response> element on success.
deleteUser
http://your-server/rest/deleteUser.view
Since 1.3.0
Deletes an existing Subsonic user, using the following parameters:
| Parameter | Required | Default | Comment |
|---|---|---|---|
username |
Yes | The name of the user to delete. |
Returns an empty <subsonic-response> element on success.
getChatMessages
http://your-server/rest/getChatMessages.view
Since 1.2.0
Returns the current visible (non-expired) chat messages.
| Parameter | Required | Default | Comment |
|---|---|---|---|
since |
No | Only return messages newer than this time (in millis since Jan 1 1970). |
Returns a <subsonic-response> element with a nested <chatMessages>
element on success.
addChatMessage
http://your-server/rest/addChatMessage.view
Since 1.2.0
Adds a message to the chat log.
| Parameter | Required | Default | Comment |
|---|---|---|---|
message |
Yes | The chat message. |
Returns an empty <subsonic-response> element on success.
getAlbumList
http://your-server/rest/getAlbumList.view
Since 1.2.0
Returns a list of random, newest, highest rated etc. albums. Similar to the album lists on the home page of the Subsonic web interface.
| Parameter | Required | Default | Comment |
|---|---|---|---|
type |
Yes | The list type. Must be one of the following: random, newest,
highest, frequent, recent.
|
|
size |
No | 10 | The number of albums to return. Max 500. |
offset |
No | 0 | The list offset. Useful if you for example want to page through the list of newest albums. Max 5000. |
Returns a <subsonic-response> element with a nested <albumList>
element on success.
getRandomSongs
http://your-server/rest/getRandomSongs.view
Since 1.2.0
Returns random songs matching the given criteria.
| Parameter | Required | Default | Comment |
|---|---|---|---|
size |
No | 10 | The maximum number of songs to return. Max 500. |
genre |
No | Only returns songs belonging to this genre. | |
fromYear |
No | Only return songs published after or in this year. | |
toYear |
No | Only return songs published before or in this year. | |
musicFolderId |
No | Only return songs in the music folder with the given ID. See getMusicFolders. |
Returns a <subsonic-response> element with a nested <randomSongs>
element on success.
getLyrics
http://your-server/rest/getLyrics.view
Since 1.2.0
Searches for and returns lyrics for a given song.
| Parameter | Required | Default | Comment |
|---|---|---|---|
artist |
No | The artist name. | |
title |
No | The song title. |
Returns a <subsonic-response> element with a nested <lyrics>
element on success. The <lyrics> element is empty if no matching lyrics was found.
jukeboxControl
http://your-server/rest/jukeboxControl.view
Since 1.2.0
Controls the jukebox, i.e., playback directly on the server's audio hardware. Note: The user must be authorized to control the jukebox (see Settings > Users > User is allowed to play files in jukebox mode).
| Parameter | Required | Default | Comment |
|---|---|---|---|
action |
Yes | The operation to perform. Must be one of: get, start, stop,
skip, add, clear, remove, shuffle, setGain
|
|
index |
No | Used by skip and remove. Zero-based index of the song to skip to or remove. |
|
id |
No | Used by add. ID of song to add to the jukebox playlist. Use multiple id parameters
to add many songs in the same request.
|
|
gain |
No | Used by setGain to control the playback volume. A float value between 0.0 and 1.0. |
Returns an empty <subsonic-response> element on success, unless the get
action is used, in which case a nested <jukeboxPlaylist> element is returned.
Donate
Love Subsonic? Support continued development and maintenance by giving a donation.
Donors get access to premium features like:
- Unlimited use of Subsonic apps for iPhone, Android and AIR.
- Your personal server address: yourname.subsonic.org
- No ads in the web interface.
The suggested donation amount is €20, but you can give any amount you like. €10, €15, €20, €25, €30

