Announcements

"Current User's Recently Played Tracks" before param not working as expected

Reply

"Current User's Recently Played Tracks" before param not working as expected

wittydeveloper
Casual Listener

Hi Spotify Developers!

I am the maintainer of http://github.com/wittydeveloper/spotify-graphql/ client and I am currently implementing a tool using the Spotify API "Current User's Recently Played Tracks" endpoint: https://api.spotify.com/v1/me/player/recently-played

I am willing to navigate the player history using the bidirectional cursors (as written in your doc), here, using the "before" pagination param.
However, anytime I provide a before cursor that goes beyond the last 50 listened to tracks, I get empty responses (no tracks), even when using the "before" cursor of the initial request.


Step to reproduce are the following:

1. perform the following query: "GET https://api.spotify.com/v1/me/player/recently-played?limit=50"
2. perform a second query, using the "next" URL from the previous response: "GET https://api.spotify.com/v1/me/player/recently-played?before=1610564232420&limit=50"

The second query always returns the following response:

{
  "items": [],
  "next": null,
  "cursors": null,
  "limit": 50,
  "href": "https://api.spotify.com/v1/me/player/recently-played?before=1610564232420&limit=50"
}


Am I doing something wrong? My OAuth token has the required `user-read-recently-played` scope.
Is this behavior expected?

Thank you very much! 🙏

 

1 Reply

Re: "Current User's Recently Played Tracks" before param not working as expected

Migwell
Visitor
This endpoint has only ever returned 50 items total. You can use the cursors to paginate within that limit but not outside of it. Possibly they have set up the cursors to support a larger list of favourites eventually, but this isn't yet available.
SUGGESTED POSTS