Rate Limiting
FreJun implements API rate limiting (throttling) to ensure fair usage and maintain service quality for all users. Rate limits are applied per organization and help prevent abuse while ensuring system stability.
Rate Limit Policies
FreJun enforces two types of rate limits:
1. Per-Minute Limit
- Limit: 100 requests per minute per organization
- Scope: Applied per endpoint
- Purpose: Prevents short-term bursts of excessive requests
If you exceed this limit, you'll receive a 429 error with the message:
Too many requests (org per minute limit reached)
2. Per-Day Limit
- Limit: 10,000 requests per day per organization
- Scope: Applied per endpoint
- Purpose: Ensures fair usage across all organizations over longer periods
If you exceed this limit, you'll receive a 429 error with the message:
Too many requests (org per day limit reached)
Understanding Rate Limit Responses
When you hit a rate limit, the API will return:
- HTTP Status Code:
429 Too Many Requests - Response Body: Contains details about which limit was exceeded
Best Practices
To avoid hitting rate limits:
-
Implement Exponential Backoff: When you receive a
429error, wait before retrying, and increase the wait time with each subsequent failure -
Cache Responses: Store API responses locally when appropriate to reduce the number of requests
-
Batch Operations: Where possible, combine multiple operations into a single API call
-
Monitor Your Usage: Track your API usage to stay within limits
-
Handle Rate Limit Errors Gracefully: Implement proper error handling for
429responses in your application
Example: Handling Rate Limits
Here's an example of how to handle rate limiting in your code:
import time
import requests
def make_api_request(url, headers, max_retries=3):
retries = 0
backoff = 1 # Initial backoff in seconds
while retries < max_retries:
response = requests.get(url, headers=headers)
if response.status_code == 200:
return response.json()
elif response.status_code == 429:
print(f"Rate limit exceeded. Retrying in {backoff} seconds...")
time.sleep(backoff)
backoff *= 2 # Exponential backoff
retries += 1
else:
response.raise_for_status()
raise Exception("Max retries exceeded")
Rate limits are calculated per organization, not per user or API key. All requests from your organization share the same rate limit quota.