Some API endpoints return potentially large result sets and support pagination. We provide an easy and pythonic way to work with these paginated endpoints as iterators.
The following endpoints support pagination:
client.get_sleep_log_list()client.get_activity_log_list()client.get_ecg_log_list()client.get_irn_alerts_list()
By default, all endpoints return a single page of results with pagination metadata:
# Get a single (the first) page of sleep logs
sleep_data = client.get_sleep_log_list(
before_date="2025-01-01",
sort=SortDirection.DESCENDING,
limit=10
)When you need to process multiple pages of data, use iterator mode:
iterator = client.get_sleep_log_list(
before_date="2025-01-01",
sort=SortDirection.DESCENDING,
limit=10,
as_iterator=True # Creates an iterator for all pages
)
# Process all pages - the iterator fetches new pages as needed
for page in iterator:
# Each page has the same structure as the standard response
for sleep_entry in page["sleep"]:
print(f"Sleep log ID: {sleep_entry['logId']}")Different endpoints support different pagination parameters, but they generally follow these patterns:
| Parameter | Description | Constraints |
|---|---|---|
before_date |
Return entries before this date | Must use with sort=SortDirection.DESCENDING |
after_date |
Return entries after this date | Must use with sort=SortDirection.ASCENDING |
limit |
Maximum items per page | Varies by endpoint (10-100) |
offset |
Starting position | Usually only 0 is supported |
sort |
Sort direction | Use SortDirection.ASCENDING or SortDirection.DESCENDING |
Each paginated endpoint has specific constraints:
- Max limit: 100 entries per page
- Date filtering:
before_dateorafter_date(must specify one but not both)
- Max limit: 100 entries per page
- Date filtering:
before_dateorafter_date(must specify one but not both)
- Max limit: 10 entries per page