Detect a user's current song in Spotify api

2019-08-05 09:53发布

问题:

I was wondering if it was possible to detect what song a user is listening to from his/her current active device via the spotify web api.

Thanks.

回答1:

I know this is an old question, but there is a new beta API endpoint available that supplies this information. It does have some bugs that I've noticed though.

  • Stations only: If you change stations, you have to restart Spotify to get the API endpoint to update and continue updating.
  • According to bug reports, it lags behind 20 to 30 minutes at random. I haven't had that problem, so it may be fixed.

GET https://api.spotify.com/v1/me/player/currently-playing

Docs: https://developer.spotify.com/web-api/get-the-users-currently-playing-track/



回答2:

This is not possible using the web API. If you're writing a Mac app, you can use the Spotify Desktop Client's AppleScript API to access the current track. If the user is scribbling to Last.fm, you can use Last.fm's APIs. Otherwise, this data is not accessible.



标签: api spotify