Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

playlist rate limiting

playlist rate limiting

my app calls the API to get playlists (<1000) and then calls it again to get the tracks and some track features from those playlists, which ends up being around 10000 tracks. is there a better way to do this to avoid rate limiting?

 

playlist_data = []

for result in results:
    for playlist in result['items']:
        time.sleep(1)
        playlist_data.append({
            'name' : playlist['name'],
            'track_ids' : sp.playlist_tracks(playlist['id'], fields='items(track(id))'),
            'track_names' : sp.playlist_tracks(playlist['id'], fields='items(track(name))'),
            'id' : playlist['id'],
            # 'image' : playlist['images'][0].get('url')
        })

playlists = pd.DataFrame(playlist_data)
# playlists.head().style.format({'image': lambda x : f''})
playlists.head()

later I also need to call audio_features for each track, which I'm worried will also cause a rate limiting error. is there a better way to do that? 

Reply
2 Replies

I recommend cutting your request in half by using sp.playlist_tracks(playlist['id'], fields='items(track(id,name))') instead of requesting them separately.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

it's still hanging... but am I right to assume just the one call shouldn't cause a rate limiting issue? there are about 900 playlists.

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random