Agrofin

Lists, filtering & pagination

On this page 2

Every list endpoint follows one contract (Spatie QueryBuilder under the hood).

Query parameters

Parameter Example Notes
per_page ?per_page=25 Clamped server-side: floor 1, default 10, cap 100
page ?page=2 Standard page number
filter[...] ?filter[search]=term Only filters the endpoint explicitly allows; unknown filters return 400
sort ?sort=-created_at Leading - = descending; only allowed sorts; unknown sorts return 400

Which filters and sorts an endpoint accepts is listed on that endpoint's reference page — the backend defines the contract.

Pagination metadata

List responses carry the paginator under meta.pagination:

json
{
  "meta": {
    "pagination": {
      "total": 42,
      "per_page": 10,
      "current_page": 1,
      "last_page": 5,
      "from": 1,
      "to": 10,
      "path": "https://api.example.com/api/v1/things",
      "first_page_url": "https://api.example.com/api/v1/things?page=1",
      "last_page_url": "https://api.example.com/api/v1/things?page=5",
      "next_page_url": "https://api.example.com/api/v1/things?page=2",
      "prev_page_url": null
    }
  }
}

Page URLs preserve the request's filter/sort/per_page query string.