Postman Pagination

An API with ten thousand records never sends them all at once. Large responses slow servers, waste bandwidth, and overwhelm apps. Pagination splits a big list into small pages. Learning to request pages in Postman, and to loop through them, is essential for testing any list endpoint.

The Book Analogy

A library does not hand you every book in one pile. It gives you a catalog with numbered pages. You ask for page one, read it, and ask for page two. Pagination follows the same habit: the client asks for one page at a time.

  ALL RECORDS (1000)
  ┌──────┬──────┬──────┬──────┬─────┐
  │Page 1│Page 2│Page 3│Page 4│ ... │   each page holds 10 to 100 items
  └──────┴──────┴──────┴──────┴─────┘
      ▲
   Client asks: "Give me page 1, 10 items"

Three Common Pagination Styles

StyleExampleBest Trait
Page number?page=2&limit=10Easy to understand
Offset?offset=20&limit=10Jump to any position
Cursor?cursor=abc123Stable when data changes quickly

Page Number Style

The client sends a page number and a page size. Page two with ten items per page returns records eleven through twenty.

Offset Style

The client states how many records to skip. An offset of 20 skips the first twenty records and begins at the twenty-first.

Cursor Style

The server returns an opaque marker called a cursor with each page. The client sends that cursor to receive the next page. This style avoids duplicate or missing records when new data arrives between requests.

Try It in Postman

The practice API at https://jsonplaceholder.typicode.com supports page parameters. Send this request:

GET https://jsonplaceholder.typicode.com/posts?_page=2&_limit=5

Open the Params tab and notice that Postman splits the URL into key and value rows. Edit the values there to move between pages. Open the response Headers tab to find X-Total-Count, which reports the total number of posts.

Where APIs Hide Paging Information

  • Response body: fields such as next, nextCursor, or totalPages.
  • Link header: web links labeled next and last.
  • Custom headers: values such as X-Total-Count.

Use Variables for the Page Number

GET {{baseUrl}}/posts?_page={{page}}&_limit=10

Store page as a collection variable with the value 1. A script increases it after every response.

Loop Through Every Page

Place this script in the Post-response tab. Run the request from the Collection Runner with enough iterations, or let the script call itself again with setNextRequest.

const items = pm.response.json();
let page = Number(pm.collectionVariables.get("page") || 1);

pm.test("Page " + page + " returns items", function () {
    pm.expect(items).to.be.an("array");
});

if (items.length === 10) {
    pm.collectionVariables.set("page", page + 1);
    pm.execution.setNextRequest(pm.info.requestName);
} else {
    pm.collectionVariables.set("page", 1);
    pm.execution.setNextRequest(null);
}

A page shorter than the limit signals the final page. Resetting the variable prepares the next run.

Cursor Loop Example

const body = pm.response.json();

if (body.nextCursor) {
    pm.collectionVariables.set("cursor", body.nextCursor);
    pm.execution.setNextRequest(pm.info.requestName);
} else {
    pm.collectionVariables.unset("cursor");
    pm.execution.setNextRequest(null);
}

What to Test on a Paged Endpoint

  • The first page returns the requested number of items.
  • The last page returns fewer items without an error.
  • A page beyond the end returns an empty list or a clear message.
  • No record appears on two different pages.
  • A limit above the allowed maximum is capped or rejected with a 400 status.
  • Negative or zero page numbers produce a clean error response.

Key Points

  • Pagination returns large lists in small pages.
  • Page number, offset, and cursor are the three common styles.
  • Postman's Params tab makes page values easy to edit.
  • Scripts and setNextRequest loop through every page automatically.
  • Edge cases such as empty pages and oversized limits deserve dedicated tests.