Pagination

All endpoints in Zenegy that are returning lists of data are supporting paging.

Pagination is enforced for performance reasons, since list of items can be large(more than 1000) and fetching 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 keep track if there are more items to be retrived.

Zenegy APIs can have different implementation of the pagination. Some of this implementations are legacy and will be substituted in the near future.

Result implementation

This is the most used implementation, in this implementation total number and display number of records is returned. It is responsibility of the receiver to keep track of the total records and to try to pull more records if they are needed.

Property Description
totalRecords Total number of records for this action
totalDisplayRecords Total number of records returned with this action
data Array(list) containing the records for this action

Example:

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

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

Currenly in Zenegy APIs we have 3 implementations.

Skip and Take

In this implementation 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 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 is legacy implementation that is present only in Payroll Denmark api. This implementation uses skip and top syntax of OData protocol.
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 continuation(next page token) is provided back from the api. Using this token integrating party is able to retrieve the next page of data.

Example:

Property Description
nextPageToken String representing the next page token. If next page is not available this property will be null
hasNextPage If next page is present this property will be true
data Array(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 integration party is required to provide only page size(pageSize), and if pulling new page page token has to be provided. Info can be provided as query params(Legacy) or body to the action.