Spec a script that downloads a paged API
Your task
Your company is leaving its help desk vendor, and you need a Node script that copies every ticket out of the vendor's REST API into a local file. There are about 300,000 tickets. The API returns 100 per page, with a cursor for the next page, and now and then it answers 429 (too many requests) or 503 (briefly unavailable). An agent will write the script.
Write the spec you would hand the agent.
What you know:
GET /v1/tickets?cursor=<c>returns{ "data": [...], "next_cursor": "..." }, andnext_cursoris null on the last page- a 429 response includes a
Retry-Afterheader, in seconds - the vendor allows 10 requests per second
- a full run takes about 20 minutes, and you would rather not start over if it stops halfway
Then, in a few sentences: what does "fetch all pages from this API" get wrong?