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.
Please see below the most popular frequently asked questions.
Loading article...
Loading faqs...
Please see below the current ongoing issues which are under investigation.
Loading issue...
Loading ongoing issues...
Plan
Free
Country
Device
All Devices
Operating System
All OS
My Question or Issue
I'm building a web app that will display most popular song for my user base. In Spotify API docs I call Get Recently Played Tracks
It works fine for the first users however when I'm looping to the second (third and so on) I get a 504 error. I've checked Spotify forms and looked for other recommendations but unfortunately I've not seen another way without looping through each users and calling the Get Recently Played Tracks.
I also tried spacing out my calls to Spotify (every 1 min, 5min, etc.) with no luck.
private async Task<SpotifyRecentlyPlayedModel> GetSpotifyRecentlyPlayedData(DateTime afterTime, string AccessToken, long SpotifyUserMappingId) {
long afterTimeTimestamp = new DateTimeOffset(afterTime).ToUnixTimeMilliseconds();
//await Task.Delay(1000);
string requestURI = $"https://api.spotify.com/v1/me/player/recently-played?after={afterTimeTimestamp}";
using (HttpClient client = new())
{
using HttpRequestMessage request = new(HttpMethod.Get, requestURI);
request.Headers.Clear();
request.Headers.Add("ContentType", "application/json");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);
using HttpResponseMessage response = await client.SendAsync(request);
if (response.IsSuccessStatusCode) {
string apiResponse = await response.Content.ReadAsStringAsync();
SpotifyRecentlyPlayedModel result = JsonConvert.DeserializeObject<SpotifyRecentlyPlayedModel>(apiResponse);
return result;
} else {
= await spotifyDataErrorLogRepository.AddAsync(new() {
SpotifyUserMappingId = SpotifyUserMappingId,
ErrorCode = (int)response.StatusCode,
ErrorMessage = response.ReasonPhrase });
}
}
return null;
You'll need the tokens of every user in your user base, and use them in a for each loop.
If your app is still in development mode, it has some limitations.
Thank you for the reply Ximzend.
Currently I'm using tokens for each users and regenerating them if it's older than 50 minutes.
I will try to switch the mode from development mode to see if there is something there that is blocking me.
It's not a simple switch. As you can read on that page, you will need a quota extension if you don't have it already.
I agree it is in depth, I've started the process and hope to complete it soon.
I will let you know after I run a test with live cred if it resolved the issue.
Yeah we have the same issue getting 504s for subsequent calls to fetch recently-played items. We're trying to request a quota extension to see if that fixes it, too.
I'm also getting a 504 error for multiple users when fetching from recently played:
https://github.com/Yooooomi/your_spotify/issues/260
Has anyone resolved this yet?
Just wanted to check if you've made any progress with the application? I'm having the same issue and think it's a bit ridiculous that I have to go through an entire process and wait 6 weeks + just to get my friend's recently played tracks haha.
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…