• Pagination

Pagination

Unless specified otherwise in the endpoint documentation, all list endpoints will return Length aware pagination response, which mean they will always have the total count of results and the remaining pages on the returned response.

The pagination return response will have:

  1. data: which hold the requested records.
  2. links: which has the following keys:
    1. first: the full URL of the first page.
    2. last: the full URL of the last page.
    3. prev: the full URL of the previous page if applicable, otherwise null.
    4. next: the full URL of the next page if applicable, otherwise null.
  3. meta: which has the following keys:
    1. current_page: int
    2. from: int or null if the result is empty
    3. last_page: int
    4. links: array of {url: full URL|null, label: string, active: bool}
    5. path: string
    6. per_page: int
    7. to: int or null if result is empty
    8. total: int

Parameters

Unless specified otherwise in the endpoint documentation, all pagination endpoints accept the following parameters:

Key Type default Description
page string 1 The page number
limit int 15 Define how many result are returned per request, max is 100
search string - Search (what keys this search depends on the endpoint)
order string created_at Ordering the results (keys to order by depends on the endpoint)
direction string desc The direction of the order

Response example

{
    "data": [],
    "links": {
        "first": "http://localhost/api/contacts?search=tjrbeh123123&page=1",
        "last": "http://localhost/api/contacts?search=tjrbeh123123&page=1",
        "prev": null,
        "next": null
    },
    "meta": {
        "current_page": 1,
        "from": null,
        "last_page": 1,
        "links": [
            {
                "url": null,
                "label": "« Previous",
                "active": false
            },
            {
                "url": "http://localhost/api/contacts?search=tjrbeh123123&page=1",
                "label": "1",
                "active": true
            },
            {
                "url": null,
                "label": "Next »",
                "active": false
            }
        ],
        "path": "http://localhost/api/contacts",
        "per_page": 15,
        "to": null,
        "total": 0
    }
}