aboutsummaryrefslogtreecommitdiff
path: root/subsonic-site/src/main/webapp/api.jsp
blob: ffcbf0ddb9b361e60a6df39cf31cfd97b45671be (plain)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<%! String current = "api"; %>
<%@ include file="header.jsp" %>

<body>

<a name="top"/>

<div id="container">
<%@ include file="menu.jsp" %>

<div id="content">
<div id="main-col">
<h1>Subsonic API</h1>

<p>
    The Subsonic API allows anyone to build their own programs using Subsonic as the media server, whether they're
    on the web, the desktop or on mobile devices. All the Subsonic <a href="apps.jsp">apps</a> are built using the
    Subsonic API.
</p>
<p>
    Feel free to join the <a href="http://groups.google.com/group/subsonic-app-developers">Subsonic App Developers</a> group
    for discussions, suggestions and questions.
</p>

<h2 class="div">Introduction</h2>

<p>
    The Subsonic API allows you to call methods that respond in <a
        href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a> style xml.
    Individual methods are detailed below.
</p>

<p>
    Please note that all methods take the following parameters:
</p>

<table width="100%" class="bottomspace">
    <tr>
        <th class="param-heading">Parameter</th>
        <th class="param-heading">Required</th>
        <th class="param-heading">Default</th>
        <th class="param-heading">Comment</th>
    </tr>
    <tr class="table-altrow">
        <td><code>u</code></td>
        <td>Yes</td>
        <td></td>
        <td>The username.</td>
    </tr>
    <tr>
        <td><code>p</code></td>
        <td>Yes</td>
        <td></td>
        <td>The password, either in clear text or hex-encoded with a "enc:" prefix.</td>
    </tr>
    <tr class="table-altrow">
        <td><code>v</code></td>
        <td>Yes</td>
        <td></td>
        <td>The protocol version implemented by the client, i.e., the version of the
            <code>subsonic-rest-api.xsd</code> schema used (see below).</td>
    </tr>
    <tr>
        <td><code>c</code></td>
        <td>Yes</td>
        <td></td>
        <td>A unique string identifying the client application.</td>
    </tr>
    <tr class="table-altrow">
        <td><code>f</code></td>
        <td>No</td>
        <td>xml</td>
        <td>Request data to be returned in this format. Supported values are "xml", "json" (since <a href="#versions">1.4.0</a>)
            and "jsonp" (since <a href="#versions">1.6.0</a>). If using jsonp, specify name of javascript callback function using
            a <code>callback</code> parameter.</td>
    </tr>
</table>

<p>
    For example:
</p>

<p>
    <code>http://your-server/rest/getIndexes.view?u=joe&amp;p=sesame&amp;v=1.1.0&amp;c=myapp</code>, or<br/>
    <code>http://your-server/rest/getIndexes.view?u=joe&amp;p=enc:736573616d65&amp;v=1.1.0&amp;c=myapp</code>
</p>

<p>
    Starting with API version <a href="#versions">1.2.0</a> it is no longer necessary to send the username and password as part of the URL.
    Instead, HTTP <a href="http://en.wikipedia.org/wiki/Basic_access_authentication">Basic</a> authentication could be
    used.
    (Only <em>preemptive</em> authentication is supported, meaning that the credentials should be supplied by the client
    without being challenged for it.)
</p>

<p>
    Note that UTF-8 should be used when sending parameters to API methods. The XML returned
    will also be encoded with UTF-8.
</p>

<p>
    All methods (except those that return binary data) returns XML documents conforming to the
    <code>subsonic-rest-api.xsd</code> schema. This schema (as well as example XML documents) can be found
    at <code>http://your-server/xsd/</code>
</p>

<h2 class="div">Error handling</h2>

<p>
    If a method fails it will return an error code and message in an <code>&lt;error&gt;</code> element.
    In addition, the <code>status</code> attribute of the <code>&lt;subsonic-response&gt;</code> root element
    will be set to <code>failed</code> instead of <code>ok</code>. For example:
</p>

            <pre>
   &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;subsonic-response xmlns="http://subsonic.org/restapi"
                      status="failed" version="1.1.0"&gt;
       &lt;error code="40" message="Wrong username or password"/&gt;
   &lt;/subsonic-response&gt;
            </pre>

<p>
    The following error codes are defined:
</p>
<table width="100%" class="bottomspace">
    <tr>
        <th class="param-heading">Code</th>
        <th class="param-heading">Description</th>
    </tr>
    <tr class="table-altrow">
        <td><code>0</code></td>
        <td>A generic error.</td>
    </tr>
    <tr>
        <td><code>10</code></td>
        <td>Required parameter is missing.</td>
    </tr>
    <tr class="table-altrow">
        <td><code>20</code></td>
        <td>Incompatible Subsonic REST protocol version. Client must upgrade.</td>
    </tr>
    <tr>
        <td><code>30</code></td>
        <td>Incompatible Subsonic REST protocol version. Server must upgrade.</td>
    </tr>
    <tr class="table-altrow">
        <td><code>40</code></td>
        <td>Wrong username or password.</td>
    </tr>
    <tr>
        <td><code>50</code></td>
        <td>User is not authorized for the given operation.</td>
    </tr>
    <tr class="table-altrow">
        <td><code>60</code></td>
        <td>The trial period for the Subsonic server is over. Please donate to get a license key. Visit subsonic.org for details.</td>
    </tr>
    <tr>
        <td><code>70</code></td>
        <td>The requested data was not found.</td>
    </tr>
</table>

<h2 class="div"><a name="versions"></a>Versions</h2>

<p>
    This table shows the REST API version implemented in different Subsonic versions:
</p>
<table width="50%" class="bottomspace">
    <tr>
        <th class="param-heading">Subsonic version</th>
        <th class="param-heading">REST API version</th>
    </tr>
    <tr class="table-altrow">
        <td>4.7</td>
        <td>1.8.0</td>
    </tr>
    <tr>
        <td>4.6</td>
        <td>1.7.0</td>
    </tr>
    <tr class="table-altrow">
        <td>4.5</td>
        <td>1.6.0</td>
    </tr>
    <tr>
        <td>4.3.1</td>
        <td>1.5.0</td>
    </tr>
    <tr class="table-altrow">
        <td>4.2</td>
        <td>1.4.0</td>
    </tr>
    <tr>
        <td>4.1</td>
        <td>1.3.0</td>
    </tr>
    <tr class="table-altrow">
        <td>4.0</td>
        <td>1.2.0</td>
    </tr>
    <tr>
        <td>3.9</td>
        <td>1.1.1</td>
    </tr>
    <tr class="table-altrow">
        <td>3.8</td>
        <td>1.0.0</td>
    </tr>
</table>
<p>
    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.
</p>

<h2 class="div">File structure vs ID3 tags</h2>

<p>
    Starting with version <a href="#versions">1.8.0</a>, the API provides methods for accessing the media collection
    organized according to ID3 tags, rather than file structure.
</p>
<p>
    For instance, browsing through the collection using ID3 tags should use the <code>getArtists</code>, <code>getArtist</code>
    and <code>getAlbum</code> methods.
    To browse using file structure you would use <code>getIndexes</code> and <code>getMusicDirectory</code>.
</p>
<p>
    Correspondingly, there are two sets of methods for searching, starring and album lists. Refer to the method
    documentation for details.
</p>

<h1>API method documentation</h1>

<table width="100%" class="bottomspace">
    <tr class="table-altrow">
        <td>System</td>
        <td>
            <code><a href="#ping">ping</a></code>,
            <code><a href="#getLicense">getLicense</a></code>
        </td>
    </tr>
    <tr>
        <td>Browsing</td>
        <td>
            <code><a href="#getMusicFolders">getMusicFolders</a></code>,
            <code><a href="#getIndexes">getIndexes</a></code>,
            <code><a href="#getMusicDirectory">getMusicDirectory</a></code>,
            <code><a href="#getArtists">getArtists</a></code>,
            <code><a href="#getArtist">getArtist</a></code>,
            <code><a href="#getAlbum">getAlbum</a></code>,
            <code><a href="#getSong">getSong</a></code>,
            <code><a href="#getVideos">getVideos</a></code>
        </td>
    </tr>
    <tr class="table-altrow">
        <td>Album/song lists</td>
        <td>
            <code><a href="#getAlbumList">getAlbumList</a></code>,
            <code><a href="#getAlbumList2">getAlbumList2</a></code>,
            <code><a href="#getRandomSongs">getRandomSongs</a></code>,
            <code><a href="#getNowPlaying">getNowPlaying</a></code>,
            <code><a href="#getStarred">getStarred</a></code>,
            <code><a href="#getStarred2">getStarred2</a></code>
        </td>
    </tr>
    <tr>
        <td>Searching</td>
        <td>
            <code><a href="#search">search</a></code>,
            <code><a href="#search2">search2</a></code>,
            <code><a href="#search3">search3</a></code>
        </td>
    </tr>
    <tr class="table-altrow">
        <td>Playlists</td>
        <td>
            <code><a href="#getPlaylists">getPlaylists</a></code>,
            <code><a href="#getPlaylist">getPlaylist</a></code>,
            <code><a href="#createPlaylist">createPlaylist</a></code>,
            <code><a href="#updatePlaylist">updatePlaylist</a></code>,
            <code><a href="#deletePlaylist">deletePlaylist</a></code>
        </td>
    </tr>
    <tr>
        <td>Media retrieval</td>
        <td>
            <code><a href="#stream">stream</a></code>,
            <code><a href="#download">download</a></code>,
            <code><a href="#getCoverArt">getCoverArt</a></code>,
            <code><a href="#getLyrics">getLyrics</a></code>,
            <code><a href="#getAvatar">getAvatar</a></code>
        </td>
    </tr>
    <tr class="table-altrow">
        <td>Media annotation</td>
        <td>
            <code><a href="#star">star</a></code>,
            <code><a href="#unstar">unstar</a></code>,
            <code><a href="#setRating">setRating</a></code>,
            <code><a href="#scrobble">scrobble</a></code>
        </td>
    </tr>
    <tr>
        <td>Sharing</td>
        <td>
            <code><a href="#getShares">getShares</a></code>,
            <code><a href="#createShare">createShare</a></code>,
            <code><a href="#updateShare">updateShare</a></code>,
            <code><a href="#deleteShare">deleteShare</a></code>
        </td>
    </tr>
    <tr class="table-altrow">
        <td>Podcast</td>
        <td>
            <code><a href="#getPodcasts">getPodcasts</a></code>
        </td>
    </tr>
    <tr>
        <td>Jukebox</td>
        <td>
            <code><a href="#jukeboxControl">jukeboxControl</a></code>
        </td>
    </tr>
    <tr class="table-altrow">
        <td>Chat</td>
        <td>
            <code><a href="#getChatMessages">getChatMessages</a></code>,
            <code><a href="#addChatMessage">addChatMessage</a></code>
        </td>
    </tr>
    <tr>
        <td style="white-space: nowrap; padding-right: 0.6em">User management</td>
        <td>
            <code><a href="#getUser">getUser</a></code>,
            <code><a href="#createUser">createUser</a></code>,
            <code><a href="#deleteUser">deleteUser</a></code>,
            <code><a href="#changePassword">changePassword</a></code>
        </td>
    </tr>
</table>

<%@ include file="api-ping.jsp" %>
<%@ include file="api-getLicense.jsp" %>

<%@ include file="api-getMusicFolders.jsp" %>
<%@ include file="api-getIndexes.jsp" %>
<%@ include file="api-getMusicDirectory.jsp" %>
<%@ include file="api-getArtists.jsp" %>
<%@ include file="api-getArtist.jsp" %>
<%@ include file="api-getAlbum.jsp" %>
<%@ include file="api-getSong.jsp" %>
<%@ include file="api-getVideos.jsp" %>

<%@ include file="api-getAlbumList.jsp" %>
<%@ include file="api-getAlbumList2.jsp" %>
<%@ include file="api-getRandomSongs.jsp" %>
<%@ include file="api-getNowPlaying.jsp" %>
<%@ include file="api-getStarred.jsp" %>
<%@ include file="api-getStarred2.jsp" %>

<%@ include file="api-search.jsp" %>
<%@ include file="api-search2.jsp" %>
<%@ include file="api-search3.jsp" %>

<%@ include file="api-getPlaylists.jsp" %>
<%@ include file="api-getPlaylist.jsp" %>
<%@ include file="api-createPlaylist.jsp" %>
<%@ include file="api-updatePlaylist.jsp" %>
<%@ include file="api-deletePlaylist.jsp" %>

<%@ include file="api-stream.jsp" %>
<%@ include file="api-download.jsp" %>
<%@ include file="api-getCoverArt.jsp" %>
<%@ include file="api-getLyrics.jsp" %>
<%@ include file="api-getAvatar.jsp" %>

<%@ include file="api-star.jsp" %>
<%@ include file="api-unstar.jsp" %>
<%@ include file="api-setRating.jsp" %>
<%@ include file="api-scrobble.jsp" %>

<%@ include file="api-getShares.jsp" %>
<%@ include file="api-createShare.jsp" %>
<%@ include file="api-updateShare.jsp" %>
<%@ include file="api-deleteShare.jsp" %>

<%@ include file="api-getPodcasts.jsp" %>

<%@ include file="api-jukeboxControl.jsp" %>

<%@ include file="api-getChatMessages.jsp" %>
<%@ include file="api-addChatMessage.jsp" %>

<%@ include file="api-getUser.jsp" %>
<%@ include file="api-createUser.jsp" %>
<%@ include file="api-deleteUser.jsp" %>
<%@ include file="api-changePassword.jsp" %>

</div>

<div id="side-col">

    <%@ include file="google-translate.jsp" %>
    <%@ include file="donate.jsp" %>
    <%@ include file="merchandise.jsp" %>

</div>

<div class="clear">
</div>
</div>
<hr/>
<%@ include file="footer.jsp" %>
</div>


</body>
</html>