Pagination and Filtering

Pagination and filtering #

Every list endpoint (GET /account, GET /transaction, GET /category and so on) returns a page of results:

{
  "status": "success",
  "data": [ { "id": 7, "name": "Clients", "account_type": "RECEIVABLE", "type": "Receivable" } ],
  "meta": { "current_page": 1, "per_page": 5, "total": 23, "last_page": 5 }
}
ParameterDefaultRange
perPage51 to 200
page11 to meta.last_page

Results are always ordered by id, so paging through them is stable.

Filters #

Filters narrow a list on the server. They combine, and they apply on every page.

EndpointParameterMatches
GET /accountaccount-typeExactly. One of the codes listed in /meta under vocabularies.account_types, e.g. RECEIVABLE
nameCase-insensitive substring
category-idExactly
currency-idExactly
GET /transactiontransaction-typeExactly, e.g. IN
account-idExactly
start-date, end-datetransaction_date within the range, inclusive
GET /categorycategory-typeExactly
curl "https://api.microbooks.io/books/v1/account?account-type=RECEIVABLE&perPage=50" \
  -H "Authorization: Bearer $TOKEN"

An invalid filter value, such as an unknown account type, is a 422, not an empty page. A parameter the endpoint does not accept is also a 422; see Conventions.