Announcements

Help Wizard

Step 1

NEXT STEP

Get User Playlists Only Returns Some Playlists

Get User Playlists Only Returns Some Playlists

Plan

Free

Country

 

Device

2017 MacBook Air

Operating System

Big Sur 11.4

 

My Question or Issue

I have a Python script that utilises the `https://api.spotify.com/v1/me/playlists` endpoint. However, the request only returns some of my created playlists and non of my followed playlists. The documentation says it should return all playlists in my library. Also, when I use the 'try it' feature on Spotify's website, it works perfectly fine. I've made sure I have the right scopes, the user ID is correct and even made sure my playlists are public (not that it should matter). Here is my code calling the function:

def getUsersPlaylists(self, offset): 
        headers = {
            "Authorization" : f"Bearer {self.access_token}"
        }
        endpoint = 'https://api.spotify.com/v1/me/playlists?offset=' + str(offset) + '&limit=50'
        return requests.get(endpoint, headers=headers).json()

It should be returning 47 playlists (I have 47 in my library), but it only returns 19 and it doesn't provide a 'next' URL with a next set of playlists either. Thanks to anyone who can help 🙂

 

Reply
7 Replies

Client credentials only work with playlists that are public and are displayed on your/someone's profile.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Thanks for the reply. I  have made sure that the playlists that aren't showing are public. However, they still don't show. What do you mean by 'displayed on your/someone's profile' - how can I ensure this?

Never mind. I figured out what it means by 'displayed on profile'. However, why does it require this? I'm using the 'user-read-private' scope and it works perfectly fine on the 'try me' feature in the Spotify for Developers documentation here: https://developer.spotify.com/documentation/web-api/reference/get-a-list-of-current-users-playlists

To use that scope, you'll need an Access Token generated by your app using the Authorization Code Flow or the Authorization Code with PKCE Flow.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

I'm already using the authorisation flow. Why would it still not be working?

Do you use the required Scopes? If so, I don't have a clue where the problem lies.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

Ahhh I can't believe I made this mistake. I was using the 

user-read-private and playlist-read-collaborative scopes, but not the playlist-read-private scope. Using this scope fixed the problem. Thanks 🙂

Suggested posts

Let's introduce ourselves!

Hey there you,   Yeah, you! 😁   Welcome - we're glad you joined the Spotify Community!   While you here, let's have a fun game and get…

ModeratorStaff / Moderator/ 4 years ago  in Social & Random