--- tags: 個人筆記 --- # jyun1 [Search API](https://developer.spotify.com/documentation/web-api/reference/search/search/) |參數 Parameters|必要||範例 |---|---|---|---| |q|**是**|搜尋關鍵字,空白格用`%20`或`+`|[`q=roadhouse%20blues`](https://developer.spotify.com/documentation/web-api/reference/search/search/#writing-a-query---guidelines) |type|**是**|類型,可以填入`album`, `artist`, `track`, `playlist`, `show` and `episode`. |`q=name:abacab&type=album,track` |market|否|使用此參數時,只有在指定國家可以播放的歌手、專輯、音樂會出現在顯示結果。<br>不影響播放清單|台灣國碼:TW |limit|否|顯示結果數量限制:<br>Default: 20 <br>Minimum: 1 <br>Maximum: 50 這個數量是指**每種種類**的數量| |offset|否|**第一個顯示結果**在搜尋結果(感覺是一坨陣列)中的index,搭配limit使用就可以有下一頁的效果。|limit max20,第一頁offset:0,第二頁offset:20..... |include_external|否|可以填入的值只有`audio`,平常的顯示結果會排除相關的外部託管音源,使用這個參數後的顯示結果會包含那些音源| ### 關鍵字查詢 - 對大小寫不敏感 - 如果使用到***運算符***,就要使用大,使用小寫會被當成關鍵字 - 如果使用雙引號,輸入的關鍵字順序會影響結果 - `q=roadhouse&20blues`:Blues Roadhouse跟Roadhouse of the Blues都會出現在結果 - `q="roadhouse&20blues"`:Roadhouse of the Blues會符合,Blues Roadhouse則不會出現在搜尋結果 - 搜尋類型為`Playlist`時,關鍵字會匹配到播放清單的名字、描述。 - 運算符 - NOT:`q=roadhouse%20NOT%20blues` - OR:`q=roadhouse%20OR%20blues`,**一次搜尋只能使用一個OR** - Field filters - 查詢關鍵字時,可以指定此關鍵字是要查詢什麼類型,例如: `q=album:gold%20artist:abba`,顯示結果為「專輯名稱包含gold、歌手名字包含abba」的歌手/專輯/曲目⋯⋯等。如果再加上類型:`type=album`,顯示結果只會有「專輯名稱包含gold、歌手名字包含abba」的**專輯**。<br> 除了專輯、歌手,也有別的filter,可以再參考文件~ ### 回傳格式 - 成功時,各種類型(type)的結果如artist objects、simplified album objects 、track objects、simplified show objects、simplified episode objects,包在一個叫做**paging object**的JSON檔。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up