Rate Limiting
Semaswift implements rate limiting to ensure fair usage and platform stability.
Rate Limits
| Plan | Requests/Minute | Requests/Day |
|---|---|---|
| Free | 60 | 1,000 |
| Starter | 300 | 10,000 |
| Professional | 1,000 | 100,000 |
| Enterprise | Custom | Custom |
Rate Limit Headers
Every response includes rate limit information:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 995
X-RateLimit-Reset: 1704067200
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per window |
X-RateLimit-Remaining | Remaining requests in window |
X-RateLimit-Reset | Unix timestamp when limit resets |
Rate Limit Response
When you exceed the rate limit:
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Retry-After: 60
{
"code": 429,
"message": "Rate limit exceeded",
"retry_after": 60
}
Handling Rate Limits
Exponential Backoff
async function fetchWithRetry(url, options, maxRetries = 3) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
const response = await fetch(url, options);
if (response.status !== 429) {
return response;
}
const retryAfter = response.headers.get('Retry-After') || 60;
const delay = Math.min(retryAfter * 1000, Math.pow(2, attempt) * 1000);
console.log(`Rate limited. Retrying in ${delay}ms...`);
await new Promise(resolve => setTimeout(resolve, delay));
}
throw new Error('Max retries exceeded');
}
Request Queuing
import time
from collections import deque
class RateLimiter:
def __init__(self, max_requests=60, window_seconds=60):
self.max_requests = max_requests
self.window_seconds = window_seconds
self.requests = deque()
def wait_if_needed(self):
now = time.time()
# Remove old requests
while self.requests and self.requests[0] < now - self.window_seconds:
self.requests.popleft()
# Wait if at limit
if len(self.requests) >= self.max_requests:
sleep_time = self.requests[0] + self.window_seconds - now
time.sleep(sleep_time)
self.requests.append(now)
Rate Limit Scopes
Rate limits are applied at different scopes:
| Scope | Description |
|---|---|
| Per User | Limits per authenticated user |
| Per Organization | Limits for entire organization |
| Per Endpoint | Some endpoints have specific limits |
| Per IP | For unauthenticated requests |
Endpoint-Specific Limits
Some endpoints have stricter limits:
| Endpoint | Limit | Reason |
|---|---|---|
POST /auth/login | 10/min | Brute force protection |
POST /uploads | 100/hour | Resource intensive |
GET /reports/* | 10/min | Heavy queries |
Best Practices
- Cache responses - Reduce unnecessary API calls
- Use webhooks - Instead of polling for changes
- Batch operations - Use bulk endpoints when available
- Monitor usage - Track your rate limit consumption
- Implement backoff - Handle 429 responses gracefully
Increasing Limits
Need higher limits? Contact us:
- Upgrade your plan
- Request temporary increase for migrations
- Enterprise custom limits