[GH-ISSUE #375] inconsistent return 'sp.category_playlists' object #220

Closed
opened 2026-02-27 23:21:27 +03:00 by kerem · 2 comments
Owner

Originally created by @camantis on GitHub (May 13, 2019).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/375

Hello,

I'm fairly new to python and the Spotify api, however my efforts to understand (and search for) my current issue have not been successful.

I am trying to retrieve all of the playlists from a given category and so I run the following

#Set up

import spotipy  
import spotipy.oauth2 as oauth2
from spotipy.oauth2 import SpotifyClientCredentials 

client_credentials_manager = SpotifyClientCredentials(client_id=CONSUMER_KEY,
        client_secret=CONSUMER_SECRET)

sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)

#getting category_playlists
sp.category_playlists('category_id', limit = 50) 

However, when I run this line, only a fraction of the playlists are return (e.g., for 'hiphop', 7 out of 47 although I'm experiencing this for every category with > 20 playlists).

playlists{ 'items': [list of playlists]
'limit': 50,
'next': None,
'offset': 0,
'previous': None,
'total': 7}}

I understand that the spotify api uses pagination, but I don't understand why 'next' has a value of None? I included the offset argument and assigned it to 0. What's returned are the 47 playlists (as expected?).

sp.category_playlists('category_id', limit = 50, offset = 0)

playlists{ 'items': [list of playlists]
           'limit': 50,
           'next': None,
           'offset': 0,
           'previous': None,
           'total': 47}}

So it seems to work. However when I re-run the code without any changes, it leads to outputs that alternate between the limited result (7) and the full result (47) with seemingly no pattern. I'm not assigning any variable and I'm getting the same first seven playlists. I have tried modifying the solution for getting tracks shown here but to no luck. Can anyone offer any advice or point me in the right direction?

Thank you

Originally created by @camantis on GitHub (May 13, 2019). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/375 Hello, I'm fairly new to python and the Spotify api, however my efforts to understand (and search for) my current issue have not been successful. I am trying to retrieve all of the playlists from a given category and so I run the following ``` #Set up import spotipy import spotipy.oauth2 as oauth2 from spotipy.oauth2 import SpotifyClientCredentials client_credentials_manager = SpotifyClientCredentials(client_id=CONSUMER_KEY, client_secret=CONSUMER_SECRET) sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager) #getting category_playlists sp.category_playlists('category_id', limit = 50) ``` However, when I run this line, only a fraction of the playlists are return (e.g., for 'hiphop', 7 out of 47 although I'm experiencing this for every category with > 20 playlists). playlists{ 'items': [list of playlists] 'limit': 50, 'next': None, 'offset': 0, 'previous': None, 'total': 7}} I understand that the spotify api uses pagination, but I don't understand why 'next' has a value of None? I included the `offset` argument and assigned it to 0. What's returned are the 47 playlists (as expected?). `sp.category_playlists('category_id', limit = 50, offset = 0) ` playlists{ 'items': [list of playlists] 'limit': 50, 'next': None, 'offset': 0, 'previous': None, 'total': 47}} So it seems to work. However when I re-run the code without any changes, it leads to outputs that alternate between the limited result (7) and the full result (47) with seemingly no pattern. I'm not assigning any variable and I'm getting the same first seven playlists. I have tried modifying the solution for getting tracks shown [here](https://stackoverflow.com/questions/39086287/spotipy-how-to-read-more-than-100-tracks-from-a-playlist) but to no luck. Can anyone offer any advice or point me in the right direction? Thank you
kerem 2026-02-27 23:21:27 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@Garana400 commented on GitHub (Jun 5, 2019):

That's weird, the offset variable is set by default to 0, so it shouldn't make a difference 🤷‍♂️.

<!-- gh-comment-id:499070810 --> @Garana400 commented on GitHub (Jun 5, 2019): That's weird, the `offset` variable is set by default to 0, so it shouldn't make a difference 🤷‍♂️.
Author
Owner

@stephanebruckert commented on GitHub (Feb 22, 2020):

Seems to work, maybe that was a temporary issue on the web-api side.

If this happens again, see if you can reproduce it on https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-get-a-categories-playlists and if that's the case report it here https://github.com/spotify/web-api/

<!-- gh-comment-id:589951713 --> @stephanebruckert commented on GitHub (Feb 22, 2020): Seems to work, maybe that was a temporary issue on the web-api side. If this happens again, see if you can reproduce it on https://developer.spotify.com/documentation/web-api/reference-beta/#endpoint-get-a-categories-playlists and if that's the case report it here https://github.com/spotify/web-api/
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#220
No description provided.