Pagination ​
Truto's API uses cursor-based pagination for all list endpoints. This is a way to handle large sets of data effectively and efficiently. Instead of relying on traditional offset-based pagination, cursor pagination provides smoother navigation through the listed items.
Understanding the Response ​
Each call to a list endpoint returns an object containing two main attributes:
result
: This attribute contains the list of resources returned by the current request.next_cursor
: This attribute is a cursor that points to the start of the next page of results. Ifnext_cursor
is null, then there are no more pages to retrieve.
Using the Cursors ​
To fetch the next page of results, use the next_cursor
value from the previous response. This should be included as a query parameter in your next request.
For instance, if the next_cursor
from the last response was abc123
, you would fetch the next page of results by appending ?next_cursor=abc123
to the URL.
Limiting the Results ​
You can limit the number of records returned in a single request by using the limit
query parameter. The limit
parameter defines the maximum number of records to return. For example, ?limit=10
will return up to 10 records from the list.
Example ​
Here's an example of a response from a list call:
{
"result": [
{
"id": 1,
"name": "Resource 1",
...
},
{
"id": 2,
"name": "Resource 2",
...
},
...
],
"next_cursor": "abc123"
}
In this example, result is an array of resources, and next_cursor
is the cursor you would use to fetch the next page of results.