Skip to content

Pagination & Sorting

List endpoints return paginated results by default.

Pagination

Control pagination with page and size query parameters:

http
GET /api/v1/acme-corp/sales/Customer?page=0&size=50
ParameterDefaultDescription
page0Page number (zero-based)
size20Records per page

Response Metadata

Every list response includes a meta object with pagination info:

json
{
  "data": [ ... ],
  "meta": {
    "page": 0,
    "size": 20,
    "totalElements": 150,
    "totalPages": 8
  }
}
FieldDescription
pageCurrent page number
sizeRecords per page
totalElementsTotal number of records matching the query
totalPagesTotal number of pages

To get the next page, increment the page parameter:

bash
# Page 1 (first 20 records)
GET /api/v1/acme-corp/sales/Customer?page=0&size=20

# Page 2 (records 21-40)
GET /api/v1/acme-corp/sales/Customer?page=1&size=20

# Page 3 (records 41-60)
GET /api/v1/acme-corp/sales/Customer?page=2&size=20

When page exceeds totalPages, the data array is empty.

Sorting

Sort results with the sort parameter in field,direction format:

http
GET /api/v1/acme-corp/sales/Customer?sort=name,asc
DirectionDescription
ascAscending (A-Z, 0-9, oldest first)
descDescending (Z-A, 9-0, newest first)

Examples

Sort by name alphabetically:

?sort=name,asc

Sort by creation date, newest first:

?sort=createdAt,desc

Combining with Pagination

All parameters can be combined:

?page=0&size=50&sort=name,asc

SchemaStack Documentation