Using API to play Spotify album?

Hi,

I am new to Volumio, got it successfully running on a Raspberry Pi Zero (sloowww) with Spotify Premium.

I would like to play a full album from Spotify, initiated with a hardware interface using NFC cards.

Example, something like this with 23 tracks: open.spotify.com/album/01JrN7TzqiE7Vs1JNJ3Mkl

How can I do that via REST API or WebSocket? I checked the docs and tried some initial code, but its not working for me.

Thanks
bluepuma

I might add that Spotify is behaving strangely on the Pi.

  1. Featured playlists aren’t playing at all
  2. Personal playlists are not shown
  3. It only plays songs and albums from “What’s new”

Using volumio latest.

No one using Spotify and the API (in this forum)?

Is there another better place to ask?

help-needed-test-spotify-plugin-with-oauth-t10071-10.html
how-get-the-spotify-plugin-working-t12368.html#p63618

For the api part, it is tricky as Spotify is stand alone, and doesn’t use mpd like the rest of Volumio. You might need to dig a litter further into the uri structure that Volumio uses and check if you can coax it to play an album.

Thank you very much for the link! :sunglasses:

I did not realize that my Spotify login wasn’t actually working.

:exclamation: [b]It would be great to have

  1. latest Spotify plugin installable via GUI
  2. indicator if Spotify login was (not) successful[/b]

I worked my way through some Github source code and it seems the REST API can’t handle playing a URI
github.com/volumio/Volumio2/blo … i/index.js

After diving into the WebSocket API I found “replaceAndPlay” in the source which is not listed in the documentation :cry:
volumio.github.io/docs/API/WebSocket_APIs.html
github.com/volumio/Volumio2/blo … t/index.js
github.com/socketio/socket.io-client

I can now play a full Spotify album with a node script :smiley: Strangely I don’t get any messages back :blush:

var socket = require('socket.io-client')('http://volumio.local:3000');
socket.on('connect', function(){
    console.log('connect');
    socket.emit('getDeviceInfo'); // test
    socket.emit('getState', ""); // test
    socket.emit('getQueue', {}); // test
    socket.emit('replaceAndPlay', {"name": "Spotify", "service": "spop", "uri": "spotify:album:7a5U0GPoAvT3gvEY66FRuN"});
    console.log('emitted');
});
socket.on('event', function(data){
    console.log(data);
});
socket.on('message', function(data){
    console.log(data);
});
socket.on('disconnect', function(){
    console.log('disconnect');
});

I am also trying to play a spotifty album using the web API how exactly did you compile and run this command here?

is there a way to do it like this?
volumio.local/api/v1/replaceAndPlay

Hello, have you considered the rest api to manipulate spotify? You can just try this url volumio.local/api/v1/browse?uri= … /playlists, on my setup it works pretty well and you can go forward easily from there.

I struggled a bit with this too, and a quick solution is to add a spotify playlist to queue, and then save the queue to a volumio playlist, then one can trigger the playlist easily with the rest API.

Hope it helps