Pagination

View as MarkdownOpen in Claude

Pagination is a feature of our API that you can use to handle responses that contain large datasets, for example, when you retrieve a list of payments.

Instead of returning all the results in one response, we separate the results into pages and return a page for each request. You can then send follow-up requests to retrieve the other pages.

Note: Our SDKs use a different process for pagination. For more information about how to use pagination with our SDKs, go to the SDK’s readMe.

Request parameters

If a method supports pagination, you can use the following query parameters to tailor your results:

  • before - Return results that are before the value that you specify. You can’t use the before parameter in the same request as the after parameter.
  • after - Return results that are after the value that you specify. You can’t use the after parameter in the same request as the before parameter.
  • limit - Specify the maximum number of results we return for each page. If you don’t include a limit parameter, we return a maximum of 10 results for each page.

Note: To retrieve the first page of results, don’t include a before parameter or an after parameter in your request.

Example request

The following example is a request to our List Contacts method. The request limits the results for each page to two results:

$curl -G https://api.payroc.com/v1/processing-accounts/38765/contacts \
> -H "Authorization: Bearer <token>" \
> -d limit=2

Response fields

We return the following fields in the response:

  • limit - Maximum number of results that a page can contain.
  • count - Number of results that we returned in the page.
  • hasMore - Boolean that indicates if there are more results available. If the value is false, you have reached the last page of results.
  • data - Array that contains your results.
  • links - HATEOAS object that contains information about how to navigate to additional pages of results. The object contains the following fields:
    • rel - Relationship of the link to the current page. The value is one of the following:
      • next - Next page of results.
      • previous – Previous page of results.
    • method - HTTP method that you use to retrieve the next page or previous page of results.
    • href - Uniform Resource Identifier (URI) of the next page or previous page.

Example response

The following example is a response from our List Contacts method. The response contains two results, along with a links object that contains a URI to the next page of results.

1{
2
3 "limit": 2,
4 "count": 2,
5 "hasMore": true,
6
7 "links": [
8 {
9 "rel": "next",
10 "method": "get",
11 "href": "https://api.payroc.com/v1/processing-accounts/38765/contacts?after=87926&limit=2"
12 }
13 ],
14
15 "data": [
16
17 {
18 "contactId": 87925,
19 "type": "manager",
20 "firstName": "Jane",
21 "lastName": "Doe",
22 "identifiers": [
23 {
24 "type": "nationalId",
25 "value": "xxxxx4320"
26 }
27 ],
28 "contactMethods": [
29 {
30 "type": "email",
31 "value": "[email protected]"
32 }
33 ],
34 },
35
36 {
37 "contactId": 87926,
38 "type": "representative",
39 "firstName": "Fred",
40 "lastName": "Nerk",
41 "identifiers": [
42 {
43 "type": "nationalId",
44 "value": "xxxxx9876"
45 }
46 ],
47 "contactMethods": [
48 {
49 "type": "email",
50 "value": "[email protected]"
51 }
52 ],
53 }
54
55 ]
56}