Bird
Raised Fist0

You want to combine cursor-based pagination with filtering by date in your API. Which approach is best to ensure correct pagination?

hard🚀 Application Q9 of Q15
Rest API - Pagination Patterns

You want to combine cursor-based pagination with filtering by date in your API. Which approach is best to ensure correct pagination?

AReset cursor to null when filters change
BInclude filter parameters in the request and generate cursor based on filtered data
CUse offset pagination for filtered data instead of cursor
DIgnore filters when generating cursor and paginate all data
Step-by-Step Solution
Solution:
  1. Step 1: Understand filtering with pagination

    Filters affect which data is shown, so cursor must reflect filtered results.
  2. Step 2: Generate cursor based on filtered data

    The API should apply filters first, then generate cursor for the filtered dataset to paginate correctly.
  3. Final Answer:

    Include filter parameters in the request and generate cursor based on filtered data -> Option B
  4. Quick Check:

    Cursor must match filtered data for correct pagination [OK]
Quick Trick: Apply filters before cursor generation to paginate filtered results [OK]
Common Mistakes:
MISTAKES
  • Paginating unfiltered data with filters applied client-side
  • Resetting cursor incorrectly on filter change
  • Switching pagination type unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes