Announcements

Now that users can view their recently played tracks in the apps...

Reply

Now that users can view their recently played tracks in the apps...

BloodShura
Regular

Can we list more than 50 of the most recently played tracks of users from our systems, in the API https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-recently-played ?

 

Currently, it allows us to fetch only the 50 most recent tracks. However, since in the apps, users can now view a much higher number of their tracks played in the past, can't this limitation be relaxed in this API?

 

Thanks.

4 Replies

Re: Now that users can view their recently played tracks in the apps...

Hubo
Rock Star 16
Rock Star 16

Hey @BloodShura, thanks for your post here!

 

Hmm, let’s dive into this. Are you able to navigate the list of recently played tracks with the before attribute? That might help get more recently played tracks. Let me know how it goes.

 

Have a great day,

Hubo

HuboRock Star 16
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.

Re: Now that users can view their recently played tracks in the apps...

BloodShura
Regular

Hi Hubo, thank you for your prompt reply!

 

Unfortunately, no -- that's what I expected too. However, after I send an initial request with limit=50, the API responds with the 50 most recent tracks, along with the cursors "after" and "before" to fetch it again. However, by using the cursor "before" with the timestamp returned by the API, no tracks are returned at all.

 

To demonstrate it -- I send the initial request, with no after/before cursors and limit=50:

spotify-1.png

 

Then, the request responds me successfully with the 50 most recently listened tracks, and with the after/before cursors that I could use in the next requests:

spotify-2.png

Then, calling the very same API again, but with the cursor before=1617655258250 (that is, to fetch all tracks played before the timestamp of the last returned track in the first API call):

spotify-3.png

It returns me no tracks at all:

spotify-4.png

 

Also, AFAIR, this has been behavior of this API ever since 2018 -- only 50 tracks are returned at all. However, it would be really great if the API team could relax this limitation, now that this information is freely available in the Spotify clients, as this would enrich API clients with many new possibilities and use cases.

 

Thank you!

Re: Now that users can view their recently played tracks in the apps...

Hubo
Rock Star 16
Rock Star 16
Hey @BloodShura, thanks for your detailed explanation here!

Got it! Thanks for trying this and reporting this back here. The right teams are keeping an eye out on this board and reading the feedback you give to improve the API. Hopefully this limit can be a bit more relaxed.

Could you give me a bit more background around how you'd use this endpoint in your app? That can help the Developer team get a bit more insight into how developers would like to use this.

Thanks again, happy coding,
Hubo
HuboRock Star 16
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.

Re: Now that users can view their recently played tracks in the apps...

BloodShura
Regular

Hubo,


Thank you for your time. I'm really hoping that the API team can have the resources and "permissions" necessary to relax this limit, as that would be beneficial to many API consumers.

 

By increasing the amount of "recently played tracks" we could fetch from users, systems that integrate with the Spotify API could:

 

  • implement a scrobbling-like system with much less overhead, less rate-limited API calls, and also, with less overall impact on Spotify's API;
  • create algorithms to analyze the listening habits of users, considering a much bigger dataset -- 50 last tracks are not sufficient to offer information which would require fetching the played tracks of users along some period, like "which time of the day do you most listen to Spotify?", since people like me (and many others) listen to 50 tracks in a period of like 4-6 hours (if we consider tracks of 4 minutes, then we would have a lower bound of 50x4=200 minutes, just 3.5 hours)
  • analyze listening habits over time, like "how's your mood varying this week?", which would also need to consider a much bigger span of tracks (along days, weeks, etc).

 

Theoretically, a system could already spam Spotify's API calling this "recently-played-tracks" endpoint every 3 hours, for example, and constructing a list with the users recently played tracks (just like scrobbling); but, again, that is not viable, particularly when you have 20,000 monthly active users in your application (my case here).

 

Thank you!

SUGGESTED POSTS