Pagination
A lot of the time, when you’re making calls to the Lending API, there’ll be a lot of results to return. For that reason, the results are paginated (returned in a series of pages
) to ensure easy management.
Not all API endpoints support or require pagination, but it is often used when result sets are large.
Fundamentals of Pagination
Making calls to endpoints that use pagination requires the use of the limit
, offset
parameters.
limit
- An integer with the number of items to include in the response.offset
- An integer with the number of items to skip in the response.
Endpoints that use pagination will respond to an initial request with the first page of results, and provide the limit
, offset
and total_items
parameters within the pagination
object in the JSON response.
total_items
- The total number of items available in the dataset, which can be larger than the number of items included in the response.
If additional pages of results are required, the call can be repeated with a different offset
value.
For example, if you make a request for a large list and set
limit
to 10 andoffset
to 0, you will obtain the first 10 items in the list. Make the call again with the samelimit
andoffset
set to 10, and you will get the next ‘page’ of results.
Results are delivered in reverse-chronological order. This is true within individual pages, as well as across multiple pages:
- The first item in the first response will be the most recent.
- The last item in the last response will be the oldest.
- The
limit
request parameter enables you to configure the number of items returned per response page. There will be a defaultlimit
and a maximum allowed value for it.