<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>89</id><slug>rate-limit-headers-explained-part-5-89</slug><title>Rate limit headers explained, part 5</title><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…</excerpt><seriesName>Rate limit headers explained</seriesName><seriesPart>5</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>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.</item></paragraphs></item><item><heading>Step by step</heading><paragraphs><item>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.</item><item>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.</item></paragraphs></item><item><heading>What to watch for</heading><paragraphs><item>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.</item><item>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.</item></paragraphs></item><item><heading>Key takeaway</heading><paragraphs><item>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.</item></paragraphs></item></sections><authorId>8</authorId><authorName>Hannah Novak</authorName><authorSlug>hannah-novak</authorSlug><category>APIs</category><tags><item>ethics</item></tags><publishedAt>2024-08-12T00:00:00.000Z</publishedAt><wordCount>194</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
