Allan Raquin
Allan Raquin

Reputation: 613

Error 500 with spotify web-api on POST

## Search for a track (GET) ##

Sometimes, if I make more than 10 requests per second, I get the status code 429: Too Many Requests - Rate limiting has been applied.

So I stay under this limit and it's work fine even if I would love to be able to send more ^^

## Add track to a playlist (POST)

Here I get a strange behavior. When I send less than 1 request/second everything works just fine.
But if I try 2 requests/second, sometimes I get the status code : 500. And more I increase the number of request, more often I get error 500.

I would like to know if the limitrate is fixed to 1 request/second when POST is used ?
But in this case I should get a error 429 right ?



All request made with an Implicit Grant

Upvotes: 0

Views: 384

Answers (1)

Michael Thelin
Michael Thelin

Reputation: 4830

Questions on Stack Overflow is optimised to contain one problem per question, so separate the problems into two threads next time so that they're easier to find for others with the same problem.

Rate limits

Firstly, your assumption regarding 429 (Too Many Requests) is correct - it's the returned status code when your application has reached Spotify's API's rate limit. Importantly, different endpoints count the same, so a request to modify a playlist counts as a single request, and a request to search for artists counts as a single request.

For you and anyone else reading this - we're trying to gather some bits and pieces that might help you to avoid getting rate limited and to handle rate limit responses. You'll find this information in the User Guide's section on rate limiting. For example, a 429 responses also includes a Retry-After header (HTTP RFC) with a value of the number of seconds that your application needs to wait to make another request.

Playlist endpoint issues

Lastly, the issue with 500 responses from the playlist endpoints, especially when modifying them, is known and something that we've tried to remedy for some time without great success. One way to work around this problem is exactly what you're currently doing - to make less frequent requests. If you get an error I urge you to retry, but I'd recommend backing off exponentially.

Upvotes: 1

Related Questions