Automatic Pagination
Use the--paginate flag to fetch all pages automatically:
--paginate, the CLI returns only the first page (default limit varies by endpoint, typically 50-200 items).
The
--paginate flag fetches all pages into memory before rendering output. For very large result sets, use manual pagination instead.Manual Pagination
Control page-by-page fetching with--limit and --next:
How Pagination Works
The CLI uses a generic pagination system (internal/asc/client_pagination.go) that:
- Fetches the first page from the API
- Checks for
links.nextin the response - Fetches subsequent pages until
links.nextis empty - Aggregates results into a single response using reflection
- Detects cycles to prevent infinite loops on repeated pagination URLs
Pagination Interface
All paginated responses implement:PaginateAll function works with any response type that follows this interface.
Memory Considerations
Buffered (Default)
With--paginate, all pages are buffered in memory:
- Result set is reasonably sized (< 10,000 items)
- You need table or markdown output
- You want a single aggregated result
Streaming (Advanced)
For very large datasets, some commands support--stream with --paginate:
- Result set is very large (> 10,000 items)
- You need to process results incrementally
- Memory usage is a concern
Streaming mode only works with JSON output. Table and markdown formats require buffering all results.
Pagination Limits
API Limits
The App Store Connect API enforces maximum page sizes per endpoint:- Apps: 200
- Builds: 200
- Beta Testers: 200
- Analytics: 100
--paginate is set.
Setting Custom Limits
Control the page size with--limit:
Error Handling
If a page fetch fails mid-pagination:- Pages fetched before the error are returned
- The error is reported with the page number:
page 3: unauthorized - Exit code reflects the error (see Error Handling)
Cycle Detection
The CLI detects repeatedlinks.next URLs to prevent infinite loops:
Examples
Fetch All Apps
Fetch All Builds for an App
Manual Pagination Loop (Shell Script)
Count All Beta Testers
Implementation Details
The pagination system uses reflection to handle any response type:- Type-safe aggregation using reflection on the
Datafield - Cycle detection with a
seenNextmap - Type validation ensures all pages match the first page’s type
- Context support for cancellation and timeouts
Spinner Indicator
When--paginate is used in an interactive terminal, a spinner appears on stderr:
Best Practices
Use --paginate by Default
Always use
--paginate unless you specifically want only the first page.Combine with Filters
Filter before paginating to reduce API calls:
--filter[platform]=IOS --paginateSave JSON Output
Cache paginated results to avoid repeated API calls during development.
Monitor Rate Limits
Paginating large datasets consumes API rate limits. Use
--limit to control request frequency.Related
- Output Formats - How pagination interacts with different output formats
- Error Handling - Handling errors during pagination
- Filtering & Sorting - Reduce pagination needs with filters
