1. U4 ERPx
  2. API Reference
  3. ObjectAPI
  4. Working with large volumes
  5. Pagination (optimised)

Pagination (optimised)

An optimised pagination using last read keys

Introduction

This is an optimised pagination strategy where only the limit query parameter is used (no offset), but on each subsequent request, we use the last read key values from the previous page. We need to make sure that we also order the request based on the key fields.

Flow

The first call would be:

/v2/objects/general-ledger-transactions? \
    &companyId=U4Demo \
    &posted=true \
    &limit=10000 \
    &orderBy=companyId,transactionNumber,additionalInformation/sequenceNumber

Assuming that the last-read item has the following keys:

[  
    {
        "additionalInformation": {
            "sequenceNumber": 9
        },
        "companyId": "U4Demo",
        "transactionNumber": 1500048427
    }
]

The next call would be:

/v2/objects/general-ledger-transactions? \
    &companyId=U4Demo \
    &posted=true \
    &filter=((transactionNumber gt 1500048427) or \
            (transactionNumber eq 1500048427 and additionalInformation/sequenceNumber gt 9)) \
    &limit=10000 \
    &orderBy=companyId,transactionNumber,additionalInformation/sequenceNumber

Advantages

  • More efficient for large datasets
  • Better consistency during data modifications
  • Avoids performance degradation with high offset values
  • Suitable for streaming large volumes of data