{"data":{"id":89,"slug":"rate-limit-headers-explained-part-5-89","title":"Rate limit headers explained, part 5","excerpt":"Part 5 looks at what changes when the same technique has to run every day in production. A well-behaved API tells you how many requests you have left before it starts saying no. Reading those headers…","seriesName":"Rate limit headers explained","seriesPart":5,"sections":[{"heading":"Introduction","paragraphs":["Part 5 looks at what changes when the same technique has to run every day in production. A well-behaved API tells you how many requests you have left before it starts saying no. Reading those headers turns rate limiting from a surprise into a plan."]},{"heading":"Step by step","paragraphs":["Always identify your client honestly with a descriptive User-Agent, and keep your request rate modest. A crawler that behaves like a considerate visitor is far less likely to cause problems for the site operator.","Pagination comes in several shapes: numbered pages, next links, offsets and opaque cursors. Each has trade-offs, and a robust scraper should detect the end of the result set rather than assuming a fixed number of pages."]},{"heading":"What to watch for","paragraphs":["Store raw responses alongside parsed output while you are developing. When a parser breaks, you can replay the saved HTML instead of hitting the site again.","Be careful with relative URLs. Resolve every link against the page it came from, not against the site root, or you will request pages that do not exist."]},{"heading":"Key takeaway","paragraphs":["Track X-RateLimit-Remaining, slow down as it approaches zero, and when you receive a 429, wait for the number of seconds in Retry-After before trying again."]}],"authorId":8,"authorName":"Hannah Novak","authorSlug":"hannah-novak","category":"APIs","tags":["ethics"],"publishedAt":"2024-08-12T00:00:00.000Z","wordCount":194,"readingTimeMinutes":2}}