Pagination
API Reference - pagination and listing
Cursor Pagination
Most API resources have list API methods. For instance, you can list projects, list runs for a project.
Those methods utilize cursor-based pagination via the starting_after
and ending_before
parameters. Both parameters take an existing pointer value (see below) and return objects in a particular order.
These list API methods share a common structure, taking optional parameters: limit
, starting_after
, and ending_before
.
Please note: Listing parameters are mutually exclusive -- only one of starting_after
or ending_before
may be used.
limit
Limit the number of returned items. Valid values are 1 to 50. The default value is 10.
starting_after
Pagination cursor - if specified, the response will list items created before the pointed item.
ending_before
Pagination cursor - if specified, the response will list items created after the pointed item on reverse chronological order
List API method responses
All "list" API method responses have the has_more
flag, every item of the requested type has a cursor
field that can be used for pagination, for example:
If has_more
value is true, you can get additional items from the "list" API, using cursor-based pagination.
Using items cursor for pagination
Currents' list API methods utilize cursor-based pagination via the starting_after
and ending_before
parameters. Both parameters take an existing pointer value (see below) and return objects in a particular order.
if
ending_before
specified - in reverse chronological orderif
starting_after
is specified - in chronological orderif none specified - in chronological order
The ending_before
parameter returns items created before the pointed item. The starting_after
parameter returns items listed after the pointed item.
For example, given a chronologically ordered list of items in a DB and using pointer1003
as a reference:
starting_after=pointer1003
would return
ending_before=pointer1003
would return (in reverse chronological order)
Offset Pagination
Some API resources don't have a stable cursor, for example - listing spec files for a project is an aggregative query that doesn't have a corresponding stable database entity. We use offset-based pagination for those resources. The resources using offset pagination have an explicit notice.
The responses for such resources have the following shape:
total
field contains the total number of items retrieved by the querynextPage
field contains the next page to be used for retrieving additional items. If the value isfalse
it means all the items were exhausted and no more pages are available.
To retrieve more items from a paginated response, use the following query parameters:
limit
Limit the number of returned items. Valid values are 1 to 50.
page
Pagination cursor - if specified, the response will return items from the spec files list based on a splice operation.
The offset will be calculated as follows:
Last updated