If you are researching this topic, you will likely encounter the following tools. Here is an analysis of what they actually do:
If Spotify lags on your PC, disable GPU rendering via the config file: spotify premium pc powershell
$prefsPath = "$env:APPDATA\Spotify\prefs"
Set-Content -Path $prefsPath -Value "ui.hardware_acceleration=false" -Append
$token = 'ACCESS_TOKEN'
$track = Invoke-RestMethod -Method Get -Uri 'https://api.spotify.com/v1/me/player/currently-playing' -Headers @ Authorization = "Bearer $token"
if ($track -and $track.item) ConvertTo-Json