Spotify Web API rate limits

Larry Person picture Larry Person · May 30, 2015 · Viewed 28.7k times · Source

The spotify web API documentation mentions rate limits. For example, the authorization guide says this:

Only endpoints that do not access user information can be accessed. Its advantage is that a higher rate limit is applied compared with requests to the Web API made without an access token.

Are rate limits something I, as a developer, need to worry about? Will requests to the web API fail if I exceed my rate limit, and if so, what would the failure look like?

Thanks in advance.

Answer

Michael Thelin picture Michael Thelin · May 31, 2015

You'll find some general information about rate limiting in the User Guide. As described under Status codes, the Web API will return HTTP status code 429 (Too Many Requests) if your application makes more requests than the rate limit allowed.

If this happens, you should wait a while (see update below) before making requests again. Of course, the best thing to do is to try to avoid reaching the rate limit in the first place. As the User guide suggests, you can do this by for example accessing multiple entities at once which is available for some endpoints. You could also cache responses.

Update: If you're rate limited, the HTTP response will include a header named 'Retry-After'. The value of this header is the amount of seconds you need to wait until making the next request. For example, Retry-After: 4 means that you need to wait four seconds before trying again. This is now also mentioned in the Web API User Guide.