Pagination and Sorting

Pagination

All listing endpoints in the new standard of Core API are paginated. To list a few: list products, list customers and list tasks endpoints are all paginated. These list endpoints share the same structure and have parameters: limit and page to allow for specific pagination of results:

  • limit: argument can be passed into the request via query parameter to change the number of results per page

  • page: argument can be passed into the request via query parameter to change the page of results that you are viewing in the response

In each paginated response, information about the next page of the result set is included. hasMore boolean field indicating if there are next pages. Additionally, nextPageUrl contains the URL of the next (subsequent) page of results if they exist.

Example

Request URL:

https://{{cluster_name}}-{{client_name}}/api/{version}/crm/customers?limit=1

Response:

{
    "resources": [
        {
            "externalId": "customer-Alan-Walker",
            "uuid": "a13ed78c-0d31-4f94-8234-f05f4d655af5",
            "firstName": "Alan",
            "lastName": "Walker",
            "prefix": "",
            "suffix": "",
            "disabled": false,
            "image": "https://d3t32hsnjxo7q6.cloudfront.net/devtest/https://randomuser.me/api/portraits/women/24.jpg",
            "dateCreated": "2021-08-26T16:17:32Z",
            "dateModified": null,
            "attributes": [],
            "addresses": []
        }
    ],
    "totalRecords": "39",
    "hasMore": true,
    "nextPageUrl": "https://{{cluster_name}}-{{client_name}}/api/{version}/crm/customers?limit=1&page=2",
    "errors": []
}

Sorting

Along with paginating list endpoints, you can sort the list response as well. Response list data can be sorted using sort query parameter. The fields that are available for sorting include:

  • dateCreated
  • dateModified
  • firstName
  • lastName
  • and more fields depending on the endpoint

Note: Sorting by multiple fields is currently not available.

Direction of sorting can also be set using the sort_direction parameter, which accepts the following (case-insensitive): asc or desc.

Example

Request URL:

`https://{{cluster_name}}-{{client_name}}/api/{version}/crm/customers?sort=firstName&sort_direction=asc

Response:

{
    "resources": [
        {
            "externalId": "customer-Alan-Walker",
            "uuid": "4f4232d7-9f35-4ddc-b731-6e04a65652a3",
            "firstName": "Alan",
            "lastName": "Walker",
            "prefix": "",
            "suffix": "",
            "disabled": false,
            "image": "",
            "dateCreated": "2021-09-13T16:01:13Z",
            "dateModified": "2021-09-29T16:46:59Z",
            "attributes": [],
            "addresses": []
        },
        {
            "externalId": "customer-Andrew-Valeri",
            "uuid": "84d38f81-d8b3-4add-9ba5-61414512e10d",
            "firstName": "Andrew",
            "lastName": "Valeri",
            "prefix": "",
            "suffix": "",
            "disabled": false,
            "image": "https://d3t32hsnjxo7q6.cloudfront.net/devtest/9e0ba91725de490418b2894e599a2c4b.jpg",
            "dateCreated": "2021-08-05T21:41:29Z",
            "dateModified": null,
            "attributes": [],
            "addresses": [
                "09fb28c6-525a-45aa-9acf-151a2c1af96a"
            ]
        },
        .... more results sorted by firstName in ascending order ...
    ],
    "totalRecords": null,
    "hasMore": null,
    "nextPageUrl": null,
    "errors": null
}