Skip to main content

Rate Limiting

SwiftPay implements rate limiting to ensure fair usage and protect our infrastructure. Rate limits are applied per API key.

Rate Limits

TierRequests per MinuteRequests per Hour
Standard1001,000
Premium5005,000
EnterpriseCustomCustom
Your rate limit tier is based on your account plan. Contact support to upgrade.

Rate Limit Headers

Every API response includes headers indicating your current rate limit status:
HeaderDescription
X-RateLimit-LimitMaximum requests allowed in the current window
X-RateLimit-RemainingRequests remaining in the current window
X-RateLimit-ResetUnix timestamp when the rate limit resets
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1704067200

Rate Limit Exceeded

When you exceed your rate limit, you’ll receive a 429 Too Many Requests response:
{
   "success": false,
   "error": {
      "type": "rate_limit_exceeded",
      "message": "Rate limit exceeded. Please retry after 45 seconds.",
      "requestId": "req_abc123",
      "retryAfter": 45
   }
}
The Retry-After header indicates how many seconds to wait before retrying.

Handling Rate Limits

async function apiRequest(url, options, retries = 3) {
  for (let i = 0; i < retries; i++) {
    const response = await fetch(url, options);
    
    if (response.status === 429) {
      const retryAfter = response.headers.get('Retry-After') || 60;
      console.log(`Rate limited. Retrying after ${retryAfter}s...`);
      await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
      continue;
    }
    
    return response;
  }
  
  throw new Error('Max retries exceeded');
}

Best Practices

When retrying after rate limits, use exponential backoff to gradually increase wait times: javascript const delay = Math.min(1000 * Math.pow(2, attempt), 30000);
Cache API responses where appropriate to reduce the number of requests: - Balance information (cache for 30-60 seconds) - Session details (cache until status changes) - Webhook endpoint lists (cache for several minutes)
Where possible, batch multiple operations into a single request to reduce API calls.
Monitor your API usage in the dashboard to understand your patterns and avoid hitting limits.

Rate Limit Exceptions

Certain endpoints have different rate limits:
EndpointLimit
POST /api/checkout/:id/pay10 per minute per session
GET /api/balance30 per minute

Need Higher Limits?

If you need higher rate limits, contact our sales team to discuss Enterprise pricing:

Contact Sales

Get custom rate limits for your business needs