Rate Limits
Understanding API rate limits and best practices
Rate Limit Overview
To ensure fair usage and system stability, our API implements rate limiting based on your account tier.
| Account Tier | Requests per Minute | Concurrent Requests | Daily Limit |
|---|---|---|---|
| Free | 10 | 2 | 500 |
| Basic | 60 | 10 | 10,000 |
| Pro | 120 | 25 | 50,000 |
| Enterprise | 300 | 100 | Unlimited |
Rate Limit Headers
Every API response includes rate limit information in the headers:
Response Headers
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1699564800
| Header | Description |
|---|---|
X-RateLimit-Limit |
Maximum requests allowed per minute |
X-RateLimit-Remaining |
Requests remaining in current window |
X-RateLimit-Reset |
Unix timestamp when limit resets |
Handling Rate Limits
When you exceed the rate limit, you'll receive a 429 status code:
Error Response
{
"success": false,
"service": "MyDisct Solver",
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "Rate limit exceeded",
"retryable": true,
"retryAfter": 30
}
}
Exponential Backoff Implementation
Implement exponential backoff in your code to handle rate limits gracefully:
JavaScript Example
async function solveWithRetry(captchaData, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
const response = await fetch('https://solver-api.mydisct.com/createTask', {
method: 'POST',
headers: {
'apikey': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
auth: { token: 'YOUR_API_KEY' },
context: { source: 'api', version: '1.0.0' },
captcha: captchaData
})
});
if (response.status === 429) {
const retryAfter = response.headers.get('Retry-After') || Math.pow(2, i);
console.log(`Rate limited. Waiting ${retryAfter} seconds...`);
await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
continue;
}
return await response.json();
} catch (error) {
if (i === maxRetries - 1) throw error;
await new Promise(resolve => setTimeout(resolve, Math.pow(2, i) * 1000));
}
}
}
const result = await solveWithRetry({
type: 'RECAPTCHA_V2_TOKEN',
metadata: {
siteKey: 'your_sitekey',
siteUrl: 'https://example.com'
}
});
Best Practices
Recommendations
- Monitor rate limit headers in responses
- Implement exponential backoff for retries
- Cache results when possible to reduce API calls
- Batch requests during off-peak hours
- Upgrade your tier if consistently hitting limits
- Use connection pooling for better performance
- Set up alerts when approaching rate limits