[GH-ISSUE #390] How to get all tracks of playlist without user id #231

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

Originally created by @maltejur on GitHub (Jul 18, 2019).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/390

Is there a alternative function to user_playlist_tracks(user, playlist_id) where you just have the playlist id? The new spotify playlist-links aren't giving the user-id anymore.

Originally created by @maltejur on GitHub (Jul 18, 2019). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/390 Is there a alternative function to `user_playlist_tracks(user, playlist_id)` where you just have the playlist id? The new spotify playlist-links aren't giving the user-id anymore.
kerem closed this issue 2026-02-27 23:21:30 +03:00
Author
Owner

@ritiek commented on GitHub (Jul 23, 2019):

Passing user as None seems to work:

>>> playlist_id = "blabla"
>>> sp.user_playlist_tracks(user=None, playlist_id=playlist_id)
<!-- gh-comment-id:514219218 --> @ritiek commented on GitHub (Jul 23, 2019): Passing `user` as `None` seems to work: ```python >>> playlist_id = "blabla" >>> sp.user_playlist_tracks(user=None, playlist_id=playlist_id) ```
Author
Owner

@mw1213 commented on GitHub (Sep 2, 2019):

If you want to get another users' playlist, servers won't let you do that, giving you The HTTP 403 Forbidden error.

Error

Function code (playlist argument is uri to playlist):

def get_a_list_of_tracks(playlist):
    scope='playlist-read-collaborative'
    token = get_token(scope)
    sp = spotipy.Spotify(auth=token)
    result = sp.user_playlist(user=None, playlist_id=playlist)
    ...

def get_token(scope=''):
    token = util.prompt_for_user_token(username, scope, SPOTIPY_CLIENT_ID,
                                       SPOTIPY_CLIENT_SECRET,
                                       SPOTIPY_REDIRECT_URI)
    return token
<!-- gh-comment-id:527121098 --> @mw1213 commented on GitHub (Sep 2, 2019): If you want to get another users' `playlist`, servers won't let you do that, giving you The `HTTP 403 Forbidden` error. ![Error](https://user-images.githubusercontent.com/33518737/64112459-c15eb800-cd87-11e9-8ac1-9354a41411d8.png) Function code (`playlist` argument is uri to playlist): ``` def get_a_list_of_tracks(playlist): scope='playlist-read-collaborative' token = get_token(scope) sp = spotipy.Spotify(auth=token) result = sp.user_playlist(user=None, playlist_id=playlist) ... def get_token(scope=''): token = util.prompt_for_user_token(username, scope, SPOTIPY_CLIENT_ID, SPOTIPY_CLIENT_SECRET, SPOTIPY_REDIRECT_URI) return token ```
Author
Owner

@ritiek commented on GitHub (Sep 2, 2019):

@mw1213 Are you trying to fetch user's starred playlist? That is what it seems like to me from the screenshot. I think Spotify removed starred playlists quite a while ago so I don't know if those are still a thing.

Anyway, I can confirm that passing user=None for usual Spotify playlists works fine. For example, you could pick any spotify playlist from r/spotify and pass the playlist ID to sp.user_playlist or sp.user_playlist_tracks and it works fine. Such as this playlist:
https://open.spotify.com/playlist/3REbQZU8WKDD0h4riXklug?si=ZXm1M-_wSJyyQYKSlufU6Q could be fetched as:

sp.user_playlist(user=None, playlist_id="3REbQZU8WKDD0h4riXklug")
<!-- gh-comment-id:527202296 --> @ritiek commented on GitHub (Sep 2, 2019): @mw1213 Are you trying to fetch user's starred playlist? That is what it seems like to me from the screenshot. I think Spotify removed starred playlists quite a while ago so I don't know if those are still a thing. Anyway, I can confirm that passing `user=None` for usual Spotify playlists works fine. For example, you could pick any spotify playlist from [r/spotify](https://www.reddit.com/r/spotify/) and pass the playlist ID to `sp.user_playlist` or `sp.user_playlist_tracks` and it works fine. Such as this playlist: https://open.spotify.com/playlist/3REbQZU8WKDD0h4riXklug?si=ZXm1M-_wSJyyQYKSlufU6Q could be fetched as: ```python sp.user_playlist(user=None, playlist_id="3REbQZU8WKDD0h4riXklug") ```
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#231
No description provided.