Help Wizard

Step 1



Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...


Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...


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

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

Hi Spotify Developers!

I am the maintainer of client and I am currently implementing a tool using the Spotify API "Current User's Recently Played Tracks" endpoint:

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"
2. perform a second query, using the "next" URL from the previous response: "GET"

The second query always returns the following response:

  "items": [],
  "next": null,
  "cursors": null,
  "limit": 50,
  "href": ""

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

Thank you very much! 🙏


3 Replies

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.

@wittydeveloper I recently found this limitation as well. I think this is a substantial deficiency in Spotify. Also, there is no value that shows when a track was last played (i.e., timestamp). I think the latter would solve the former. Is there a way to submit a feature request?


I was also facing the same error but after some studies, I found out that I haven't played any songs
yesterday for which day I was requesting the data. I hope you have done the same mistake.
So instead of the last 1 day, I set it to last 5 days, and now I'
m able to get the results.
I'm sharing my timestamp code here, so you might get a rough idea. 

# Before ( last 1 day timestamp) : 
today =
yesterday = today - timedelta(days=1) # 1 for yesterday's result.
yesterday_unix_timestamp = int(yesterday.timestamp()) * 1000

# Download all songs you've listened to "after yesterday", which means in the last 24 hours
r = requests.get(
headers = header1)
#After : 
today =
last_5_days = today - timedelta(days=5)
last_5_days_unix_timestamp = int(last_5_days.timestamp()) * 1000

# Download all songs you've listened to last 5 days, which means in the last 5 days
r = requests.get(
headers = header1)

I hope it will help you get the result. 


Thank you.

Suggested posts