Pagination & sorting

Using the pageable object, you can define pagination for the objects you want to request, filter, and sort them.

In this article:

Pagination

When you request a collection of objects over the API, the results are returned in portions. This approach is called “pagination.”

To define the portions, you send the limit and offset query parameters (as a part of the pageable object in Swagger). By default, you get 30 objects (limit=30) starting from the beginning (offset=0).

Copy

pageable

{
  "limit": 30,
  "offset": 0
}

The pageable object includes the following query parameters.

Parameter

Type

Description

certifiedOnly

boolean

A filter to return only certified objects if set to True. Otherwise, all types of objects are returned.

limit

integer($int32)

The maximum number of results to return in the response. By default, it is set to 30.

For example, to get a number of storyboards to display on a page, the application’s UI sets the limit to 35 by default. When you scroll down, the limit is incremented, 70, 105, and so on.

offset

integer($int32)

Offset is the position of a record in the table. You can return a subset of records starting with an offset value. In other words, this is a number of records to skip from the beginning. By default, it is set as 0.

The offset and limit parameters work together. Valid values for the offset parameter are multiples of the limit. For example, if you define the limit as 0, 35, you can define offset as 70, 105, or any multiple of 35.

search

string

Search by a phrase in names and tags.

For example, you can search for storyboards by “sales” to show the storyboards that have a tag named “sales” or include “sales” in the name.

sort

string

Sort the results by the various fields depending on a resource type. For details, see Sorting.

Sorting

Sorting refers to having the server order the results by a field and returning the results in the requested order. Each sort value consists of a field name that is eligible for sorting and a direction specifier. The direction specifier can be :ASC or :DESC and is appended to the name of the field.

For example, the following code will have the server return 30 most recent storyboards:

Copy
{
  "limit": 30,
  "offset": 0,
  "sort": "SB.UPDATED:DESC"
}

The request URL applies the pageable object and appends parameters to the query:

Copy
https://{server}/sb/api/v1/storyboards/my?certifiedOnly=false&limit=3&offset=0&search=product&sort=SB.UPDATED%3ADESC

Depending on the type of the resource, you can sort by the different fields.

Filtering

You can filter storyboards, datasets, data connections, and AI connections by certification (certified or not) and also by using the search parameter.

For example, the following code makes the server return only certified objects that contain “marketing” either in the object’s name or tag:

Copy
{
  "certifiedOnly": true,
  "limit": 30,
  "offset": 0,
  "search": "marketing"
}
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.