Design Stable Cursor Pagination for an iCloud Drive Folder Listing API
Last updated: November 29, 2026
Quick Overview
Design and implement a paginated listing endpoint for an iCloud Drive folder that returns consistent pages even while files are added or deleted between requests.
Apple
November 29, 20260
0
0 solved
Design and implement a paginated listing endpoint for an iCloud Drive folder that returns consistent pages even while files are added or deleted between requests.
iCloud Drive clients on Mac, iPhone, and the web page through folders with thousands of files while sync changes them underneath. The interviewer checks API design judgment: offset vs keyset pagination, opaque and tamper-proof cursors, and clear contracts.
What the Interviewer Expects
- Explains why offset pagination skips or duplicates rows under concurrent writes
- Uses keyset pagination on a unique, total sort key such as (name, item_id)
- Makes the cursor opaque, signed, and scoped to the folder and sort order
- Defines response shape, page size limits, and the end-of-list signal
- Discusses versioning the cursor format and what guarantees clients get
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 support sorting by modification date, where many items share a timestamp?
- How do clients learn about changes that happen behind the cursor (items inserted before it)?
- Should cursors expire? How would you handle an old cursor after a schema change?
- How would the API look as a REST endpoint versus a CloudKit-style query operation?
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
GET /folders/{id}/items?limit=N&cursor=...returns items andnext_cursor(null at end).- No item present for the whole listing is skipped or repeated, even with concurrent inserts and deletes. ...
High-Level Design
Offset pagination breaks when a file is inserted before the current offset (you see a duplicate) or deleted (you skip one). Keyset pagination stores the last key returned and resumes strictly after it...