Rate Limits
The LocalStitch API enforces rate limits to ensure fair usage and maintain service quality.
Current Limits
| Limit | Value |
|---|---|
| Requests per minute | 60 |
| Window duration | 60 seconds (sliding) |
| Scope | Per API key |
MCP requests count against the same limit
Both REST API and MCP requests share the same rate limit. If you're using both, plan your request budget accordingly.
Rate Limit Headers
Every API response includes rate limit headers:
text
HTTP/1.1 200 OK
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 45
X-RateLimit-Reset: 1704067200
X-Credits-Remaining: 850| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per window |
X-RateLimit-Remaining | Requests remaining in current window |
X-RateLimit-Reset | Unix timestamp when the window resets |
X-Credits-Remaining | Your current credit balance |
Handling Rate Limits
When you exceed the rate limit, you'll receive a 429 Too Many Requests response:
text
HTTP/1.1 429 Too Many Requests
Retry-After: 30
X-RateLimit-Limit: 60
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1704067200
{
"error": "rate_limited",
"message": "Rate limit exceeded. Retry after 30 seconds."
}Retry Logic
Implement exponential backoff using the Retry-After header:
javascript
400">"text-purple-400">async 400">"text-purple-400">function fetchWithRetry(url, options, maxRetries = 3) {
400">"text-purple-400">for (400">"text-purple-400">let i = 0; i < maxRetries; i++) {
400">"text-purple-400">const response = 400">"text-purple-400">await fetch(url, options);
400">"text-purple-400">if (response.status === 429) {
400">"text-purple-400">const retryAfter = response.headers.get(400">'Retry-After') || 60;
console.log(400">`Rate limited. Retrying in ${retryAfter}s...`);
400">"text-purple-400">await new Promise(r => setTimeout(r, retryAfter * 1000));
continue;
}
400">"text-purple-400">return response;
}
throw new Error(400">'Max retries exceeded');
}Best Practices
✓
Monitor rate limit headers
Track X-RateLimit-Remaining to proactively slow down before hitting limits.
✓
Batch requests when possible
Use bulk endpoints (like enrichment batches) instead of individual requests.
✓
Cache responses
Store and reuse data that doesn't change frequently to reduce API calls.
✓
Implement exponential backoff
When rate limited, wait before retrying and increase the delay with each retry.
