Skip to main content

Pagination, filtering, and sorting

Pagination, filtering and sorting

Pagination

Page pagination

Use page and limit:
Example response snippet:

Offset pagination

Use offset and limit:
Example response snippet:

Cursor pagination

Example response snippet:

Sorting

Use ’+’ (ASC) or ’-’ (DESC) as a prefix for each field. If not specified, default is ASC. Multiple fields can be separated by a comma.
In Apivalk, this order_by parameter automatically populates the sorting() bag on the request object, based on the fields allowed in the Route definition. Any field not declared via Route::sorting([...]) (or AbstractResource::availableSortings()) is rejected by the validation middleware with a 422.

Filtering

Filtering allows clients to narrow down results by specifying conditions on fields using flat key-value parameters. Example: retrieve all plugs with phase AC:
Filters may also use parameter names that are not directly bound to object fields. Example: