Choose pagination for an API list
Prompt that sets cursor or page numbers, stable sorting, page size and response format for an API list. Paste it into an AI tool of your choice, which then defines pagination.
- Topic
- Apps & prototypes
- Type
- Prompt
- Level
- Intermediate
- Time
- about 8 min
Results depend on the tool, the model and what you enter.
Result preview
Example: written by our editors, not real AI output.
Recommendation: cursor instead of page numbers, because new orders arrive all the time Sort order: created_at descending, then ID Page size: default 50, at most 200 Request: GET /orders?limit=50&cursor=eyJ0IjoiMTA6MzAiLCJpZCI6OTkxfQ Response: { "data": [...], "next_cursor": "eyJ0Ijo...", "has_more": true } New entries while paging: appear only on the next refresh, never twice Tests: empty list, exactly 50 entries, last page, tampered cursor → 400
Fill in
What you type stays in this browser window. We store and send nothing.
- orders in a shop
- comments under posts
- log entries of a service
- products with filters
- messages in a chat
- a few thousand entries, rarely new ones
- millions of entries, new ones all the time
- grows sharply at month end
- often deleted and re-sorted
- unknown
- own web app with infinite scroll
- mobile app
- partners via a public API
- nightly export
- internal dashboard
Your prompt
You have edited the prompt. Changes in the fields above no longer overwrite it.
This is an instruction for an AI, not the result itself.
Where this prompt works
These AI tools are a good fit for this prompt:
How to use it
- Fill in the fields or tap a suggestion. Leave out names, addresses and other personal data.
- Copy the finished prompt into an AI tool of your choice.
- Have a test page through the whole list twice while entries are added in parallel, and check that every entry appears exactly once.
Why does this work?
Page numbers with offsets are simple but become slow and inaccurate for large or fast-changing lists. A stable sort order and a cursor make paging predictable.
Tips
- Return the cursor as an opaque string. Then you can change the technique behind it later without breaking existing clients.