Verified Jobs Live
Full Stack Web Development Medium Level ~3 min read

How would you add pagination to an API whose records change frequently?

Interactive Practice Mode
Formulate your thoughts or take notes before revealing the model solution.
Model Answer & Deep-Dive Explanation

Use a stable sort with a unique tie-breaker, such as created_at followed by id. Offset pagination is simple but can skip or repeat records as earlier rows change and can become expensive at large offsets. Cursor pagination encodes the last sort position and queries after it. Bind cursors to relevant filters and validate them. If a fully consistent snapshot is required, define how that snapshot is maintained. Explain whether new records appear on refresh and retu only metadata the client actually needs.