About Pagination
When a response from the REST API includes many results, Endor Labs paginates the results and returns a subset of the results. For example, GET/v1/namespaces/{tenant_meta.namespace}/findings only returns 100 findings from the given namespace even if the namespace has more than 100 findings. This makes the response easier to handle for servers and for people.
You can use the additional data from the list response to request additional pages of data.
This article explains how to request additional pages of results for paginated responses and how to change the number of results returned on each page.
Fetch all resources with --list-all
The endorctl CLI provides the --list-all flag that allows you to fetch all results. Internally, endorctl handles the pagination through multiple requests.
Using page_size
The page_size field allows you to control the number of elements returned. By default, this value is 100, with a maximum of 500. The higher this value is, the longer it may take to get a result.
- endorctl
- curl
Iterating through results
You can iterate through results using thepage_id or page_token fields.
Using page_id
When a response spans multiple pages, it includes a next_page_id value. Use this value to fetch additional pages of results.
For example, the response to the above request contains the first 50 elements in the objects field along with the following values in the response field:
next_page_id value as the value of page_id in the next request. For example:
- endorctl
- curl
Using page_token
page_token and next_page_token provide the same pagination capability as page_id and next_page_id, using a numeric offset instead of a cursor. However, we recommend using page_id and next_page_id as they offer better performance for the request.