The API provides methods for listing resources. For example, you can list apps, list users, and list contracts. Where pagination is supported, these API list methods share a common structure and accept, at a minimum, the following three parameters: limit, starting_after, and ending_before.
If pagination or cursor are not mentioned on the API reference page, the API will response will include the full list of resources without need for pagination.
Torii's list API methods use cursor-based pagination through the size
and cursor
parameters. An API that supports pagination will return a response including a next_cursor
field. Make an additional API call and use this value for the cursor
query parameter. This will provide the next set of results. Paginate and make additional calls until no next_cursor
is returned.
Example response including a cursor
This is an example response of the GET /users API:
{
"users": [
{}, {}, {}
],
"count": 100,
"total": 253,
"nextCursor": "WzE6NjM1Mzg4NTcsIjY1NFMyMyJd"
}
This call returned 100 results from a total of 253. To get the next 100 results, make an additional API call with the cursor /users?cursor=WzE6NjM1Mzg4NTcsIjY1NFMyMyJd