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| Parameter | Default | Description |
|---|---|---|
page | 0 | Page number (zero-based) |
size | 20 | Records 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
}
}| Field | Description |
|---|---|
page | Current page number |
size | Records per page |
totalElements | Total number of records matching the query |
totalPages | Total number of pages |
Navigating 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=20When 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| Direction | Description |
|---|---|
asc | Ascending (A-Z, 0-9, oldest first) |
desc | Descending (Z-A, 9-0, newest first) |
Examples
Sort by name alphabetically:
?sort=name,ascSort by creation date, newest first:
?sort=createdAt,descCombining with Pagination
All parameters can be combined:
?page=0&size=50&sort=name,asc