有没有办法使用Spotify的API获取当前播放时间

时间:2019-10-18 20:04:15

标签: node.js api express spotify

我正在制作一个网络应用程序,将我的Spotify播客片段嵌入其中。播放了一定数量的秒后,我需要在网站上进行某些操作。是否可以使用API​​获取播放时间?

1 个答案:

答案 0 :(得分:1)

使用

/v1/me/player/currently-playing

返回progress_ms


示例:

请求

curl -X GET "https://api.spotify.com/v1/me/player/currently-playing" -H "Authorization: Bearer {your access token}"

回复

{
  "context": {
    "external_urls" : {
      "spotify" : "http://open.spotify.com/user/spotify/playlist/49znshcYJROspEqBoHg3Sv"
    },
    "href" : "https://api.spotify.com/v1/users/spotify/playlists/49znshcYJROspEqBoHg3Sv",
    "type" : "playlist",
    "uri" : "spotify:user:spotify:playlist:49znshcYJROspEqBoHg3Sv"
  },
  "timestamp": 1490252122574,
  "progress_ms": 44272, <------
  ...

还要考虑到此API是Beta版,可能会随时更改,恕不另行通知。 (或存在功能或性能问题)

API文档为herehere

相关问题