Page Based Data Fetching
In CRS, it is common to fetch entities page-by-page to efficiently retrieve large sets of data. This method ensures optimized performance and reduced server load. All requests following this approach use the following generic properties:
Pagination Parameters
offset
– Specifies the starting point of the current page (for the first page, this value is0
).count
– Defines the size of the current page (number of entities returned per request).includeOverallEntryCount
(optional) – Iftrue
, the response will include the total number of entities matching the filter and sorting criteria.
Fetching Entities Page-by-Page
When retrieving paginated data, the following approach is recommended:
- Choose an appropriate
page_size
(e.g.,100
entities per page). - First Request: Set
offset = 0
,count = page_size
, andincludeOverallEntryCount = true
.- The response will include an array of entities along with an additional property
overallEntryCount
, which contains the total number of matching entities.
- The response will include an array of entities along with an additional property
- Subsequent Requests: Use the already fetched entity count to calculate the next
offset
value.- Example:
- Request 1:
offset = 0
,count = page_size
,includeOverallEntryCount = true
- Request 2:
offset = 1 * page_size
,count = page_size
,includeOverallEntryCount = false
- Request 3:
offset = 2 * page_size
,count = page_size
,includeOverallEntryCount = false
- Continue until all data is fetched.
- Request 1:
- Example:
Best Practices
- Set
includeOverallEntryCount = true
only for the first request, as the total count remains unchanged for the same filter and sorting criteria. This avoids unnecessary processing overhead. - Optimize page size based on API response time and dataset size.
- Ensure the
offset
calculation is correct to prevent missing or duplicating records.
Use Cases
This pagination method is applicable in all scenarios where data should be retrieved in segments, such as:
- Webshop Integrations (fetching product listings, order history, customer data, etc.).
- Inventory Management (retrieving stock availability across multiple warehouses).
- Financial Transactions (retrieving paginated payment or invoice records).