DOCS

New!

/

5 minute read

October 2, 2019

Sorting and Pagination

The Core API supports sorting and pagination for most endpoints that return arrays of resources. The sorting mechanism places the resources in order; the pagination mechanism then returns a specific range of those ordered resources. You control sorting and pagination by way of URL query parameters.

A GET request to the /users endpoint returns an array of users. By default, the sorting mechanism places the most recently modified users at the top of the sort order (sort_by=-lastModifiedTime) and the pagination mechanism then returns the first five users (count=5&start_index=0). The following URL shows this default setting in an explicit form:

/users?count=5&start_index=0&sort_by=-lastModifiedTime

Is this helpful?

The next five users in the sort order could then be returned with this URL (the start_index is now set to 5):

/users?count=5&start_index=5&sort_by=-lastModifiedTime

Is this helpful?

Query parameter details

The following table provides details on the URL query parameters that control sorting and pagination of returned arrays.

Query Parameter Description Default Value Allowable Values

sort_by

Field on which to sort. Use any field in the resource model, or one of the system fields lastModifiedTime or createdTime. Prefix the field name with a hyphen (-) to sort in descending order. Omit the hyphen to sort in ascending order.

‑lastModifiedTime

lastModifiedTime, createdTime, any field in the resource model

count

Specifies the number of resources to return.

5

1–100

start_index

Specifies the sort order index from which to begin returning data.

0 (the first row)

Any integer

Response field details

Name Type Description Allowable Values

count

integer

The number of resources returned.

1–100

start_index

integer

The sort order index of the first resource in the returned array.

Any integer

end_index

integer

The sort order index of the last resource in the returned array.

Any integer

is_more

boolean

A value of true indicates that more unreturned resources exist.

true, false

data

array of objects

Contains the returned resources.

Sample response body

{
    "count": 10,
    "start_index": 0,
    "end_index": 9,
    "is_more": true,
    "data": [
        ...
    ]
}

Is this helpful?

Have any feedback on this page?

If you feel we can do anything better, please let our team know.

We strive for the best possible developer experience.