[GH-ISSUE #798] Argument parameters of playlist_items() are non functional #493

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

Originally created by @djsamyak on GitHub (Apr 29, 2022).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/798

Describe the bug
I am trying to fetch the names of all the tracks in a playlist using a playlist URI by using playlist_items(). This function has the following parameters:

  • playlist_id,
  • fields=None,
  • limit=100,
  • offset=0,
  • market=None,
  • additional_types=('track', 'episode')

However, due to the original limit of 100 items, the API fails to fetch any more results when the number of tracks in a playlist is greater than 100; it only fetches the details of the first 100 tracks. Passing a custom value to the limit or offset parameter also doesn't work.

Your code

import spotipy
from spotipy.oauth2 import SpotifyClientCredentials

playlist_uri = '5z5kiTiHO85L6ERjm32jQ7?si=2582f978e1484627'

spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials("SPOTIPY_CLIENT_ID",'SPOTIPY_CLIENT_SECRET'))
playlist_details = spotify.playlist_items(playlist_uri,limit=500)

print(playlist_details['name'])
print(len(playlist_details['tracks']['items']))

Expected behaviour
It should print the playlist name, and then print the number of tracks in that playlist in the next line.
For the above-mentioned playlist URI, it should print the following:

Morning Mood 2022
113

Output
It prints the following:

Morning Mood 2022
100

Environment:

  • OS: Microsoft Windows 11 Home (10.0.22000 N/A Build 22000)
  • Python version: 3.8.3 64-bit
  • Spotipy version: 2.19.0
  • IDE: VS Code with Jupyter Notebook extension, Google Colab

Additional context
Making changes in source code's client.py to modify the default limit has not solved the issue.

Originally created by @djsamyak on GitHub (Apr 29, 2022). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/798 **Describe the bug** I am trying to fetch the names of all the tracks in a playlist using a playlist URI by using playlist_items(). This function has the following parameters: - `playlist_id`, - `fields=None`, - `limit=100`, - `offset=0`, - `market=None`, - `additional_types=('track', 'episode')` However, due to the original limit of 100 items, the API fails to fetch any more results when the number of tracks in a playlist is greater than 100; it only fetches the details of the first 100 tracks. Passing a custom value to the `limit` or `offset` parameter also doesn't work. **Your code** ``` import spotipy from spotipy.oauth2 import SpotifyClientCredentials playlist_uri = '5z5kiTiHO85L6ERjm32jQ7?si=2582f978e1484627' spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials("SPOTIPY_CLIENT_ID",'SPOTIPY_CLIENT_SECRET')) playlist_details = spotify.playlist_items(playlist_uri,limit=500) print(playlist_details['name']) print(len(playlist_details['tracks']['items'])) ``` **Expected behaviour** It should print the playlist name, and then print the number of tracks in that playlist in the next line. For the above-mentioned playlist URI, it should print the following: ``` Morning Mood 2022 113 ``` **Output** It prints the following: ``` Morning Mood 2022 100 ``` **Environment:** - OS: Microsoft Windows 11 Home (10.0.22000 N/A Build 22000) - Python version: 3.8.3 64-bit - Spotipy version: 2.19.0 - IDE: VS Code with Jupyter Notebook extension, Google Colab **Additional context** Making changes in source code's `client.py` to modify the default limit has not solved the issue.
kerem 2026-02-27 23:22:56 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@Peter-Schorn commented on GitHub (Apr 30, 2022):

The issue is that your playlist_uri variable contains a malformed id (not even a uri). The id is 5z5kiTiHO85L6ERjm32jQ7. The uri would be spotify:playlist:5z5kiTiHO85L6ERjm32jQ7. You should pass either of these two into the function. ?si=2582f978e1484627 is not part of any identifier.

When you pass the malformed id into the function, spotipy ends up calling a different endpoint, which does not contain offset or limit parameters.

see https://github.com/plamere/spotipy/issues/763#issuecomment-1003441199.

<!-- gh-comment-id:1114052564 --> @Peter-Schorn commented on GitHub (Apr 30, 2022): The issue is that your `playlist_uri` variable contains a malformed id (not even a uri). The id is `5z5kiTiHO85L6ERjm32jQ7`. The uri would be `spotify:playlist:5z5kiTiHO85L6ERjm32jQ7`. You should pass either of these two into the function. `?si=2582f978e1484627` is not part of any identifier. When you pass the malformed id into the function, spotipy ends up calling a *different* endpoint, which does not contain `offset` or `limit` parameters. see https://github.com/plamere/spotipy/issues/763#issuecomment-1003441199.
Author
Owner

@djsamyak commented on GitHub (May 21, 2022):

Ah, that makes sense. I was not able to find the Spotify URI due to the new update, but if someone else is stuck, you can hold down the modifier key (alt/command) while in the share menu.

<!-- gh-comment-id:1133510795 --> @djsamyak commented on GitHub (May 21, 2022): Ah, that makes sense. I was not able to find the Spotify URI due to the new update, but if someone else is stuck, you can hold down the modifier key (alt/command) while in the share menu.
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#493
No description provided.