Starting Spotify session via HTTP call

dhess83

Member
Joined
Nov 30, 2024
Messages
7
Hi all,

I'm doing some stuff with Wiim via HTTP calls to the device directly, such as adding and removing sub-devices, controlling playback (previous, play\pause, next, etc).

However, the one thing I -can't- figure out how to do is to start a new spotify session from the device. It seems the only way I can do it is from a spotify client itself. I feel like I'm knocking on the door here, with this command:

Code:
https://10.10.10.254/httpapi.asp?command=setPlayerCmd:play:url
but I can't figure out how to make this work, specifically for Spotify. I'd like to make it work with any of my playlists-- doesn't matter which, as long as it's Spotify. Can anybody offer suggestions here?
 
Have you tried Spotify’s API? I haven’t used it in years, so don’t remember if it offers playback on specific devices.
 
Have you tried Spotify’s API? I haven’t used it in years, so don’t remember if it offers playback on specific devices.
I'm also using this Python-based control for spotify that uses its API:


It also lets me play, pause, resume... even search for tracks or playlists, but only if the Spotify session is already started. If no active session is present, it doesn't do anything. So, I'm in the same boat with this one.

I'm probably missing something simple, I just can't figure out how to do it.
 
I don't have a premium Spotify sub (though I still have a working developer login), but this looks like it ought to work:


I get this response without a premium sub, as expected:

JSON:
{
  "error": {
    "status": 403,
    "message": "Player command failed: Premium required",
    "reason": "PREMIUM_REQUIRED"
  }
}
 
If you have spotify saved as a preset, you can call that preset through the API and it will start the spotify session.
A more roundabout way of tackling this is through the spotcast integration in home assistant. One issue I have with it is that as soon as someone else with a spotify account attaches to one of my players, the existing spotify device ID is destroyed and a new one created. The dev of spotcast hopes to do auto discovery of spotify connect devices in version 5, but I'm not sure what the current status of that is.
 
Back
Top