Work with Get[Something]Page requests

In CRS often used way  possibility to fetch some entities page-by-page. All requests for such cases use some generic properties:

[offset] - current page start (for first page - 0),

[count] - current page size,

[includeOverallEntryCount] - optional fields that indicates that along with entities of current page response should contain information about how many entities exists at all for filter and sort info described in request.

Following approach may be used to fetch all entities by filter page-by-page:

  • should be considered  [page_size]  (for example 100).

  • in first products page request [offset] should be 0, [count] should be [page_size] and [includeOverallEntryCount] should be true. Then in response value along with 100 entities of first page in property "entries" will be available property [overallEntryCount]" with entire count of products that can be fetched by this request parameters.

  • For next request [offset] should be amount of already fetched entities, page size should be the same and [includeOverallEntryCount]  should be false because we already know count for example: request 2: [offset] = 1*page_size, [count] = page_size, request 3: [offset] = 2*page_size, [count] = page_size, and so on till all products will be fetched.

I suggest to set [includeOverallEntryCount]  only for request of first page because for other pages with same filter overall count will remains immutable and its' calculation is time-consuming.

This offset/count management approach may be used in all cases when data should be fetched by pages.