All jobs / Backend developer / API Development
Backend developer interview question · 1–3 years
The interviewer asks: “How do you paginate a list endpoint?” Strongest answer?
The strongest answer
A stable ORDER BY plus a limit. Keyset/cursor pagination (WHERE (created, id) < last) beats OFFSET for large pages. Always return a next cursor, not “page 7 of unknown.”
Why it works
Exactly. Unordered OFFSET is a dice roll. Cursors stay correct as rows insert, and they use the index instead of skipping N rows.
What a good answer covers
- Stable order + limit.
- Prefer keyset/cursors over deep OFFSET.
- Don't load the table to paginate.
- Whitelist sort fields; never splice them.
Answers that fall short
- Close, but not the strongest: LIMIT/OFFSET with whatever order the database picks.
OFFSET without ORDER BY is undefined. OFFSET with ORDER BY still gets slower as the page number grows. - Weak: Load the whole table and slice it in memory so page numbers stay exact.
Paging in the app after a full read is how you run out of memory on the “simple” list. - Red flag: Let the client send the ORDER BY column name and splice it into SQL.
Client-chosen ORDER BY is identifier injection. Whitelist sort keys.
Who gets asked this
More API Development questions
- The interviewer asks: “Where do you validate input?” Strongest answer?
- The interviewer asks: “PUT versus PATCH?” Strongest answer?
- The interviewer asks: “How should API errors look to clients?” Strongest answer?
- The interviewer asks: “How do you version a public JSON API?” Strongest answer?
- When would you pick gRPC over a JSON REST API, and what do you give up?
- Your OpenAPI document lists every path and method and nothing else. A partner team says integrating still…
- The interviewer asks: “You're building an internal platform API other teams will live on. What changes?”…
- The interviewer asks: “When do you use GET versus POST?” Strongest answer?