Every web application that relies on third-party APIs eventually meets two problems: API rate limits and failed requests. Payment gateways, CRMs, ERPs, shipping providers, marketplaces and email services all limit how many requests you can send, and all of them occasionally time out, return errors or go offline for maintenance. If your application is not designed for this, orders fail, data goes missing, users see errors and support teams spend hours fixing records. This guide explains how to handle API rate limits and failed requests reliably.
Understanding API Rate Limits
Rate limits cap how many requests a client can make in a period, such as 100 requests per minute or 10 requests per second. Providers use them to protect their systems. Limits may apply per API key, per user, per endpoint or per IP address. Some APIs use a “leaky bucket” or “token bucket” model, allowing short bursts but limiting sustained traffic.
When you exceed a limit, the API usually returns HTTP 429 (Too Many Requests), often with headers telling you when to try again, such as Retry-After or remaining quota values.
Types of Failed Requests
| Error type | Examples | Retry? |
|---|---|---|
| Rate limiting | 429 Too Many Requests | Yes, after waiting |
| Temporary server errors | 500, 502, 503, 504 | Yes, with backoff |
| Network problems | Timeouts, connection resets | Yes, with backoff |
| Client errors | 400 Bad Request, 422 validation errors | No, fix the data |
| Authentication errors | 401, 403 | No, fix credentials |
| Not found | 404 | Usually no |
Distinguishing temporary from permanent errors is the foundation of good error handling. Retrying a validation error wastes requests; giving up on a temporary error loses data.
Strategies to Stay Within API Rate Limits
Read and Respect Limit Headers
Monitor remaining quota headers and slow down before hitting the limit, rather than waiting for 429 errors.
Use Queues for Outgoing Requests
Instead of calling APIs directly during user actions, place requests in a background queue. Workers process the queue at a controlled rate. Users get fast responses, and the application never floods the API.
Batch Requests
Many APIs support bulk endpoints, such as updating 100 products in one call. Batching reduces request counts dramatically.
Cache Responses
Cache data that changes rarely, such as product details, shipping rates for common routes or configuration data. Fewer calls mean less risk of hitting limits.
Use Webhooks Instead of Polling
Where available, webhooks reduce the need to poll APIs repeatedly for changes.
Spread Scheduled Jobs
Avoid running all sync jobs at the top of the hour. Stagger schedules to smooth traffic.
Handling Failed Requests
Retry With Exponential Backoff
For temporary failures, retry after increasing delays: for example 1 second, 2, 4, 8 and so on, with a small random “jitter” so many workers do not retry at the same moment. Set a maximum number of attempts.
Make Operations Idempotent
If a request times out, you may not know whether it succeeded. Retrying could create duplicates, such as two orders or two charges. Use idempotency keys where APIs support them, and check for existing records before creating new ones.
Use Dead-Letter Queues
After the final retry fails, move the job to a dead-letter queue for review. Staff can inspect, fix data and replay it. Nothing is silently lost.
Apply Circuit Breakers
If an API is failing repeatedly, stop sending requests for a short period instead of hammering it. A circuit breaker protects both systems and allows faster recovery.
Provide Fallbacks
Where possible, degrade gracefully. If live shipping rates fail, show standard rates. If a CRM is down, store enquiries locally and sync later. Users should rarely see raw integration errors.
Monitoring and Alerts
Track:
- Requests per API and remaining quota
- Error rates by type
- Queue lengths and processing times
- Dead-letter queue size
- Average and peak response times
Alert staff when error rates spike, queues grow or dead-letter items appear. Dashboards make problems visible before customers notice.
Logging for Troubleshooting
Log every external request with timestamp, endpoint, response code, duration and a correlation ID linking it to the business record. Avoid logging sensitive data such as card numbers or passwords. Good logs turn a vague “the order didn’t sync” into a precise answer in minutes.
Example: Marketplace Sync During a Sale
A retailer syncing stock to a marketplace hit rate limits during a festive sale, causing stock updates to fail and overselling. The redesigned integration used a queue with a controlled request rate, batch stock updates, exponential backoff on 429 responses and alerts for growing queues. During the next sale, stock updates completed within minutes despite much higher order volumes.
Common Mistakes
- Calling third-party APIs synchronously during checkout or form submission
- Retrying immediately and repeatedly
- Retrying permanent errors
- No idempotency, causing duplicate records
- No monitoring of failed jobs
Planning for Peak Events
Rate limits and failures cause the most damage at the busiest moments: festive sales, product launches, marketing campaigns, financial year-end or exam results day for education portals. Prepare before these events. Review expected traffic and API usage against provider limits, request temporary limit increases where available, pre-warm caches, schedule bulk updates for quieter hours and freeze non-essential integration changes. Run a load test that simulates peak order volumes against sandbox APIs to see how queues behave. Share contact details for provider support with the on-call team. After the event, review logs to see where limits were approached and adjust settings. Businesses that build these checks into their website launch checklist and website testing and QA routines avoid most peak-day surprises. Retail brands planning big campaigns through ecommerce website development projects benefit most, because sales events concentrate traffic into a few hours. Reliable website hosting and deployment with autoscaling queues completes the picture.
Frequently Asked Questions
How Many Times Should We Retry?
Typically three to seven attempts with backoff, depending on how critical the operation is.
Can We Ask Providers for Higher Limits?
Often yes, especially on paid plans. Still design for limits, because they exist for a reason.
Should Users See Integration Errors?
Rarely. Show friendly messages and handle problems in the background. Ongoing website support teams can then resolve queued items without customers noticing.
Designing for rate limits and failures makes integrations reliable under real-world conditions. Explore our API integration development, review website backend development, learn about website integration services, read our website performance guide, or contact us.
