How to handle rate limits
React to 429 Too Many Requests so that your integration keeps working and does not make things worse.
The gateway limits requests per caller (see Rate Limiting and the policy list). A client that retries immediately after a 429 stays over the limit. A client that waits as told gets through.
Steps
1. Treat 429 as "wait", not as an error
Read Retry-After (seconds) and wait at least that long before you send the same request again. It is a
time after which the retry succeeds, not the earliest moment it might; for a per-minute limit it can be the whole
minute. A rejected request takes nothing from your quota, so retrying early does not extend the wait — it only
wastes the call. Requests that get through do count, so hold other calls to the same API too.
2. Add jitter
If many clients hit a limit at the same moment and all wait exactly Retry-After, they all come back at
the same moment. Add a random 0-50 % on top of the wait.
import random, time, requests
def call(session, method, url, **kwargs):
for attempt in range(5):
response = session.request(method, url, **kwargs)
if response.status_code != 429:
return response
wait = int(response.headers.get("Retry-After", "5"))
time.sleep(wait * (1 + random.random() * 0.5))
return response
3. Send fewer requests
- Reuse the access token for its whole lifetime. Do not log in before every call; the login route has the strictest limit.
- Batch where the API offers it, for example the bulk activation and the timeseries query routes.
- Poll less often. Use SignalR streaming for live values instead of polling.
4. Keep the trace id when you contact support
The 429 body has a traceId. With it, support can find the request, the policy that rejected it and the
counter it hit, and can lift the limit for you if that is the right fix.
What not to do
- Do not spread requests over several tokens or several IP addresses to get around a limit. Limits exist to keep the platform responsive for everyone, and a shared per-IP ceiling still applies.
- Do not retry in a tight loop. Each retry is counted.