Type in your question below and we'll check to see what answers we can find...
Loading article...
Submitting...
If you couldn't find any answers in the previous step then we need to post your question in the community and wait for someone to respond. You'll be notified when that happens.
Simply add some detail to your question and refine the title if needed, choose the relevant category, then post.
Before we can post your question we need you to quickly make an account (or sign in if you already have one).
Don't worry - it's quick and painless! Just click below, and once you're logged in we'll bring you right back here and post your question. We'll remember what you've already typed in so you won't have to do it again.
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! 🙏
@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?
Hello,
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 = datetime.now()
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(
"https://api.spotify.com/v1/me/player/recently-played?after={time}".format(time=yesterday_unix_timestamp),
headers = header1)
#After :
today = datetime.now()
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(
"https://api.spotify.com/v1/me/player/recently-played?after={time}".format(time=last_5_days_unix_timestamp),
headers = header1)
I hope it will help you get the result.
@charlypoly
Thank you.
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…