Hey everyone, I’m having a hard time with the Spotify API. I’m trying to get genre seeds for recommendations, but it’s not working out. Here’s what I’ve tried:
import requests
auth_token = 'my_token_here'
headers = {'Authorization': f'Bearer {auth_token}'}
api_url = 'https://api.spotify.com/v1/recommendations/available-genre-seeds'
response = requests.get(api_url, headers=headers)
print(f'Status: {response.status_code}')
print(f'Response: {response.json()}')
It keeps giving me a 404 error. I’ve checked my token and it works fine for other things like getting my account info and songs from my private playlists. But I can’t get recommendations or audio features. Public playlists are giving me trouble too.
I’ve even tried using curl and wget instead of Python, but no luck. Any ideas what might be going wrong? Thanks for any help!
I’ve encountered similar issues with Spotify’s API before. One thing to check is your API access level. The recommendations endpoint requires a higher tier of access than basic account info or private playlist operations.
Double-check your Developer Dashboard to ensure you have the necessary scopes enabled for your application. Sometimes, even if your token is valid, certain endpoints may be restricted based on your app’s permissions.
Another potential issue could be rate limiting. Spotify has strict limits on API calls, especially for recommendation-related endpoints. Try implementing exponential backoff and retry logic in your requests.
If those don’t solve it, you might want to try regenerating your access token. Occasionally, tokens can become invalid for recommendation endpoints while still working for other API calls.
Lastly, ensure you’re using the correct API version. Spotify occasionally updates their API, and older versions might return 404 errors for certain endpoints.