[GH-ISSUE #123] Recommendation endpoint ignoring seeds #57

Closed
opened 2026-02-27 23:20:37 +03:00 by kerem · 3 comments
Owner

Originally created by @eoinmcc on GitHub (Oct 19, 2016).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/123

It appears that when a list of seeds is provided(genre, artist, track) only the first seed in the array is used by the recommendation api.

It looks like this is as a result of some mismatch between how the requests library unpacks the array as separate params in the GET, and how the Spotify api endpoint expects multiple seeds to be supplied (as a comma separated single param)

Example.... Spotipy's currently implemntation expands to the following request.
https://api.spotify.com/v1/recommendations?seed_artists=3dz0NnIZhtKKeXZxLOxCam&seed_artists=3CjlHNtplJyTf9npxaPl5w

but the response reports on 1 seed where 2 were provided...
u'seeds': [{u'afterFilteringSize': 250, u'href': u'https://api.spotify.com/v1/artists/3dz0NnIZhtKKeXZxLOxCam', u'initialPoolSize': 250, u'type': u'ARTIST', u'id': u'3dz0NnIZhtKKeXZxLOxCam', u'afterRelinkingSize': 250}]

Passing the 2 seeds as a comma seperated param gives us the expected response.
https://api.spotify.com/v1/recommendations?seed_artists=3dz0NnIZhtKKeXZxLOxCam,3CjlHNtplJyTf9npxaPl5w

response reports on 2 seeds...
u'seeds': [{u'afterFilteringSize': 250, u'href': u'https://api.spotify.com/v1/artists/3dz0NnIZhtKKeXZxLOxCam', u'initialPoolSize': 250, u'type': u'ARTIST', u'id': u'3dz0NnIZhtKKeXZxLOxCam', u'afterRelinkingSize': 250}, {u'afterFilteringSize': 250, u'href': u'https://api.spotify.com/v1/artists/3CjlHNtplJyTf9npxaPl5w', u'initialPoolSize': 250, u'type': u'ARTIST', u'id': u'3CjlHNtplJyTf9npxaPl5w', u'afterRelinkingSize': 250}]

I've been working around by supplying the seeds as list with 1 item (i.e. ['3dz0NnIZhtKKeXZxLOxCam,3CjlHNtplJyTf9npxaPl5w'].. This gives me the second result above.

Same is true of genre (and I believe the track) seed params. I believe @mkb218 submitted a pull request for this original.

Happy to take a swing at fix if you'd prefer.

Originally created by @eoinmcc on GitHub (Oct 19, 2016). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/123 It appears that when a list of seeds is provided(genre, artist, track) only the first seed in the array is used by the recommendation api. It looks like this is as a result of some mismatch between how the requests library unpacks the array as separate params in the GET, and how the Spotify api endpoint expects multiple seeds to be supplied (as a comma separated single param) Example.... Spotipy's currently implemntation expands to the following request. https://api.spotify.com/v1/recommendations?seed_artists=3dz0NnIZhtKKeXZxLOxCam&seed_artists=3CjlHNtplJyTf9npxaPl5w but the response reports on 1 seed where 2 were provided... `u'seeds': [{u'afterFilteringSize': 250, u'href': u'https://api.spotify.com/v1/artists/3dz0NnIZhtKKeXZxLOxCam', u'initialPoolSize': 250, u'type': u'ARTIST', u'id': u'3dz0NnIZhtKKeXZxLOxCam', u'afterRelinkingSize': 250}]` Passing the 2 seeds as a comma seperated param gives us the expected response. https://api.spotify.com/v1/recommendations?seed_artists=3dz0NnIZhtKKeXZxLOxCam,3CjlHNtplJyTf9npxaPl5w response reports on 2 seeds... `u'seeds': [{u'afterFilteringSize': 250, u'href': u'https://api.spotify.com/v1/artists/3dz0NnIZhtKKeXZxLOxCam', u'initialPoolSize': 250, u'type': u'ARTIST', u'id': u'3dz0NnIZhtKKeXZxLOxCam', u'afterRelinkingSize': 250}, {u'afterFilteringSize': 250, u'href': u'https://api.spotify.com/v1/artists/3CjlHNtplJyTf9npxaPl5w', u'initialPoolSize': 250, u'type': u'ARTIST', u'id': u'3CjlHNtplJyTf9npxaPl5w', u'afterRelinkingSize': 250}]` I've been working around by supplying the seeds as list with 1 item (i.e. ['3dz0NnIZhtKKeXZxLOxCam,3CjlHNtplJyTf9npxaPl5w'].. This gives me the second result above. Same is true of genre (and I believe the track) seed params. I believe @mkb218 submitted a pull request for this original. Happy to take a swing at fix if you'd prefer.
kerem 2026-02-27 23:20:37 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@ecowan commented on GitHub (Feb 15, 2017):

Has this been addressed? I am still seeing this behavior.

<!-- gh-comment-id:280105430 --> @ecowan commented on GitHub (Feb 15, 2017): Has this been addressed? I am still seeing this behavior.
Author
Owner

@jdormuth commented on GitHub (Dec 24, 2017):

Yes ^^, also still seeing this problem.

<!-- gh-comment-id:353767174 --> @jdormuth commented on GitHub (Dec 24, 2017): Yes ^^, also still seeing this problem.
Author
Owner

@stephanebruckert commented on GitHub (Jan 27, 2021):

Closing since this is 4 years old without updates

<!-- gh-comment-id:768445922 --> @stephanebruckert commented on GitHub (Jan 27, 2021): Closing since this is 4 years old without updates
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#57
No description provided.