This error is returned when you send too many requests in a short period of time. The API enforces rate limits to ensure fair usage and maintain service stability for all users.
When you exceed the rate limit, you will receive a 429 Too Many Requests status code.
What to do next
Wait before retrying. Rate limits reset after a short time window. Implement a brief delay before sending additional requests.
Implement exponential backoff. When you receive a 429 response, wait progressively longer between retry attempts (e.g., 1s, 2s, 4s, 8s).
Check response headers. The response may include headers like Retry-After or X-RateLimit-Reset indicating when you can resume making requests.
Retry flow
Preventing rate limit errors
Batch requests where possible instead of making many individual calls
Cache responses to avoid redundant API calls
Spread requests evenly over time rather than sending bursts
Monitor your usage to stay within acceptable limits
Example retry logic
Tip
Always set a maximum retry limit to avoid infinite loops in case of persistent rate limiting.
TypeScript
Code
async function fetchWithRetry( url: string, options: RequestInit, maxRetries: number = 3): Promise<Response> { for (let attempt = 0; attempt < maxRetries; attempt++) { const response = await fetch(url, options); if (response.status !== 429) { return response; } const retryAfter = response.headers.get("Retry-After"); const delay = retryAfter ? parseInt(retryAfter, 10) * 1000 : Math.pow(2, attempt) * 1000; await new Promise((resolve) => setTimeout(resolve, delay)); } throw new Error("Rate limit exceeded after maximum retries");}
Rust
Code
use std::time::Duration;use reqwest::{Client, Response, StatusCode};async fn fetch_with_retry( client: &Client, url: &str, max_retries: u32,) -> Result<Response, Box<dyn std::error::Error>> { for attempt in 0..max_retries { let response = client.get(url).send().await?; if response.status() != StatusCode::TOO_MANY_REQUESTS { return Ok(response); } let delay = response .headers() .get("Retry-After") .and_then(|v| v.to_str().ok()) .and_then(|v| v.parse::<u64>().ok()) .map(Duration::from_secs) .unwrap_or_else(|| Duration::from_secs(2_u64.pow(attempt))); tokio::time::sleep(delay).await; } Err("Rate limit exceeded after maximum retries".into())}