Skip to content

Pagination

Every BioTime list endpoint returns a standard envelope:

json
{
    "count": 42,
    "next": "http://.../?page=2",
    "previous": null,
    "data": [ /* ... */ ]
}

Every list-style resource (Attendances, Employees, Devices, Departments, Positions, Areas, Resigns) exposes this envelope through two consistent methods.

list() — one page

Returns the raw envelope, with data mapped to DTOs. Use this when you need count/next/previous to build your own pagination UI, or you only want one specific page.

php
$page = $biotime->employees()->list(
    page: 2,
    perPage: 100,
    filters: ['ordering' => '-first_name'],
);

echo $page['count'];    // total matching records
echo $page['next'];     // URL for the next page, or null

foreach ($page['data'] as $employee) {
    echo $employee->firstName;
}

all() — every page

Walks every page automatically (via the shared AbstractResource::fetchAll() helper) and returns a flat array of DTOs. Use this when you just want "everything that matches these filters," and don't care about manual pagination.

php
$allEmployees = $biotime->employees()->all(
    perPage: 200,
    filters: ['ordering' => 'first_name'],
);

foreach ($allEmployees as $employee) {
    echo $employee->firstName;
}

Internally, fetchAll() requests page=1 with the given page_size, appends every row from data, then keeps requesting the next page as long as the response's next field is non-empty and the current page returned at least one row.

Choosing perPage

perPage (sent to the API as page_size) defaults to 50 for list() and 200 for all(). A larger perPage in all() means fewer HTTP round-trips to fetch everything, at the cost of a larger single response per page. Adjust it based on how large your dataset typically is.

Attendances has extra positional parameters

Attendances::list() and Attendances::all() take startTime/endTime as the first two arguments (a date range), before pagination and filters — see Attendances.

Devices and Resigns

Devices and Resigns follow the exact same list()/all() convention as the other resources, on top of their own endpoints (/iclock/api/terminals/ and /personnel/api/resigns/).

Distributed under the MIT License.