Pagination

This page contains a short overview of handling pagination when using the Zenegy API.

Pagination

All endpoints in Zenegy that return lists of data support paging.

Pagination is enforced for performance reasons. The list of items can be large(more than 1000), and fetching the full list can result in slow responses.

In pagination, it is consumers' responsibility to provide the number of items that need to be returned and to track if more items need to be returned.

Zenegy APIs can have different pagination implementations. Some of these implementations are legacy and will be substituted shortly.

Result implementation

This is the most used implementation, in this implementation total number and display number of records is returned.
The receiver is responsible for keeping track of the total records and trying to pull more records if needed.

PropertyDescription
totalRecordsTotal number of records for this action
totalDisplayRecordsTotal number of records returned with this action
dataArray(list) containing the records for this action

Example:

{
  "totalRecords": 100,
  "totalDisplayRecords": 10,
  "data": []
}

In this implementation, the integration party must provide two parameters: the index from where to start(skip), and the number of records to take.

Currently, in Zenegy APIs, we have 3 implementations.

Skip and Take

In this implementation, a skip-and-take number is provided to the API.

  • Skip - The index(position) from which to start getting records
  • Take - Number of records to return

This information can be provided as query params or as a body in a post-call.

  • Query params Example
GET 
https://api.zenegy.com/api/companies/f76431a6-7ba3-4dbd-81f5-bef985b73dad/employees?skip=0&$take=30
  • Body example
POST 
https://api.zenegy.com/api/v2.0/companies/f76431a6-7ba3-4dbd-81f5-bef985b73dad/departments/list
{"skip":0,"take":10}

OData

This legacy implementation is present only in the Payroll Denmark API. It uses the OData protocol's skip and top syntax.
Read more about Odata here

Example:
https://api.zenegy.com/api/companies/f76431a6-7ba3-4dbd-81f5-bef985b73dad/employees?$skip=30&$top=30

Continuation token

In this implementation, the API provides continuation(next page token).
Using this token, the integrating party can retrieve the next data page.

Example:

PropertyDescription
nextPageTokenA string representing the next page token. If the next page is not available, this property will be null
hasNextPageIf the next page is present, this property will be true
dataArray(list) containing the records for this action
{
  "hasNextPage": true,
  "nextPageToken": "[{\"token\":\"+RID:~8FcnAOZwdUgNQgEAAAAAAA==#RT:3#TRC:75#RTD:gbpbHYBOs3+zX69FfoKTBTQ0NAA=#ISV:2#IEO:65551#QCF:3#FPC:AgEEBQRGANWhXoApgRIA4AAAAo6AMQDAAY+EHYAegBWAjYBEgKuDz4AAgBiAWYBmgVEEwAB/gDiAH4AvgDaBuIIiACwZAwDxAQ0I1IAFcAC7gAHAwAAYgPMACwYMAAAgIQAgZhEAACQSAAAMAgCGgBEAEgAxAIABE4ANgDQAAOAfgADA/wAWgBqAMQBgACuAAcDdAlqACIAHgGmAJABwEAkAACAIAE+AQQAAWDIABAEAEBOAQwAAdt9WBwBHgVSA\",\"range\":{\"min\":\"\",\"max\":\"FF\"}}]",
  "data": [ ]
}

In this implementation, the integration party must provide only page size(pageSize), and if pulling a new page, a page token must be provided.
Info can be provided as query parameters (Legacy) or as a body for the action.


What’s Next