What is API mocking?
A mock API returns predefined responses in place of a real service so that a frontend, an integration or a test suite can be built and exercised before the backend exists, or without depending on it. Good mocks reproduce the real contract — status codes, headers, pagination, error bodies — otherwise the tests pass against the mock and fail against production.
Read the guide: What is API Testing? How to Test a REST API
How to use Mock Pagination Response
- Choose the style, total item count and page size.
- Select first/middle/last or a specific page.
- Generate and use each page to test list, scroll and "load more" states.
Mock Pagination Response features
- Page, offset, cursor, keyset and Link-header pagination styles
- First, middle and last pages in one run, or any specific page
- Sequential item ids across pages and decodable base64url cursors
- Links, hasNext/hasPrev flags, totals and X-Total-Count header
- Custom item fields and resource name; seedable
Mock Pagination Response example
Second page of three
Input:
Style: page, total: 25, page size: 10, page: 2Output:
{ "data": [ { "id": 11, … }, …, { "id": 20, … } ], "meta": { "page": 2, "pageSize": 10, "total": 25, "totalPages": 3, "hasPrev": true, "hasNext": true }, "links": { "prev": "…?page=1&pageSize=10", "next": "…?page=3&pageSize=10" } }Example: 25 items, page size 10, 3 pages
Page
1 2 3
Item ids
1–10 11–20 21–25 —
Prev/next links
next prev + next prev
Page-based
page=1 page=2 page=3
Offset
offset=0 offset=10 offset=20
Keyset
— after_id=10 after_id=20
Cursor
— cursor=… ({"id":10,…}) cursor=… ({"id":20,…})
A dash under page 1: the first request has no after_id or cursor. Keyset pages carry only a next link. Each request also sends the page size (pageSize, limit or per_page); the Link-header style asks like the page style.
Frequently asked questions about Mock Pagination Response
Which pagination styles are supported?
Page-based (page/pageSize/totalPages), offset/limit, cursor (pageInfo with opaque base64url cursors), keyset (after_id) and GitHub-style Link headers.
Why first, middle and last pages?
They exercise the three states a client must handle: no previous link, both links, and a partially filled final page with no next link. Generate a specific page when you need another one.
Are the cursors decodable?
Yes. Cursors are base64url-encoded JSON such as {"id":10,"dir":"next"} so you can inspect and craft them in tests.
How are item ids assigned?
Sequentially across pages (page 2 of size 10 starts at id 11), so ordering and de-duplication logic can be verified.
References
- OpenAPI SpecificationThe standard for describing REST APIs: paths, operations, parameters, schemas, responses and security schemes.
- RFC 9110: HTTP SemanticsThe meaning of HTTP methods, header fields, status codes and content negotiation, independent of the wire version.
- RFC 8288: Web LinkingThe Link header and link relations (next, prev, first, last) used for API pagination.