Design cursor-based pagination for a list API
PremiumAPI designEasy
- Cursor pagination
- Keyset pagination
- Opaque cursors
Quick answer
This API design interview question asks you to design cursor-based pagination for a list API. Aim for a design that exposes a clear, consistent and safe interface, then explain the resources, requests, responses and error handling. Interviewers want to see how you name resources, version the interface and handle failure cases.
The problem
Design cursor-based pagination for a large list API such as GET /orders, where the biggest merchant has 200 million rows. Offset paging there is slow and returns duplicate or missing rows while new orders arrive; cursors must keep every page fast and stable.
An order-management platform exposes GET /orders to merchants, and its page and offset design has broken down for large merchants. Design a cursor-based pagination contract for this and every other list endpoint in the API, and explain the rules clients must follow.
What must the system do?
- Forward paging: Fetch the first page, then each next page, until there is none.
- Backward paging: Fetch the previous page from any position, for UI tables with previous and next buttons.
How well must it do it?
- Stability: A row is never returned twice and never skipped because of inserts or deletes elsewhere in the list.
- Latency: Any page answers within 100 ms at p95 regardless of how deep it is.
What scale should you design for?
Use these numbers in your estimates.
The scale numbers unlock with this questionUnlock
Key concepts
- Cursor pagination
- Keyset pagination
- Opaque cursors
- Stable ordering
- Offset pagination
- Sorting and filtering
How you’ll practise
- Use cases
- Resources
- Endpoints
- Errors, auth and limits
- Versioning
- Wrap-up
Lala, personalized to you, gives a hint when you ask and reviews your design when you are ready.
What do interviewers look for?
In any API design round.
- Starts from the clients and the use cases
- Names resources and operations consistently
- Defines request and response shapes and status codes
- Covers authentication, rate limits and idempotency
- Plans pagination, filtering and versioning
- Explains how clients learn about and recover from errors
Questions people ask about this interview question
- Which design type is this question?
- It is an API design question. You design cursor-based pagination for a list API and explain your choices the way you would in an interview.
- Is this question asked at entry level?
- It is marked Easy, so it suits engineers who are new to API design interviews. It is also a good warm-up before harder questions.
- What should I cover first?
- Start with the clients, the main use cases and the resources they need. Agree on scope with the interviewer before you design anything.
- Can I practise it for free?
- It is a premium question. Sign up and unlock it once for 10 credits; it then stays unlocked. When you finish, Lala, your personalized AI mentor, can review your design for 30 credits.
Related questions
Updated · Written by the SevyDevy team