spotify api examples
Example 1: spotify api python
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
birdy_uri = 'spotify:artist:2WX2uTcsvV5OnS0inACecP'
spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
results = spotify.artist_albums(birdy_uri, album_type='album')
albums = results['items']
while results['next']:
results = spotify.next(results)
albums.extend(results['items'])
for album in albums:
print(album['name'])
Example 2: spotify api
import spotipy
import spotipy as spotipy
from spotipy.oauth2 import SpotifyOAuth
from pprint import pprint
from time import sleep
scope = "user-read-playback-state,user-modify-playback-state"
sp = spotipy.Spotify(client_credentials_manager=SpotifyOAuth(client_id="CLIENT_ID GET FROM SPOTIFY DASHBOARD",
client_secret="SECRET_CLIENT_ID",
redirect_uri="https://developer.spotify.com/",
scope='user-read-playback-state,user-modify-playback-state'))
float
# Shows playing devices
res = sp.devices()
pprint(res)
# Change track
sp.start_playback(uris=['spotify:track:0HUTL8i4y4MiGCPId7M7wb'])