Question 4Coding
Fetch every record from a paginated API that rate-limits you and sometimes fails.
A very common practical exercise. It looks easy; the follow-ups are about failure.
“Engineering background. You're a genuine builder. Proficient in Python and at least one of TypeScript/JavaScript, Java, or Go; comfortable across data plumbing, APIs, and a bit of front-end when a demo needs it.”Forward Deployed Engineer · NinjaTech AI
The answerFour steps
- 1
Loop on the next-page token until there isn't one
Say it like this
“The happy path is a loop: request a page, yield the records, read next_cursor, stop when it's empty. I write that as a generator in five minutes.”
Why it scores
Gets the simple loop done fast and saves time for what's really being tested.
- 2
Back off and retry on rate limits and temporary errors, with a limit
Say it like this
“Then the real work. On a 429 I sleep for Retry-After if it's set, otherwise exponential backoff with jitter. Timeouts and 5xx errors get the same, up to five tries, then it fails loudly. A 400 never gets retried.”
Why it scores
Retries only what's worth retrying, with a cap. Retrying a 400 forever is a classic bug.
- 3
Save progress so a crash resumes from the last page
Say it like this
“After each page is written, I save the cursor to a file, so a crash at page 1,800 restarts there, not at page one.”
Why it scores
Resumable progress. On a big pull, a crash is a when, not an if.
- 4
Test with a fake API that fails on purpose
Say it like this
“I test it against a fake API that returns a 429 every third call and dies once mid-run.”
Why it scores
Makes failure happen on purpose, so the retry code is proven to run.
StrongAll together
About a minute, out loud. The marked parts are the four steps; hover one to find it above.
Say we're pulling 250,000 support tickets, 100 per page. The happy path is a loop: request a page, yield the records, read next_cursor, stop when it's empty. I write that as a generator in five minutes.1 Then the real work. On a 429 I sleep for Retry-After if it's set, otherwise exponential backoff with jitter. Timeouts and 5xx errors get the same, up to five tries, then it fails loudly. A 400 never gets retried.2 After each page is written, I save the cursor to a file, so a crash at page 1,800 restarts there, not at page one.3 I test it against a fake API that returns a 429 every third call and dies once mid-run.4
WeakThe answer that fails
Sounds fine. Common. Scores low.
“I'd loop through the pages with requests and wrap each call in a try/except that sleeps a few seconds and retries if anything fails, until there are no more pages.”
Interviewer's note
Retries everything forever, bad requests included. A crash on page 1,800 starts again from page one.
PracticeTwo minutes, then they push back
Your turn
Fetch every record from a paginated API that rate-limits you and sometimes fails.
Answer like you're in the room: about two minutes, no notes. Say it out loud, even alone. It feels different from thinking it. Then check your answer against what interviewers score.