Prerequisites
Understanding Pagination
The Claro API uses cursor-based pagination for list operations:Cursor-based pagination is more reliable than offset-based pagination, especially when data is being added or removed during iteration.
Example 1: Basic Pagination
Fetch the first page of prompts:Expected output
Expected output
Example 2: Fetch Next Page
Use the cursor to fetch the next page:Example 3: Iterate Through All Pages
Loop through all pages to get all prompts:Example 4: Iterate with Limit
Fetch a specific maximum number of prompts:Example 5: Process While Paginating
Process prompts as you fetch them (memory efficient):Example 6: Generator Pattern
Use a generator for memory-efficient iteration:Example 7: Filter While Paginating
Filter prompts while iterating:Example 8: Paginate with Progress
Show progress while paginating:Example 9: Parallel Processing
Process pages in parallel (advanced):Example 10: Save and Resume
Save pagination state to resume later:Example 11: Page Size Optimization
Find optimal page size for your use case:Larger page sizes reduce the number of API calls but may increase response time. Find the balance that works for your application.
Example 12: Error Handling During Pagination
Robust pagination with error handling:Next Steps
Basic Usage
Learn basic SDK operations
File Downloads
Download context files
Error Handling
Handle errors gracefully
Advanced Patterns
Production-ready patterns