I'd like to retrieve the follower count of my Spotify playlist using Python. I've been searching https://developer.spotify.com/documentation/web-api/reference-beta/#category-playlists but haven't found a way to do so yet. However, I found a working code on how to retrieve the track IDs of a playlist, how could I tweak it to get the followers instead?
def getTrackIDs(user, playlist_id):
ids = []
playlist = sp.user_playlist(user, playlist_id)
for item in playlist['tracks']['items']:
track = item['track']
ids.append(track['id'])
return ids
ids = getTrackIDs('User', 'Playlist_Id')
print(len(ids))
print(ids)
Take a look at the playlist object that should be returned by getting a playlist.
It has the
followers
property which is a followers object which is located hereThe followers object contains the
total
property, which should be what you are looking for.Although I cannot run your code, I imagine the result should look like the following. Let me know if this works for you (I can't run the code).