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.
What is rate limiting? If your app makes a lot of Web API requests in a short period of time then it may receive a 429 error response from Spotify. This indicates that your app has reached our Web API rate limit.
Rate Limiting is the process of controlling the number of requests for a resource within a specific time window. Each unique user/IP address/client will have a limitation on the number of requests to an API endpoint.
Click Edit Rate Limit. Select Unimited to allow unrestricted calls to the API, or select Custom Rate Limit to define the required rate limit; use the supplied fields to define the maximum number of calls allowed in a specified time period; for example, 100 calls per 1 minute. Click Submit when done.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With