Search code examples
pythonspotifyspotipy

get the name of a track from its id in spotipy


I have found lots of methods to get the id of a Spotify track but I haven't managed to find a method where I can get the name of one, couldn't find anything in the docs, or I'm just looking in the wrong place. Can anyone help?


Solution

  • The track() function returns all kinds of information about a track in JSON format. To access the name, simply do something like:

    track = 'spotify:track:0Svkvt5I79wficMFgqEQJ'
    track = sp.track(track)
    
    print(track["name"])