Rate limits
What the Wire2Air APIs document about request quotas and the 429 status, and how to retry safely.
The REST API v1 can answer any request with:
| Status | Meaning |
|---|---|
429 | API calls quota exceeded. |
That status is the only thing the current documentation says about limits.
Handling 429
Until the limits are published, write clients that cope with a 429 without losing messages:
- Stop sending on the first
429. - Wait before retrying, and double the wait after each further
429(for example 1 s, 2 s, 4 s, up to a minute). - Retry the same request. Keep the messages you have not sent yet in your own queue, not in memory only.
import time
import urllib.error
import urllib.request
def send_with_retry(request, attempts=6):
delay = 1
for _ in range(attempts):
try:
with urllib.request.urlopen(request, timeout=30) as response:
return response.status, response.read().decode("utf-8")
except urllib.error.HTTPError as error:
if error.code != 429:
return error.code, error.read().decode("utf-8")
time.sleep(delay)
delay = min(delay * 2, 60)
raise RuntimeError("Still rate limited after retrying")

