Rate Limits
Understand Click Airtime API rate limits and implement proper throttling to avoid request rejections.
Rate limits protect the Click Airtime API from abuse and ensure fair access for all users. This guide explains the limits for each API version and how to handle rate-limited responses.
Rate Limit Overview
Version 2 API
Limits are applied per API key, across all /v2/* endpoints:
| Limit | Default | Window |
|---|---|---|
| Requests per minute | 60 requests | 1 minute |
| Burst | 100 requests | 1 second |
Both limits can be raised on request — contact your account manager or support@click-mobile.com if your integration needs higher throughput.
Version 1 API
| Endpoint | Rate Limit | Window |
|---|---|---|
POST /adp | 60 requests | Per minute |
GET /adp/balances | 120 requests | Per minute |
GET /adp/transactions | 120 requests | Per minute |
Rate Limit Headers
Every authenticated V2 response includes your current rate limit state:
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 47
X-RateLimit-Reset: 1791897960
| Header | Description |
|---|---|
X-RateLimit-Limit | Requests allowed per minute for this API key |
X-RateLimit-Remaining | Requests remaining in the current one-minute window |
X-RateLimit-Reset | Unix time (seconds) when the current one-minute window resets |
Handling Rate Limits
When you exceed a limit, the API returns 429 Too Many Requests with error code RATE_LIMIT_EXCEEDED:
{
"success": false,
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit exceeded (rpm: 61/60). Retry after 60s."
}
}
The response includes a Retry-After header with the number of seconds to wait before retrying.
Implementation
async function requestWithRateLimiting(fn) {
const response = await fn();
if (response.status === 429) {
const retryAfter = parseInt(response.headers.get('Retry-After') || '60', 10);
console.log(`Rate limited. Retrying after ${retryAfter} seconds...`);
await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
return fn(); // Retry once
}
return response;
}
// Proactive rate limiting using response headers
class RateLimitedClient {
constructor() {
this.remaining = Infinity;
this.resetAt = 0;
}
async request(fn) {
// Wait if we know we are out of requests
if (this.remaining <= 0) {
const waitMs = Math.max(0, (this.resetAt * 1000) - Date.now());
if (waitMs > 0) {
console.log(`Rate limit reached. Waiting ${Math.ceil(waitMs / 1000)}s...`);
await new Promise(resolve => setTimeout(resolve, waitMs));
}
}
const response = await fn();
// Update rate limit state from headers
this.remaining = parseInt(response.headers.get('X-RateLimit-Remaining') || 'Infinity', 10);
this.resetAt = parseInt(response.headers.get('X-RateLimit-Reset') || '0', 10);
if (response.status === 429) {
const retryAfter = parseInt(response.headers.get('Retry-After') || '60', 10);
await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
return fn();
}
return response;
}
}import time
import requests as http
class RateLimitedClient:
def __init__(self):
self.remaining = float('inf')
self.reset_at = 0
def request(self, method, url, **kwargs):
# Wait if we know we are out of requests
if self.remaining <= 0:
wait_seconds = max(0, self.reset_at - time.time())
if wait_seconds > 0:
print(f"Rate limit reached. Waiting {int(wait_seconds)}s...")
time.sleep(wait_seconds)
response = http.request(method, url, **kwargs)
# Update rate limit state from headers
self.remaining = int(response.headers.get('X-RateLimit-Remaining', float('inf')))
self.reset_at = int(response.headers.get('X-RateLimit-Reset', 0))
if response.status_code == 429:
retry_after = int(response.headers.get('Retry-After', 60))
print(f"Rate limited. Retrying after {retry_after} seconds...")
time.sleep(retry_after)
response = http.request(method, url, **kwargs)
return response
# Usage
client = RateLimitedClient()
response = client.request(
'GET',
'https://api.clickairtime.com/v2/balance',
headers={
'Authorization': 'Bearer ce_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
}
)Best Practices
-
Monitor rate limit headers -- Track
X-RateLimit-Remainingproactively to avoid hitting the limit. -
Implement queuing -- For high-volume applications, use a job queue to throttle API calls to stay within limits.
-
Cache where possible -- Cache catalog lookups and balance checks to reduce unnecessary API calls.
-
Spread requests evenly -- At the default 60 requests per minute, send about 1 request per second rather than bursting.
-
Handle 429 gracefully -- Always respect the
Retry-Afterheader and do not immediately retry rate-limited requests. -
Budget per key -- All V2 endpoints share one limit per API key, so catalog, balance, and history calls count against the same budget as top-ups.
