Sorting & Pagination

circle-info

💡 Control the sort order and page of your data list.

Overview

When listing data, use the sortBy, sortDirection, page, and limit parameters to control sorting and pagination of results.


Sorting

sortBy

Specify the field to sort by. Any field in the table can be used as a sort key.

# Sort by createdAt in descending order (newest first)
curl -X GET "https://api-client.bkend.ai/v1/data/posts?sortBy=createdAt&sortDirection=desc" \
  -H "X-API-Key: {pk_publishable_key}"

sortDirection

Value
Description

asc

Ascending (A to Z, 1 to 9, oldest to newest)

desc

Descending (Z to A, 9 to 1, newest to oldest) — default

Sorting Examples

circle-info

💡 If sortBy is not specified, the default sort order (by id) is applied.


Pagination

page / limit

Parameter
Type
Default
Range
Description

page

number

1

1+

Page number

limit

number

20

1-100

Items per page

Basic Usage

Pagination Response

Field
Type
Description

total

number

Total number of records

page

number

Current page

limit

number

Items per page

totalPages

number

Total number of pages

hasNext

boolean

Whether a next page exists

hasPrev

boolean

Whether a previous page exists


Combining Sorting + Pagination + Filters

You can combine all parameters together.

Iterating Through All Data

Use hasNext to iterate through all pages.


Next Steps

Last updated