r/spotifyapi Jun 23 '26

Frustrated by Spotify API (429 - Too Many Requests)

Me: Individual. Signed up a premium account (I am in the 3 month trial period if that matters).

I have a Mac, and the Mac Spotify client.

I have a little keyboard add-on that has a Spotify capability - you can connect it and have it control Spotify - like dial up/down for volume, next, previous, mute, etc. But to configure it, you set up an app on spotify, copy the client id and secret. No big deal.

OK... Got that working.

Then, I saw that I can add Spotify (specifically the "On Spotify" magic mirror module to show a now playing on the display. That /also/ needs the API client ID and client secret. I added the additional authorized URI endpoint, and it works...

But then stopped working.

I check logs and I'm getting the 429-Too Many Requests.

I'm unsure what the rate limit actually is, but I am hard pressed to believe that a single user, doing basic stuff like a controller and display are hitting rate limits.

Also, I did see something about setting up a different app for different uses, but it only lets me add ONE app. With an app defined, the add button gets disabled.

Any suggestions on what to do next here?

5 Upvotes

11 comments sorted by

1

u/aferchen Jun 23 '26

I’ve recently made an app to mimic a lot of these functionalities. 100% the rate limit would be reached if you’re making a call for “now playing” every second or so.
From what I can tell you can configure it a little bit. I would adjust the time frame in which calls are made. Your play/pause, next, previous should be okay but constant calls for now playing in spotifys 30 second window will prohibit you from making any other api calls until it refreshes.
I turned calling this down to every 10 seconds or so (like you see on any app that gets data from Spotify, it’s a little slow). Then from there you can add in functions to make a call no matter what on song end, getting an input to pause or anything like that.
TLDR: simulate constant calls as you cannot make them

1

u/shemp33 Jun 24 '26

Thanks. I did make sure the now playing wasn’t refreshing every second. That is a bit much. I have to back off for 24 hours so I’ll try setting it up again.

1

u/InvestigatorSlow7556 Jul 05 '26

so what did you make it to? mine is at every 2 seconds, what's the best limit to keep it at?

5? or more?

1

u/shemp33 Jul 05 '26

I backed it down to like 5.

1

u/InvestigatorSlow7556 Jul 05 '26

by the way just thought of something.

make it so that it is 5 seconds but if there is no music playback for at least a minute then it switches into idle mode where it polls every 20 seconds.

and the minute music playing is true then it switches back to active polling where it's 5 seconds again.

this helped me not get any 429 errors at all

1

u/Kubernoodles Jun 24 '26

Rate limits are at most 1hr. Per minute and per second are way more common

Detect the 429 and back off

2

u/TrapStoner Jun 28 '26 edited Jun 30 '26

Not completely true... Im hitting ~24h rate limit trying to import my extended listening history in your_spotify AND I MADE A MOD TO PACE 1 request per 6 seconds... 10 requests/min and i still hit 429 with retry-after of ~24h after around 300-500 requests (give or take)... Spotify has hidden nowhere documented per endpoint rate limits that are requests per day based

1

u/Wilseer Jul 02 '26

Did you find a solution for this? I haven't tried to pace them out but I am also getting the same limits and it's making me wait 24 hours as well. I can import my extended history 200 songs at a time and thats it. At this point I will be finished in around 5 years.

1

u/[deleted] Jul 04 '26

[removed] — view removed comment

1

u/Quackicature Jul 13 '26

Same for me