Pagination


Some PactFlow collection resources support pagination.

To maintain backwards compatibility, pagination parameters are optional, but we strongly recommend using pagination when fetching resources with over 100 items, as performance will decline significantly once a large number of items is returned.

To enable pagination, set the following query parameters:

ParameterDescription
pageThe page in the resource collection to return
sizeThe number of resources to include in the paginated response

NOTE: Pages start from 1 and are not zero-indexed.

To maintain backwards compatibility, pagination parameters are optional, but we strongly recommend using pagination when fetching resources with over 100 items, as performance will decline significantly once a large number of items is returned.

An example snippet of a response to the /admin/users?page=3&size=10 endpoint:

{
    "page": {
        "number": 3,
        "size": 10,
        "totalElements": 198,        
        "totalPages": 20
    },
    "_links": {
        "next": {
          "href": "https://foo.pactflow.io/admin/users?size=10&page=4",
          "title": "Next page"
        },
        "previous": {
          "href": "https://foo.pactflow.io/admin/users?size=10&page=2",
          "title": "Previous page"
        },    
        "self": {
          "title": "Users",
          "href": "https://foo.pactflow.io/admin/users?size=10&page=3"
        }
    },
    "users": [
        // ...
    ]
}

Note the inclusion of a _links attribute, containing links to the next and previous pages where they exist, and a page object with information to assist with paginating through the collection. To get all the items, use the next relation until there is no next relation present in the response.