<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Getting several tracks audio features returning error 429 in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/Getting-several-tracks-audio-features-returning-error-429/m-p/6330968#M15006</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I'm working on a web app, I code in &lt;STRONG&gt;Python&lt;/STRONG&gt; and using &lt;STRONG&gt;Spotipy&lt;/STRONG&gt;. I want to build a large datasets for my saved tracks that retrieves different track features. For that I'm using the audio_features as well. When going through my code line, it returns error code 429 (max retries achieved). I even tried to create a new spotify app and try with new credentials but still. Here's my code below for reference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def build_saved_tracks_dataset(limit_step=50):
    user = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id='client_id',
                                                     client_secret='client_secret',
                                                     redirect_uri='http://localhost:8080',
                                                     scope='user-library-read'))
    

    tracks = list()
    offset = 0
    while True:
        response = user.current_user_saved_tracks(limit=limit_step,
                                                            offset=offset)
        if len(response['items']) == 0:
            break
        offset += limit_step
        
        track_ids = [item['track']['id'] for item in response['items']]
        artists_id = [item['track']['artists'][0]['id'] for item in response['items']]

        audio_features = user.audio_features(track_ids)
        artists = user.artists(artists_id)
        
        
        for track, artist, audio_feature in zip(response['items']['track'], artists, audio_features):
            genres = ','.join(genre for genre in artist[0]['genres'])
            # tracks.append(id, name, artist, tempo...) Populating my dataset
            pass

    return tracks&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that if I delete the audio_features line and ll he parameters in the dict that comes with it, the code works, so its weird that the limitation is only applied to audio_features.&lt;BR /&gt;&lt;BR /&gt;I gave it 24 hours before trying again and same&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Any idea on how to resolve this ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks !&lt;/P&gt;</description>
    <pubDate>Tue, 10 Sep 2024 16:12:20 GMT</pubDate>
    <dc:creator>ThamiFromDoukala</dc:creator>
    <dc:date>2024-09-10T16:12:20Z</dc:date>
    <item>
      <title>Getting several tracks audio features returning error 429</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Getting-several-tracks-audio-features-returning-error-429/m-p/6330968#M15006</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I'm working on a web app, I code in &lt;STRONG&gt;Python&lt;/STRONG&gt; and using &lt;STRONG&gt;Spotipy&lt;/STRONG&gt;. I want to build a large datasets for my saved tracks that retrieves different track features. For that I'm using the audio_features as well. When going through my code line, it returns error code 429 (max retries achieved). I even tried to create a new spotify app and try with new credentials but still. Here's my code below for reference.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def build_saved_tracks_dataset(limit_step=50):
    user = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id='client_id',
                                                     client_secret='client_secret',
                                                     redirect_uri='http://localhost:8080',
                                                     scope='user-library-read'))
    

    tracks = list()
    offset = 0
    while True:
        response = user.current_user_saved_tracks(limit=limit_step,
                                                            offset=offset)
        if len(response['items']) == 0:
            break
        offset += limit_step
        
        track_ids = [item['track']['id'] for item in response['items']]
        artists_id = [item['track']['artists'][0]['id'] for item in response['items']]

        audio_features = user.audio_features(track_ids)
        artists = user.artists(artists_id)
        
        
        for track, artist, audio_feature in zip(response['items']['track'], artists, audio_features):
            genres = ','.join(genre for genre in artist[0]['genres'])
            # tracks.append(id, name, artist, tempo...) Populating my dataset
            pass

    return tracks&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note that if I delete the audio_features line and ll he parameters in the dict that comes with it, the code works, so its weird that the limitation is only applied to audio_features.&lt;BR /&gt;&lt;BR /&gt;I gave it 24 hours before trying again and same&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Any idea on how to resolve this ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks !&lt;/P&gt;</description>
      <pubDate>Tue, 10 Sep 2024 16:12:20 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Getting-several-tracks-audio-features-returning-error-429/m-p/6330968#M15006</guid>
      <dc:creator>ThamiFromDoukala</dc:creator>
      <dc:date>2024-09-10T16:12:20Z</dc:date>
    </item>
  </channel>
</rss>

