Skip to main content

Overview

Transaction API implements rate limiting to ensure fair usage and system stability. Different endpoints have different rate limits based on their resource requirements.

Rate Limit Tiers

Authentication

5 requests/minute
  • /auth/register
  • /auth/login
  • /auth/verify-email
  • /auth/resend-verification

Payment Creation

10 requests/minute
  • /payment/create
  • /payment/select-crypto

Other Endpoints

100 requests/minute
  • All other API endpoints

Rate Limit Headers

All API responses include rate limit information in the headers:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200
X-RateLimit-Limit
integer
Maximum requests allowed per window
X-RateLimit-Remaining
integer
Number of requests remaining in current window
X-RateLimit-Reset
integer
Unix timestamp when the rate limit resets

Rate Limit Exceeded

When you exceed the rate limit, you’ll receive a 429 Too Many Requests response:
{
  "success": false,
  "error": {
    "status": 429,
    "code": "RATE_LIMITED",
    "message": "Too many requests"
  },
  "data": null
}

Best Practices

Implement Exponential Backoff

async function makeRequestWithRetry(url, options, maxRetries = 3) {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      const response = await fetch(url, options);
      
      if (response.status === 429) {
        // Rate limited - wait and retry
        const retryAfter = response.headers.get('Retry-After') || Math.pow(2, attempt);
        await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
        continue;
      }
      
      return response;
    } catch (error) {
      if (attempt === maxRetries - 1) throw error;
      await new Promise(resolve => setTimeout(resolve, Math.pow(2, attempt) * 1000));
    }
  }
}

Monitor Rate Limit Usage

function checkRateLimit(response) {
  const limit = parseInt(response.headers.get('X-RateLimit-Limit'));
  const remaining = parseInt(response.headers.get('X-RateLimit-Remaining'));
  const reset = parseInt(response.headers.get('X-RateLimit-Reset'));
  
  console.log(`Rate limit: ${remaining}/${limit} remaining`);
  console.log(`Resets at: ${new Date(reset * 1000)}`);
  
  if (remaining < 10) {
    console.warn('Rate limit nearly exceeded!');
  }
}

Batch Operations

Instead of making multiple individual requests, batch operations when possible:
// ❌ Don't do this
for (const customer of customers) {
  await createCustomer(customer);
}

// ✅ Do this instead
const batchPromises = customers.map(customer => createCustomer(customer));
await Promise.all(batchPromises);

Rate Limit Strategies

For High-Volume Applications

1

Implement Caching

Cache frequently accessed data to reduce API calls.
2

Use Webhooks

Subscribe to webhook events instead of polling for updates.
3

Batch Requests

Combine multiple operations into single requests when possible.
4

Queue Operations

Use a queue system to manage request timing and avoid bursts.

For Development

1

Use Sandbox Mode

Test with sandbox mode which has higher rate limits.
2

Implement Delays

Add delays between requests during development.
3

Monitor Headers

Always check rate limit headers in your responses.

Monitoring and Alerts

Set Up Monitoring

// Example monitoring setup
class RateLimitMonitor {
  constructor() {
    this.usage = new Map();
  }
  
  trackRequest(endpoint, headers) {
    const limit = parseInt(headers.get('X-RateLimit-Limit'));
    const remaining = parseInt(headers.get('X-RateLimit-Remaining'));
    const reset = parseInt(headers.get('X-RateLimit-Reset'));
    
    this.usage.set(endpoint, {
      limit,
      remaining,
      reset,
      lastChecked: Date.now()
    });
  }
  
  getUsage(endpoint) {
    return this.usage.get(endpoint);
  }
  
  isNearLimit(endpoint, threshold = 0.8) {
    const usage = this.getUsage(endpoint);
    if (!usage) return false;
    
    return usage.remaining / usage.limit < (1 - threshold);
  }
}

Alert Configuration

Set up alerts when approaching rate limits:
if (rateLimitMonitor.isNearLimit('payment/create', 0.9)) {
  console.warn('Payment creation rate limit at 90%');
  // Send alert to monitoring system
}

Common Scenarios

Scenario: High-volume payment processingSolution:
  • Use webhooks instead of polling payment status
  • Implement request queuing
  • Cache product and price data
Scenario: Frequent API calls from mobile devicesSolution:
  • Implement local caching
  • Batch multiple operations
  • Use background sync
Scenario: Real-time data fetching for dashboardsSolution:
  • Use WebSocket connections
  • Implement data aggregation
  • Cache dashboard data

Rate Limit Increases

For applications requiring higher rate limits:
  1. Contact Support: Reach out to our support team with your use case
  2. Provide Metrics: Share your current usage patterns and requirements
  3. Business Justification: Explain why higher limits are needed
  4. Implementation Plan: Show how you’ll handle the increased volume
Enterprise Plans: Higher rate limits are available for enterprise customers. Contact sales for more information.