Play a Track Using Spotify Web API

I have the artist, track, and album from LastFM API stored in a widget. I would like to play a 30 second snippet of the song from Spotify when a user clicks play. Is it possible to do this? I'm struggling to find a way.. Especially without user authentication / permissions.

Spotify App API: Play specific track from album

This looks promising, but I'm not sure if it's what I'm talking about...

If someone could point me in the right direction (what API calls to use), that would be great! I can figure out the rest from there.


In the Spotify API documentation I found a link to this github repo that uses the 30-sec API calls to build a web player you can check out here. I believe you want the track API:

preview_url string A link to a 30 second preview (MP3 format) of the track.


You can get the track preview_url from a search response, too.

If you know the artist and track title:

https://api.spotify.com/v1/search?q=artist:Lady+Gaga+title:Bad+Romance&type=track&limit=1

if you know the ISRC:

https://api.spotify.com/v1/search?q=isrc:US2J71103806&type=track

链接地址: http://www.djcxy.com/p/55580.html

上一篇: 使用Spotify SDK关注艺术家

下一篇: 使用Spotify Web API播放曲目