SAP Knowledge Base Article - Public

2675265 - OData API: Using the $top and $skip parameters for pagination (Client-Side Pagination)

Symptom

In this document we will review how the $top and $skip parameters work in the context of pagination in an OData API query.

Environment

  • SAP SuccessFactors HXM Suite
    • OData API

Resolution

Note: using $top and $skip parameters is called Client-Side Pagination. Client-Side Pagination is not recommended when handling large amounts of data as it may cause duplicates or missing data in its response, refer to the Disadvantges section of the "Client-Side Pagination" guide page mentioned in the "See Also" section of this KBA. In order to avoid these issues, please use the Server-Side Pagination instead.

How to use $top and $skip to control the pages of records?

$top parameter

It controls the number of records to return in the response, for example:

http://<hostname>/odata/v2/User?$top=5

The response of this query will return the first 5 User entries that the API finds in the database.

More details in the guide page $top.

$skip parameter

It controls the number of records in the full data set to skip before fetching data, for example:

http://<hostname>/odata/v2/User?$skip=2

The response of this query will skip the first 2 User records from the database and return the rest.

More details in the guide page $skip.

Using $top and $skip together:

Using the $top and $skip parameters together in a request creates a pagination query. The response is a subset of the whole result, from $skip to $top. $skip indicates the starting row for the query. $top limits the size of the query.

For example:

http://<hostname>/odata/v2/User?$top=50&$skip=20

The response here will be a subset from numbers 21 to number 70 of the whole result set, meaning that it will skip the first 20 records of the database and return the 50 records that would come next.

See Also

Client-Side Pagination

2489065 - OData API returns a certain amount of records in the response when more are expected

Keywords

top, skip, $top, $skip, client-side, client side, successfactors, sf, , KBA , LOD-SF-INT-ODATA , OData API Framework , How To

Product

SAP SuccessFactors HCM all versions