Pagination

The SDK provides two approaches to pagination: manual control via list() and automatic iteration via listAll().


list()

Manual Pagination

All list() methods accept skip and take parameters for manual pagination. The response includes a meta.count field with the total number of matching records.

Parameters

  • Name
    skip
    Type
    int
    Description

    Number of records to skip. Defaults to 0.

  • Name
    take
    Type
    int
    Description

    Number of records to return. Defaults to 25.

Response Meta

  • Name
    meta.count
    Type
    int
    Description

    Total number of records matching the query. Use this with skip and take to calculate pages.

Manual Pagination

// Fetch page 1 (first 20 records)
$page1 = $client->bookings->list([
    'organisation' => 'org-id',
    'skip' => 0,
    'take' => 20,
]);

print_r($page1['data']);          // Array of bookings
echo $page1['meta']['count'];     // Total count, e.g. 154

// Fetch page 2
$page2 = $client->bookings->list([
    'organisation' => 'org-id',
    'skip' => 20,
    'take' => 20,
]);

listAll()

Auto-Pagination

Most resources provide a listAll() method that returns a Paginator implementing IteratorAggregate. This automatically fetches pages as you iterate, so you never have to manage skip and take manually.

The iterator fetches 25 records per page internally and yields them one at a time.

Auto-Pagination with foreach

// Iterate one by one
foreach ($client->bookings->listAll([
    'organisation' => 'org-id',
]) as $booking) {
    echo $booking['id'] . ' ' . $booking['customer_name'] . "\n";
}

toArray()

Collecting All Results

If you need all records in memory at once, use the toArray() method on the Paginator to collect all items into an array.

  • Name
    toArray()
    Type
    method
    Description

    Returns an array containing all items from every page.

Collecting All Results

use Felloh\FellohClient;
use Felloh\FellohConfig;

$client = new FellohClient(new FellohConfig(
    publicKey: 'your-public-key',
    privateKey: 'your-private-key',
));

$allBookings = $client->bookings->listAll([
    'organisation' => 'org-id',
])->toArray();

echo 'Total: ' . count($allBookings) . ' bookings';