Pagination

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


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
    Integer
    Description

    Number of records to skip. Defaults to 0.

  • Name
    take
    Type
    Integer
    Description

    Number of records to return. Defaults to 25.

Response Meta

  • Name
    meta['count']
    Type
    Integer
    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,
)

puts page1.data          # Array of bookings
puts page1.meta["count"] # Total count, e.g. 154

# Fetch page 2
page2 = client.bookings.list(
  organisation: "org-id",
  skip: 20,
  take: 20,
)

list_all

Auto-Pagination

Most resources provide a list_all method that returns an Enumerator. 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

# Iterate one by one
client.bookings.list_all(
  organisation: "org-id",
).each do |booking|
  puts booking["id"]
end

to_a

Collecting All Results

If you need all records in memory at once, call to_a on the enumerator to collect everything into an array.

Collecting All Results

all_bookings = client.bookings.list_all(
  organisation: "org-id",
).to_a

puts "Total: #{all_bookings.length} bookings"