Rate Limits
The MediLoop API implements rate limiting to ensure fair usage and maintain service quality for all users.
Rate Limit Tiers
Rate limits vary based on your subscription plan:
| Plan | Requests/min | Requests/day | Bulk Recipients |
|---|---|---|---|
| Sandbox | 100 | 10,000 | 100 |
| Starter | 300 | 50,000 | 500 |
| Professional | 1,000 | 500,000 | 1,000 |
| Enterprise | Custom | Custom | Custom |
Rate Limit Headers
Every API response includes headers to help you track your rate limit status:
| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests allowed per minute |
X-RateLimit-Remaining | Requests remaining in current window |
X-RateLimit-Reset | Unix timestamp when the limit resets |
Example Response Headers
X-RateLimit-Limit: 300 X-RateLimit-Remaining: 295 X-RateLimit-Reset: 1705315200
Rate Limit Exceeded
When you exceed the rate limit, the API returns a 429 Too Many Requests response:
RESPONSE429
{
"error": {
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded. Please retry after 60 seconds.",
"type": "rate_limit_error",
"retry_after": 60
}
}Handling Rate Limits
Best practices for handling rate limits:
- Monitor headers - Check
X-RateLimit-Remainingbefore making requests - Implement exponential backoff - When rate limited, wait and retry with increasing delays
- Use bulk endpoints - Send multiple items in one request when possible
- Cache responses - Avoid repeated requests for the same data
- Queue requests - Spread requests over time instead of bursting
Exponential Backoff Example
import time
import requests
def make_request_with_retry(url, headers, max_retries=5):
for attempt in range(max_retries):
response = requests.get(url, headers=headers)
if response.status_code == 429:
retry_after = int(response.headers.get('Retry-After', 60))
wait_time = min(retry_after, 2 ** attempt)
print(f"Rate limited. Waiting {wait_time}s...")
time.sleep(wait_time)
continue
return response
raise Exception("Max retries exceeded")Endpoint-Specific Limits
Some endpoints have additional limits:
| Endpoint | Limit | Notes |
|---|---|---|
| Bulk notifications | 1,000 recipients/request | Use for mass notifications |
| Patient registration | 100/minute | Duplicate detection adds overhead |
| AI processing | 60/minute | AI endpoints have lower limits |
Requesting Higher Limits
If you need higher rate limits, you can:
- Upgrade to a higher plan in the Developer Portal
- Contact support for Enterprise custom limits
- Request temporary limit increases for specific events