In the Unloc API, certain GET endpoints have the capability to return a large number of entities. To efficiently manage and retrieve these entities, paging is supported through the use of the startAfterId
and limit
query parameters.
Note: The default (and maximum) value of limit
is 2500, so in order to retrieve more than 2500 locks (or other entities) you need to implement paging.
How to implement pagination
When the number of entities exceeds the specified limit
, the API response will include a field called startAfterId
. For example, when calling the Get Locks endpoint, the response will be structured as follows:
// GET .../locks?limit=100
{
locks: [...], // 100 locks
startAfterId: "ee6a0d6a-aedc-40ef-8c13-1e0f995243ab"
}
To fetch additional locks, you can make subsequent requests to the Get Locks endpoint, including the startAfterId
as a query parameter. The startAfterId
represents the identifier of the last entity received in the previous response.
// GET .../locks?limit=100&startAfterId=ee6a0d6a-aedc-40ef-8c13-1e0f995243ab
{
locks: [...], // 100 locks
startAfterId: "64828188-0c45-4793-bc34-94233dc8cd2e"
}
When you have retrieved all locks, startAfterId
will be empty.