<?xml version="1.0" encoding="UTF-8"?>
<response><data><post><id>189</id><slug>rate-limit-headers-explained-part-10-189</slug><title>Rate limit headers explained, part 10</title><excerpt>For part 10, we revisit the basics with a fresh example and a few lessons learned the hard way. A well-behaved API tells you how many requests you have left before it starts saying no. Reading those…</excerpt><seriesName>Rate limit headers explained</seriesName><seriesPart>10</seriesPart><sections><item><heading>Introduction</heading><paragraphs><item>For part 10, we revisit the basics with a fresh example and a few lessons learned the hard way. 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>Common pitfalls</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>Read the site's terms of service before you start. Many sites welcome automated access within limits and say so explicitly; others ask you to use an API instead.</item></paragraphs></item><item><heading>Putting it into practice</heading><paragraphs><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><item>Write small, focused tests for your parsers using saved HTML fixtures. They run in milliseconds and catch layout changes long before a full crawl would.</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>11</authorId><authorName>Oliver Kim</authorName><authorSlug>oliver-kim</authorSlug><category>APIs</category><tags><item>http</item><item>ethics</item><item>playwright</item><item>javascript</item></tags><publishedAt>2024-08-21T00:00:00.000Z</publishedAt><wordCount>195</wordCount><readingTimeMinutes>2</readingTimeMinutes></post></data></response>
