Pagination

Pagination in Trelica

Some API calls can return a lot of results, so must be paginated.

By default Trelica APIs return a maximum of 100 results.

You may also request a maximum number of results to return using the limit query-string parameter. You are not guaranteed to receive that number - you may receive less - it is just an upper limit.

Additional pages of data can be requested using the after query-string parameter. This value should be a pagination token which is supplied to you by Trelica.

Typically the next attribute in the response contains the full URL to request for the next page of data, e.g.

{
    "next": "https://app.trelica.com/api/audit/v1/logs?after=<TOKEN>&limit=100",
    "results": [{
        // ...
    }, {
        // ...
    }]
}

You should continue requesting data until no further results are returned (i.e. until you receive an empty JSON array).

SCIM pagination

Data about Trelica users is returned using the SCIM protocol. This defines a specific pagination scheme, different to the default Trelica one.

This uses startIndex and count query-string parameters, and information is returned in the response JSON to help you request the next page.

Parameter Description
startIndex 1-based offset for the first result to return (defaults to 1)
count Number of results to return (defaults to 100)

If you request /api/scim/v2/users?startIndex=1&count=10, you might get some response JSON like this:

{
    "totalResults": 67,
    "itemsPerPage": 10,
    "startIndex": 1,
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:ListResponse"
    ],
    "Resources": [{
        /* ... */
    },{
        /* ... */
    }]
}

You can keep requesting pages, incrementing startIndex by 10 each time until all results are fetched. So in the example above, your next page request will be to /api/scim/v2/users?startIndex=11&count=10

Was this article helpful?

0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.