DocumentationAPI ReferenceRate Limiting

Rate Limiting

API usage limits, monitoring, and best practices

Rate Limiting Overview

VPN Enterprise implements intelligent rate limiting to ensure fair usage and optimal performance for all users. Limits are enforced per API key and vary by subscription plan.

Request Limits

Monthly and burst rate limits

Plan-Based

Different limits for each plan tier

Monitoring

Real-time usage tracking

Understanding Rate Limits

Time-Based Limits
Monthly QuotaOverall usage limit
Burst RatePer-minute limit
ConcurrentSimultaneous requests
Response Headers

Every API response includes rate limit headers:

X-RateLimit-Limit: 5000X-RateLimit-Remaining: 4847X-RateLimit-Reset: 1701619200

Rate Limits by Plan

Starter

$29/month

Monthly Requests10,000
Burst Rate20/min
Concurrent10

Pro

$79/month

Monthly Requests100,000
Burst Rate100/min
Concurrent50

Enterprise

$199/month

Monthly RequestsUnlimited
Burst Rate500/min
Concurrent200

Current Usage (Example)

Monthly Usage

15.3k / 100k

15% used

Burst Rate

23 / 100

23% used (per minute)

Concurrent

8 / 50

16% used (active)

Rate Limited

0.3%

Very low error rate

Rate Limit Headers

Response Headers
Every API response includes these rate limiting headers
X-RateLimit-Limit5000

Maximum requests allowed in the current window

X-RateLimit-Remaining4847

Number of requests remaining in current window

X-RateLimit-Reset1701619200

Unix timestamp when the rate limit resets

X-RateLimit-Window3600

Rate limit window in seconds

Retry-After60

Seconds to wait before retrying (when rate limited)

Rate Limited Response

HTTP 429 - Too Many Requests
Response when rate limit is exceeded
HTTP/1.1 429 Too Many Requests
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1701619200
Retry-After: 3600
Content-Type: application/json

{
  "success": false,
  "error": {
    "type": "rate_limit_exceeded",
    "message": "API rate limit exceeded",
    "details": {
      "limit": 5000,
      "window": "1 hour",
      "reset_at": "2024-12-03T12:00:00Z",
      "retry_after": 3600
    }
  }
}

Rate Limit API Endpoints

GET/rate-limits/status
Check current rate limit status for your API key

Response

{
  "success": true,
  "rate_limits": {
    "requests": {
      "limit": 5000,
      "remaining": 4847,
      "reset": 1701619200,
      "reset_time": "2024-12-03T12:00:00Z"
    },
    "burst": {
      "limit": 100,
      "remaining": 94,
      "window": 60
    }
  },
  "plan": "pro",
  "usage_percentage": 3.06
}
GET/rate-limits/usage
Get detailed rate limit usage statistics

Response

{
  "success": true,
  "current_period": {
    "start": "2024-12-01T00:00:00Z",
    "end": "2024-12-31T23:59:59Z"
  },
  "usage": {
    "total_requests": 153847,
    "successful_requests": 152340,
    "rate_limited_requests": 1507,
    "error_requests": 0,
    "daily_average": 5128,
    "peak_rps": 45
  },
  "limits": {
    "monthly_requests": 100000,
    "burst_per_minute": 100,
    "concurrent_requests": 50
  },
  "plan": "pro",
  "upgrade_recommendation": null
}
GET/rate-limits/history
Get historical rate limit usage data

Response

{
  "success": true,
  "history": [
    {
      "date": "2024-12-01",
      "requests": 4832,
      "rate_limited": 12,
      "success_rate": 99.75
    },
    {
      "date": "2024-11-30",
      "requests": 5124,
      "rate_limited": 24,
      "success_rate": 99.53
    }
  ],
  "summary": {
    "total_days": 30,
    "average_daily_requests": 5089,
    "total_rate_limited": 456,
    "overall_success_rate": 99.12
  }
}

Best Practices

Monitor Headers

Check rate limit headers in every response to track usage and avoid hitting limits unexpectedly.

Implement Backoff

Use exponential backoff when rate limited. Respect the Retry-After header for optimal retry timing.

Plan for Growth

Monitor your usage patterns and upgrade your plan before hitting limits regularly to ensure smooth operation.

Implementation Example

Rate Limit Handling in JavaScript
Example implementation with exponential backoff
async function apiRequest(url, options = {}) {
  const maxRetries = 3;
  let retryCount = 0;
  
  while (retryCount <= maxRetries) {
    try {
      const response = await fetch(url, {
        ...options,
        headers: {
          'Authorization': 'Bearer your-api-key',
          'Content-Type': 'application/json',
          ...options.headers
        }
      });
      
      // Check rate limit headers
      const remaining = response.headers.get('X-RateLimit-Remaining');
      const reset = response.headers.get('X-RateLimit-Reset');
      
      console.log(`Rate limit remaining: ${remaining}`);
      
      if (response.status === 429) {
        const retryAfter = response.headers.get('Retry-After');
        const delay = retryAfter ? parseInt(retryAfter) * 1000 : Math.pow(2, retryCount) * 1000;
        
        console.log(`Rate limited. Retrying in ${delay}ms...`);
        await new Promise(resolve => setTimeout(resolve, delay));
        
        retryCount++;
        continue;
      }
      
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}: ${response.statusText}`);
      }
      
      return await response.json();
      
    } catch (error) {
      if (retryCount === maxRetries) {
        throw error;
      }
      
      retryCount++;
      const delay = Math.pow(2, retryCount) * 1000;
      await new Promise(resolve => setTimeout(resolve, delay));
    }
  }
}

// Usage
try {
  const data = await apiRequest('https://api.vpnenterprise.com/vpn/connections');
  console.log('API response:', data);
} catch (error) {
  console.error('API request failed:', error);
}

API Reference Complete

You've reached the end of our comprehensive API documentation. Explore other sections to learn more about VPN Enterprise.