Rate limits
Each API key can make 120 requests a minute. That's plenty for normal use, and it stops one runaway script from slowing things down for everyone.
Go over it and you get 429 Too Many Requests with the code rate_limited and a
Retry-After header saying how many seconds to wait:
HTTP/1.1 429 Too Many Requests
Retry-After: 23
Content-Type: application/problem+json
Staying under it
- Use webhooks instead of polling. One webhook replaces dozens of "is it done yet?" requests. See Webhooks.
- Ask for bigger pages.
pageSize=100fetches 100 SIMs in one request instead of 50. - Filter on the server.
GET /sims?status=suspendedbeats fetching everything and filtering yourself. - Use the estate-wide endpoints.
GET /usage/summaryand the reports give totals in one request. - Give each system its own key. Each key has its own limit, and you can tell them apart.
- Pace bulk changes. Acting on hundreds of SIMs is fine; send them at a steady rate (one or two a second) rather than all at once.
Handling a 429
- Node.js
- Python
- C#
async function axisFetch(url, options = {}, attempts = 3) {
for (let i = 1; ; i++) {
const res = await fetch(url, options);
if (res.status !== 429 || i >= attempts) return res;
const wait = Number(res.headers.get('Retry-After') ?? 5);
await new Promise((r) => setTimeout(r, wait * 1000));
}
}
def axis_request(method, url, attempts=3, **kwargs):
for i in range(1, attempts + 1):
res = requests.request(method, url, **kwargs)
if res.status_code != 429 or i == attempts:
return res
time.sleep(int(res.headers.get("Retry-After", 5)))
async Task<HttpResponseMessage> SendWithRetryAsync(HttpClient http, Func<HttpRequestMessage> make, int attempts = 3)
{
for (var i = 1; ; i++)
{
var res = await http.SendAsync(make());
if (res.StatusCode != HttpStatusCode.TooManyRequests || i >= attempts) return res;
await Task.Delay(res.Headers.RetryAfter?.Delta ?? TimeSpan.FromSeconds(5));
}
}
Need more for a particular job? Email support@zentarinetworks.com and tell us what you're building.