Paginate A Third-Party Integration API With Rate-Limit Backoff
Last updated: November 29, 2026
Quick Overview
Write a generator that pulls every record from a cursor-paginated third-party API, retrying a page when the API returns HTTP 429 using the server's Retry-After hint when present and capped exponential backoff with jitter otherwise.
Vanta
November 29, 20260
0
0 solved
Write a generator that pulls every record from a cursor-paginated third-party API, retrying a page when the API returns HTTP 429 using the server's Retry-After hint when present and capped exponential backoff with jitter otherwise.
Vanta's integrations pull users, repos, buckets and devices from hundreds of vendor APIs on a schedule, and every one of them paginates and rate-limits differently. The interviewer is checking practical API hygiene: correct cursor handling, bounded retries, respecting server hints, and code that is testable without real sleeps.
What the Interviewer Expects
- Follows the cursor until the API signals the last page
- Retries only the failed page, not the whole crawl
- Honors Retry-After and otherwise uses capped exponential backoff with jitter
- Bounds retries and surfaces the error instead of looping forever
- Injects the sleep function so the code is unit-testable
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you resume a crawl that died halfway through after a deploy?
- How do you share one rate limit budget across many workers hitting the same customer's Okta tenant?
- What if the API returns duplicate records across pages because data changed mid-crawl?
- Which errors besides 429 should be retried, and which must not be?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
fetch_page(cursor) returns (items, next_cursor) or raises RateLimited(retry_after). We should stream items lazily (a large Google Workspace tenant can have hundreds of thousands of users), stop ...
High-Level Design
Outer loop walks pages; inner loop retries the current page. Delay is the server's Retry-After when given, otherwise full jitter: a uniform random value in [0, min(cap, base * 2^attempt)]. Jitter ...