Rate Limiting
Learn about Switch API rate limits, how to avoid exceeding them, and what to do if you do exceed them.
About rate limits
To ensure that the API remains available for all users, and help prevent abuse and denial-of-service attacks, Switch limits the number of API requests that you can make within a specific amount of time.
Not all endpoints of the Switch API apply rate limits. Some endpoints, like the save readings endpoint for example, have more restrictive limits and some are unrestriced.
In general, the rate limit for the Switch API is based on the method of authentication, as described below.
Rate limit for authenticated users
The Switch app uses users personal access token to make API requests. All of these requests count towards the users personal rate limit which is unrestricted at the moment.
Rate limit for OAuth 2.0 applications
Applications that make requests to the Switch API use OAuth 2.0 Client Credentials flow to get an access token which is then used to authenticate with the API. These types of requests have separate rate limits applied to them, depending on the endpoint.
The following rate limits are applied for these types of requests per endpoint:
POST
/api/readings
5 requests per second and/or 20 requests per minute
ALL
rest of the endpoints
no limit
Rate limit status
The response's HTTP headers are the authoritative source for the current number of API calls available to your application at any given time. The returned HTTP headers of any API request show your current rate limit status, as described below.
X-Rate-Limit-Limit
The maximum number of requests that you can make per minute
X-Rate-Limit-Remaining
The number of requests remaining in the current rate limit window
X-Rate-Limit-Reset
The time at which the current rate limit window resets, represented using ISO 8601 format and is always in UTC
Retry-After
The time in seconds after which you can retry your request
Exceeding the rate limit
If you exceed your rate limit for a given rate limit window, you will receive a 429 Too Many Requests
response, and the Retry-After
header will contain the time in seconds after which you can retry your request. You should not retry your request until this time has passed.
The body of the response will also contain message in plain text informing you about the current rate limit and the time after which you can retry your request as shown below.
Continuing to make requests while you are rate limited may result in the deactivation of your integration.
Last updated
Was this helpful?