Pagination¶
All top-level API resources support bulk fetch via the "list" API methods.
For instance, you can list tenants, resources, and available backup policies.
These list API methods share a common structure, taking at least two parameters - limit
and page_token
and returning next_page_token
.
limit
parameter defines how many objects to be returned per single API call.
Note, the specific number of objects returned may differ from the requested number and can be smaller than requested.
Also, in some cases limit
parameter can be ignored altogether, usually when the inappropriate limit
value is passed (e.g. limit = 0).
One should never assume that all the objects have been listed until next_page_token
value returned by request is empty.
page_token
parameter defines a starting point in listing and allows to continue listing from the last returned object by a previous API call identified by next_page_token
response value.
Example¶
When making a GET request to a paginated endpoint https://papi.afi.ai/api/v1/applications/me/installations
one receives the response similar to this:
In order to get the next page of results, take next_page_token
value from the response body, and provide it as the value of the page_token
key in a query to the same endpoint: