Click Airtime

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:

LimitDefaultWindow
Requests per minute60 requests1 minute
Burst100 requests1 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

EndpointRate LimitWindow
POST /adp60 requestsPer minute
GET /adp/balances120 requestsPer minute
GET /adp/transactions120 requestsPer 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
HeaderDescription
X-RateLimit-LimitRequests allowed per minute for this API key
X-RateLimit-RemainingRequests remaining in the current one-minute window
X-RateLimit-ResetUnix 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

  1. Monitor rate limit headers -- Track X-RateLimit-Remaining proactively to avoid hitting the limit.

  2. Implement queuing -- For high-volume applications, use a job queue to throttle API calls to stay within limits.

  3. Cache where possible -- Cache catalog lookups and balance checks to reduce unnecessary API calls.

  4. Spread requests evenly -- At the default 60 requests per minute, send about 1 request per second rather than bursting.

  5. Handle 429 gracefully -- Always respect the Retry-After header and do not immediately retry rate-limited requests.

  6. 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.