Pagination
The SDK provides two approaches to pagination: manual control via ListAsync() and automatic async iteration via ListAllAsync().
Manual Pagination
All ListAsync() 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
SkipandTaketo calculate pages.
Manual Pagination
// Fetch page 1 (first 20 records)
var page1 = await client.Bookings.ListAsync(new ListBookingsParams
{
Organisation = "org-id",
Skip = 0,
Take = 20,
});
Console.WriteLine(page1.Data.Count); // Items on this page
Console.WriteLine(page1.Meta.Count); // Total count, e.g. 154
// Fetch page 2
var page2 = await client.Bookings.ListAsync(new ListBookingsParams
{
Organisation = "org-id",
Skip = 20,
Take = 20,
});
Auto-Pagination
Most resources provide a ListAllAsync() method that returns an IAsyncEnumerable. This automatically fetches pages in
the background 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 await foreach
// Iterate one by one
await foreach (var booking in client.Bookings.ListAllAsync(
new ListBookingsParams
{
Organisation = "org-id",
}))
{
Console.WriteLine($"{booking.Id} {booking.CustomerName}");
}
Collecting All Results
If you need all records in memory at once, use the Paginator.ToListAsync() helper to collect the full IAsyncEnumerable into a list.
- Name
Paginator.ToListAsync(source)- Type
- static method
- Description
Accepts any
IAsyncEnumerable<T>and returns aTask<List<T>>of all items.
Collecting All Results
using Felloh;
using var client = new FellohClient(new FellohConfig
{
PublicKey = "your-public-key",
PrivateKey = "your-private-key",
});
var allBookings = await Paginator.ToListAsync(
client.Bookings.ListAllAsync(new ListBookingsParams
{
Organisation = "org-id",
}));
Console.WriteLine($"Total: {allBookings.Count} bookings");
