API Rate Limiting & Optimization
StateSet implements rate limiting to ensure fair usage and maintain service reliability for all users. This guide covers understanding rate limits, implementing efficient request patterns, and optimizing your API usage.Rate Limit Overview
StateSet uses a sliding window rate limiting algorithm that provides smooth, predictable limits across different time windows.Per-Second Limits
Prevents burst traffic spikes and ensures responsive service
Per-Minute Limits
Controls sustained request volume over longer periods
Per-Hour Limits
Manages overall API consumption and prevents abuse
Current Rate Limits
By Plan Type
Endpoint Category | Per Second | Per Minute | Per Hour |
---|---|---|---|
Orders API | 10 | 300 | 5,000 |
Customers API | 5 | 150 | 2,500 |
Returns API | 5 | 150 | 2,500 |
Webhooks | 20 | 600 | 10,000 |
Analytics | 2 | 60 | 1,000 |
Special Considerations
Batch Operations
Batch Operations
- Batch endpoints have higher rate limits but count as multiple requests
- Each item in a batch counts toward your rate limit
- Maximum batch size: 100 items per request
List Operations
List Operations
- List endpoints with large
limit
parameters consume more quota - Requests with
limit > 100
count asMath.ceil(limit/100)
requests - Use pagination instead of large limit values
Webhook Endpoints
Webhook Endpoints
- Webhook deliveries do not count against your rate limits
- Failed webhook retries use separate retry quotas
- Webhook verification calls are not rate limited
Rate Limit Headers
Every API response includes rate limit information in the headers:Header Descriptions
Header | Description |
---|---|
X-RateLimit-Limit | Maximum requests allowed in the current window |
X-RateLimit-Remaining | Requests remaining in the current window |
X-RateLimit-Reset | Unix timestamp when the window resets |
X-RateLimit-Window | Window duration in seconds (60 for per-minute limits) |
X-RateLimit-Category | API category for this endpoint |
Retry-After | Seconds to wait before retrying (present when rate limited) |
Implementing Rate Limit Handling
Basic Rate Limit Detection
Advanced Rate Limiting with Queue
Optimization Strategies
1. Efficient Pagination
Instead of requesting large datasets at once:2. Batch Operations
Use batch endpoints when available:3. Webhook-First Architecture
Reduce polling by using webhooks:4. Intelligent Caching
Cache frequently requested data:Monitoring Rate Limits
Rate Limit Dashboard
Create a monitoring dashboard for your rate limit usage:Best Practices Summary
Request Optimization
- Use pagination instead of large limit values
- Implement batch operations where possible
- Cache frequently requested data
- Use webhooks to reduce polling
Error Handling
- Always check rate limit headers
- Implement exponential backoff for retries
- Use queues to manage request flow
- Monitor and alert on high utilization
Architecture Patterns
- Design webhook-first integrations
- Implement circuit breakers for resilience
- Use separate queues for different priorities
- Cache aggressively with smart invalidation
Monitoring & Alerting
- Track utilization across all categories
- Set alerts at 80% utilization threshold
- Monitor request success rates
- Review patterns during peak usage
Getting Help
If you’re consistently hitting rate limits or need higher limits:- Review your usage patterns using the monitoring tools above
- Optimize your integration following the strategies in this guide
- Consider upgrading to a higher plan with increased limits
- Contact support at support@stateset.com for custom rate limits