Rate Limiting
API usage limits, monitoring, and best practices
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 limitsPlan-Based
Different limits for each plan tierMonitoring
Real-time usage trackingUnderstanding Rate Limits
Every API response includes rate limit headers:
X-RateLimit-Limit: 5000X-RateLimit-Remaining: 4847X-RateLimit-Reset: 1701619200Rate Limits by Plan
Starter
$29/month
Pro
$79/month
Enterprise
$199/month
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
X-RateLimit-Limit5000Maximum requests allowed in the current window
X-RateLimit-Remaining4847Number of requests remaining in current window
X-RateLimit-Reset1701619200Unix timestamp when the rate limit resets
X-RateLimit-Window3600Rate limit window in seconds
Retry-After60Seconds to wait before retrying (when rate limited)
Rate Limited Response
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
/rate-limits/statusResponse
{
"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
}/rate-limits/usageResponse
{
"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
}/rate-limits/historyResponse
{
"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
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);
}