Logic Machine Forum
Spotify API - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Spotify API (/showthread.php?tid=4092)



Spotify API - FatMax - 16.06.2022

Has anyone tried to make this work with LM/SL?

https://engineering.atspotify.com/2022/04/spotifys-player-api/


RE: Spotify API - admin - 16.06.2022

Go to https://developer.spotify.com/console/ and get your token. Make sure that you have enabled all scopes that you want to use via API.

Set volume example. You also need device id which can be found here: https://developer.spotify.com/console/get-users-available-devices/
Code:
http = require('socket.http')
ltn12 = require('ltn12')
json = require('json')

access_token = 'abcdef'
devid = 'abdec'
volume = 40
url = 'https://api.spotify.com/v1/me/player/volume?volume_percent=' .. volume .. '&device_id=' .. devid

res, code, headers = http.request({
  url = url,
  method = 'PUT',
  headers = {
    ['Authorization'] = 'Bearer ' .. access_token,
    ['Content-Length'] = 0
  }
})

log(res, code, headers)



RE: Spotify API - FatMax - 16.06.2022

Wow, thank you very much!