16.06.2022, 08:58
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/ge...e-devices/
Set volume example. You also need device id which can be found here: https://developer.spotify.com/console/ge...e-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)