Subsonic 接口文档
认证
所有请求均需携带以下参数:
参数名 | 是否必填 | 默认值 | 备注 |
---|---|---|---|
u | Y | 用户名 | |
t | Y | 以md5(密码+盐)计算出的身份验证令牌 | |
s | Y | 盐(随机生成,至少6位) | |
v | Y | 客户端实现的协议版本 | |
c | Y | 客户端名称 | |
f | N | xml | 返回格式,可选值: xml , json , jsonp 。 |
示例:
password = 'sesame'
salt = 'c19b2d'
token = md5('sesamec19b2d') = '26719a1196d2a940705a59634eb18eab'
url = 'http://your-server/rest/ping.view?u=joe&t=26719a1196d2a940705a59634eb18eab&s=c19b2d&v=1.12.0&c=myapp'
错误代码
代码 | 备注 |
---|---|
0 | 一般性错误 |
10 | 缺少参数 |
20 | 客户端版本过低 |
30 | 服务端版本过低 |
40 | 用户名或密码错误 |
50 | 无权限 |
60 | Subsonic 试用期已结束 |
70 | 未找到请求的数据 |
示例:
<?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>
请求节点
以下节点中,凡是允许填写多个值的,均为以,
分割的。
因 URL 长度限制,批量处理时最好分批请求。
getAlbumList2 获取专辑列表
请求地址:http://your-server/rest/getAlbumList2
最低版本:1.8.0
参数名 | 是否必填 | 默认值 | 备注 |
---|---|---|---|
type | Y | 排序方式,可选值: random , newest , frequent , recent , starred , alphabeticalByName , alphabeticalByArtist . 特殊值: byYear , byGenre | |
size | N | 10 | 返回结果数量,最大值 500 |
offset | N | 0 | 偏移数量,用于分页获取数据 |
fromYear | Y(type = byYear) | 年代最小值,若 最小值大于最大值,将倒序返回结果 | |
toYear | Y(type = byYear) | 年代最大值 | |
genre | Y(type = byGenre) | 流派 | |
musicFolderId | N |
示例:
<subsonic-response
xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0">
<albumList2>
<album id="1768" name="Duets" coverArt="al-1768" songCount="2" created="2002-11-09T15:44:40" duration="514" artist="Nik Kershaw" artistId="829"/>
<album id="2277" name="Hot" coverArt="al-2277" songCount="4" created="2004-11-28T00:06:52" duration="1110" artist="Melanie B" artistId="1242"/>
<album id="4201" name="Bande A Part" coverArt="al-4201" songCount="14" created="2007-10-29T19:25:05" duration="3061" artist="Nouvelle Vague" artistId="2060"/>
<album id="2910" name="Soundtrack From Twin Peaks" coverArt="al-2910" songCount="6" created="2002-11-17T09:58:42" duration="1802" artist="Angelo Badalamenti" artistId="1515"/>
<album id="3109" name="Wild One" coverArt="al-3109" songCount="38" created="2001-04-17T00:20:08" duration="9282" artist="Thin Lizzy" artistId="661"/>
<album id="1151" name="Perleporten" coverArt="al-1151" songCount="2" created="2002-11-16T22:24:22" duration="494" artist="Magnus Grønneberg" artistId="747"/>
<album id="2204" name="Wholesale Meats And Fish" coverArt="al-2204" songCount="24" created="2004-11-27T23:44:31" duration="5362" artist="Letters To Cleo" artistId="1216"/>
<album id="114" name="Sounds of the Seventies: AM Nuggets" coverArt="al-114" songCount="2" created="2004-03-09T07:32:46" duration="420" artist="Rubettes" artistId="97"/>
<album id="279" name="Waiting for the Day" coverArt="al-279" songCount="2" created="2004-11-27T17:49:19" duration="448" artist="Bachelor Girl" artistId="231"/>
<album id="4414" name="For Sale" songCount="14" created="2007-10-30T00:11:58" duration="2046" artist="The Beatles" artistId="509"/>
</albumList2>
</subsonic-response>
getAlbum 获取专辑信息及音轨列表
请求地址:http://your-server/rest/getAlbum
最低版本:1.8.0
参数名 | 是否必填 | 默认值 | 备注 |
---|---|---|---|
id | Y | 专辑id |
示例:
<subsonic-response
xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0">
<album id="11053" name="High Voltage" coverArt="al-11053" songCount="8" created="2004-11-27T20:23:32" duration="2414" artist="AC/DC" artistId="5432">
<song id="71463" parent="71381" title="The Jack" album="High Voltage" artist="AC/DC" isDir="false" coverArt="71381" created="2004-11-08T23:36:11" duration="352" bitRate="128" size="5624132" suffix="mp3" contentType="audio/mpeg" isVideo="false" path="ACDC/High voltage/ACDC - The Jack.mp3" albumId="11053" artistId="5432" type="music"/>
<song id="71464" parent="71381" title="Tnt" album="High Voltage" artist="AC/DC" isDir="false" coverArt="71381" created="2004-11-08T23:36:11" duration="215" bitRate="128" size="3433798" suffix="mp3" contentType="audio/mpeg" isVideo="false" path="ACDC/High voltage/ACDC - TNT.mp3" albumId="11053" artistId="5432" type="music"/>
<song id="71458" parent="71381" title="It's A Long Way To The Top" album="High Voltage" artist="AC/DC" isDir="false" coverArt="71381" created="2004-11-27T20:23:32" duration="315" bitRate="128" year="1976" genre="Rock" size="5037357" suffix="mp3" contentType="audio/mpeg" isVideo="false" path="ACDC/High voltage/ACDC - It's a long way to the top if you wanna rock 'n 'roll.mp3" albumId="11053" artistId="5432" type="music"/>
<song id="71461" parent="71381" title="Rock 'n' Roll Singer." album="High Voltage" artist="AC/DC" isDir="false" coverArt="71381" created="2004-11-27T20:23:33" duration="303" bitRate="128" track="2" year="1976" genre="Rock" size="4861680" suffix="mp3" contentType="audio/mpeg" isVideo="false" path="ACDC/High voltage/ACDC - Rock N Roll Singer.mp3" albumId="11053" artistId="5432" type="music"/>
<song id="71460" parent="71381" title="Live Wire" album="High Voltage" artist="AC/DC" isDir="false" coverArt="71381" created="2004-11-27T20:23:33" duration="349" bitRate="128" track="4" year="1976" genre="Rock" size="5600206" suffix="mp3" contentType="audio/mpeg" isVideo="false" path="ACDC/High voltage/ACDC - Live Wire.mp3" albumId="11053" artistId="5432" type="music"/>
<song id="71456" parent="71381" title="Can I sit next to you girl" album="High Voltage" artist="AC/DC" isDir="false" coverArt="71381" created="2004-11-27T20:23:32" duration="251" bitRate="128" track="6" year="1976" genre="Rock" size="4028276" suffix="mp3" contentType="audio/mpeg" isVideo="false" path="ACDC/High voltage/ACDC - Can I Sit Next To You Girl.mp3" albumId="11053" artistId="5432" type="music"/>
<song id="71459" parent="71381" title="Little Lover" album="High Voltage" artist="AC/DC" isDir="false" coverArt="71381" created="2004-11-27T20:23:33" duration="339" bitRate="128" track="7" year="1976" genre="Rock" size="5435119" suffix="mp3" contentType="audio/mpeg" isVideo="false" path="ACDC/High voltage/ACDC - Little Lover.mp3" albumId="11053" artistId="5432" type="music"/>
<song id="71462" parent="71381" title="She's Got Balls" album="High Voltage" artist="AC/DC" isDir="false" coverArt="71381" created="2004-11-27T20:23:34" duration="290" bitRate="128" track="8" year="1976" genre="Rock" size="4651866" suffix="mp3" contentType="audio/mpeg" isVideo="false" path="ACDC/High voltage/ACDC - Shes Got Balls.mp3" albumId="11053" artistId="5432" type="music"/>
</album>
</subsonic-response>
getArtist 获取歌手信息及专辑列表
请求地址:http://your-server/rest/getArtist
最低版本:1.8.0
参数名 | 是否必填 | 默认值 | 备注 |
---|---|---|---|
id | Y | 歌手id |
示例:
<subsonic-response
xmlns="http://subsonic.org/restapi" status="ok" version="1.8.0">
<artist id="5432" name="AC/DC" coverArt="ar-5432" albumCount="15">
<album id="11047" name="Back In Black" coverArt="al-11047" songCount="10" created="2004-11-08T23:33:11" duration="2534" artist="AC/DC" artistId="5432"/>
<album id="11048" name="Black Ice" coverArt="al-11048" songCount="15" created="2008-10-30T09:20:52" duration="3332" artist="AC/DC" artistId="5432"/>
<album id="11049" name="Blow up your Video" coverArt="al-11049" songCount="10" created="2004-11-27T19:22:45" duration="2578" artist="AC/DC" artistId="5432"/>
<album id="11050" name="Flick Of The Switch" coverArt="al-11050" songCount="10" created="2004-11-27T19:22:51" duration="2222" artist="AC/DC" artistId="5432"/>
<album id="11051" name="Fly On The Wall" coverArt="al-11051" songCount="10" created="2004-11-27T19:22:57" duration="2405" artist="AC/DC" artistId="5432"/>
<album id="11052" name="For Those About To Rock" coverArt="al-11052" songCount="10" created="2004-11-08T23:35:02" duration="2403" artist="AC/DC" artistId="5432"/>
<album id="11053" name="High Voltage" coverArt="al-11053" songCount="8" created="2004-11-27T20:23:32" duration="2414" artist="AC/DC" artistId="5432"/>
<album id="10489" name="Highway To Hell" coverArt="al-10489" songCount="12" created="2009-06-15T09:41:54" duration="2745" artist="AC/DC" artistId="5432"/>
<album id="11054" name="If You Want Blood..." coverArt="al-11054" songCount="1" created="2004-11-27T20:23:32" duration="304" artist="AC/DC" artistId="5432"/>
<album id="11056" name="Let There Be Rock" coverArt="al-11056" songCount="8" created="2004-11-27T20:33:40" duration="2449" artist="AC/DC" artistId="5432"/>
<album id="11057" name="Live - Special Collector's Edition" coverArt="al-11057" songCount="22" created="2004-11-08T23:37:09" duration="6999" artist="AC/DC" artistId="5432"/>
<album id="11058" name="Powerage" coverArt="al-11058" songCount="9" created="2004-11-27T20:33:41" duration="2380" artist="AC/DC" artistId="5432"/>
<album id="11059" name="Stiff Upper Lip" coverArt="al-11059" songCount="11" created="2004-11-08T23:41:13" duration="2595" artist="AC/DC" artistId="5432"/>
<album id="11060" name="The Razors Edge" coverArt="al-11060" songCount="12" created="2004-11-27T20:33:42" duration="2787" artist="AC/DC" artistId="5432"/>
<album id="11061" name="Who Made Who" coverArt="al-11061" songCount="9" created="2004-11-08T23:43:18" duration="2291" artist="AC/DC" artistId="5432"/>
</artist>
</subsonic-response>
getArtistInfo2 获取歌手简介和相似歌手列表
请求地址:http://your-server/rest/getArtistInfo2
最低版本:1.11.0
参数名 | 是否必填 | 默认值 | 备注 |
---|---|---|---|
id | Y | 歌手id | |
count | N | 相似歌手数量 | |
includeNotPresent | N | 是否返回媒体库不存在的歌手 |
示例:
<subsonic-response
xmlns="http://subsonic.org/restapi" status="ok" version="1.11.0">
<artistInfo2>
<biography>Black Sabbath is an English
<a target='_blank' href="http://www.last.fm/tag/heavy metal" class="bbcode_tag" rel="tag">heavy metal</a> band that formed in 1968 in Birmingham, West Midlands, England, United Kingdom, originally comprising
<a target='_blank' href="http://www.last.fm/music/Ozzy+Osbourne" class="bbcode_artist">Ozzy Osbourne</a> (vocals),
<a target='_blank' href="http://www.last.fm/music/Tony+Iommi" class="bbcode_artist">Tony Iommi</a> (guitar),
<a target='_blank' href="http://www.last.fm/music/Geezer+Butler" class="bbcode_artist">Geezer Butler</a> (bass), and
<a target='_blank' href="http://www.last.fm/music/Bill+Ward" class="bbcode_artist">Bill Ward</a> (drums). In the early
<a target='_blank' href="http://www.last.fm/tag/70s" class="bbcode_tag" rel="tag">70s</a>, they were the first to pair heavily distorted, sonically dissonant
<a target='_blank' href="http://www.last.fm/tag/blues rock" class="bbcode_tag" rel="tag">blues rock</a> at slow speeds with lyrics about drugs, mental pain and abominations of war, thus giving birth to generations of metal bands that followed in their wake.
<a target='_blank' href="http://www.last.fm/music/Black+Sabbath">Read more about Black Sabbath on Last.fm</a>.
</biography>
<musicBrainzId>5182c1d9-c7d2-4dad-afa0-ccfeada921a8</musicBrainzId>
<lastFmUrl>http://www.last.fm/music/Black+Sabbath</lastFmUrl>
<smallImageUrl>http://userserve-ak.last.fm/serve/64/27904353.jpg</smallImageUrl>
<mediumImageUrl>http://userserve-ak.last.fm/serve/126/27904353.jpg</mediumImageUrl>
<largeImageUrl>http://userserve-ak.last.fm/serve/_/27904353/Black+Sabbath+sabbath+1970.jpg</largeImageUrl>
<similarArtist id="279" name="AC/DC" coverArt="ar-279" albumCount="15"/>
<similarArtist id="278" name="Accept" coverArt="ar-278" albumCount="1"/>
<similarArtist id="433" name="Kiss" coverArt="ar-433" albumCount="1"/>
<similarArtist id="372" name="Bruce Dickinson" coverArt="ar-372" albumCount="2"/>
<similarArtist id="290" name="Alice in Chains" coverArt="ar-290" albumCount="3"/>
<similarArtist id="285" name="Aerosmith" coverArt="ar-285" albumCount="2"/>
<similarArtist id="396" name="The Doors" albumCount="1"/>
<similarArtist id="397" name="Guns N' Roses" albumCount="1"/>
</artistInfo2>
</subsonic-response>
getIndexes 获取歌手列表
请求地址:http://your-server/rest/getIndexes
最低版本:1.0.0
参数名 | 是否必填 | 默认值 | 备注 |
---|---|---|---|
musicFolderId | N | ||
ifModifiedSince | N | 返回给定时间之后发生修改的歌手列表,单位:毫秒,自1970.1.1之后的差值 |
示例:
<subsonic-response
xmlns="http://subsonic.org/restapi" status="ok" version="1.10.1">
<indexes lastModified="237462836472342" ignoredArticles="The El La Los Las Le Les">
<shortcut id="11" name="Audio books"/>
<shortcut id="10" name="Podcasts"/>
<index name="A">
<artist id="1" name="ABBA"/>
<artist id="2" name="Alanis Morisette"/>
<artist id="3" name="Alphaville" starred="2013-11-02T12:30:00"/>
</index>
<index name="B">
<artist name="Bob Dylan" id="4"/>
</index>
<child id="111" parent="11" title="Dancing Queen" isDir="false" album="Arrival" artist="ABBA" track="7" year="1978" genre="Pop" coverArt="24" size="8421341" contentType="audio/mpeg" suffix="mp3" duration="146" bitRate="128" path="ABBA/Arrival/Dancing Queen.mp3"/>
<child id="112" parent="11" title="Money, Money, Money" isDir="false" album="Arrival" artist="ABBA" track="7" year="1978" genre="Pop" coverArt="25" size="4910028" contentType="audio/flac" suffix="flac" transcodedContentType="audio/mpeg" transcodedSuffix="mp3" duration="208" bitRate="128" path="ABBA/Arrival/Money, Money, Money.mp3"/>
</indexes>
</subsonic-response>
getCoverArt 封面图片
请求地址:http://your-server/rest/getCoverArt
最低版本:1.0.0
参数名 | 是否必填 | 默认值 | 备注 |
---|---|---|---|
id | Y | 歌曲/专辑/歌手id,其中专辑id应添加前缀 al- ,歌手id应添加前缀 ar- | |
size | N | 图片大小,示例:600 |
createPlaylist 创建或更新歌单名
请求 地址:http://your-server/rest/createPlaylist
最低版本:1.2.0
参数名 | 是否必填 | 默认值 | 备注 |
---|---|---|---|
playlistId | Y(更新时填写) | 歌单id | |
name | Y(创建时填写) | 歌单名 |
早期版本返回空的 <subsonic-response>
, 自 1.14.0 之后会返回创建/更新后的歌单。
deletePlaylist 删除歌单
请求地址:http://your-server/rest/createPlaylist
最低版本:1.2.0
参数名 | 是否必填 | 默认值 | 备注 |
---|---|---|---|
id | Y | 歌单id |
ping 测试服务连通性或登录
请求地址:http://your-server/rest/ping
最低版本:1.0.0
getGenres 获取全部类型
请求地址:http://your-server/rest/getGenres
最低版本:1.9.0
示例:
<subsonic-response
xmlns="http://subsonic.org/restapi" status="ok" version="1.10.2">
<genres>
<genre songCount="28" albumCount="6">Electronic</genre>
<genre songCount="6" albumCount="2">Hard Rock</genre>
<genre songCount="8" albumCount="2">R&B</genre>
<genre songCount="22" albumCount="2">Blues</genre>
<genre songCount="2" albumCount="2">Podcast</genre>
<genre songCount="11" albumCount="1">Brit Pop</genre>
<genre songCount="14" albumCount="1">Live</genre>
</genres>
</subsonic-response>
getLyrics 获取歌词
请求地址:http://your-server/rest/getLyrics
最低版本:1.2.0
参数名 | 是否必填 | 默认值 | 备注 |
---|---|---|---|
artist | N | 歌手名 | |
title | N | 歌曲名 |
示例:
<subsonic-response
xmlns="http://subsonic.org/restapi" status="ok" version="1.2.0">
<lyrics artist="Muse" title="Hysteria"> It's bugging me Grating me And twisting me around Yeah I'm endlessly Caving in And turning inside out Cause I want it now I want it now Give me your heart and your soul And I'm breaking out I'm breaking out That's when she'll lose control It's holding me Morphing me And forcing me to strive To be endlessly Cold within And dreaming I'm alive Cause I want it now I want it now Give me your heart and your soul I'm not breaking down I'm breaking out That's when she'll lose control And I want you now I want you now I'll feel my heart implode And I'm breaking out Escaping now Feeling my faith erode </lyrics>
</subsonic-response>
getPlaylists 获取歌单列表
请求地址:http://your-server/rest/getPlaylists
最低版本:1.0.0
参数名 | 是否必填 | 默认值 | 备注 |
---|---|---|---|
username | N | 获取某个用户名下的歌单列表,使用此参数的用户必须有管理员权限 |
示例:
<subsonic-response
xmlns="http://subsonic.org/restapi" status="ok" version="1.11.0">
<playlists>
<playlist id="15" name="Some random songs" comment="Just something I tossed together" owner="admin" public="false" songCount="6" duration="1391" created="2012-04-17T19:53:44" coverArt="pl-15">
<allowedUser>sindre</allowedUser>
<allowedUser>john</allowedUser>
</playlist>
<playlist id="16" name="More random songs" comment="No comment" owner="admin" public="true" songCount="5" duration="1018" created="2012-04-17T19:55:49" coverArt="pl-16"/>
</playlists>
</subsonic-response>
setRating 评分
请求地址:http://your-server/rest/setRating
最低版本:1.6.0
参数名 | 是否必填 | 默认值 | 备注 |
---|---|---|---|
id | Y | 歌曲/专辑/歌手id | |
rating | Y | 分数,范围:0-5 |