Overview
All Smartbills API list endpoints return paginated results. Pagination allows you to efficiently retrieve large datasets by splitting them into smaller pages.Request Parameters
All list endpoints accept these pagination and sorting parameters:integer
default:"1"
Page number to retrieve (starts at 1)
integer
default:"20"
Number of items per page. Minimum: 1, Maximum: 100, Default: 20
string
default:"createdAt"
Field to sort results by (e.g.,
createdAt, date, amount)string
default:"desc"
Sort direction:
asc (ascending) or desc (descending)Response Format
Paginated responses include both the data array and a pagination metadata object:Pagination Object
object
Pagination metadata
Basic Examples
First Page
Retrieve the first page of results with sorting:Next Page
Navigate to the next page by checkinghasNext:
Iterating Through All Pages
Simple Iteration
Loop through all pages to retrieve all results:With Error Handling and Rate Limiting
Production-ready pagination with error handling:Pagination with Filters
Combine pagination with filtering to narrow your results:Pagination Limits
Maximum Page Size
- Maximum: 100 items per page
- Default: 20 items per page
- Minimum: 1 item per page
Best Practices
Use Appropriate Page Sizes
Use Appropriate Page Sizes
- Small pages (20-50): Better for UI pagination and faster initial response
- Large pages (100): Better for batch processing and fewer API calls
- Default (20): Good balance for most use cases
Always Check hasNext
Always Check hasNext
Always check
hasNext before fetching the next page. This prevents unnecessary API calls when you have reached the end of the results.Handle Rate Limits
Handle Rate Limits
Add small delays between requests when fetching multiple pages to avoid hitting rate limits. See Rate Limits for details.
Cache Results When Possible
Cache Results When Possible
Cache paginated results to reduce redundant API calls, especially for data that does not change frequently.
Use Filters to Reduce Data
Use Filters to Reduce Data
Apply filters to narrow results before paginating, reducing the total number of pages and API calls needed.
Troubleshooting
Empty results on a valid page
Empty results on a valid page
Possible causes: Data was deleted between requests, filters are too restrictive, or a race condition with concurrent modifications. Solution: Refetch from the beginning or adjust your filters.
Inconsistent page counts
Inconsistent page counts
Reason: This is normal. Data can be added or removed while you are paginating. Solution: Use
hasNext instead of relying on totalPages for iteration logic.Slow pagination performance
Slow pagination performance
Solutions: Use larger page sizes (up to 100), add filters to reduce the total dataset, cache results, or use webhooks for real-time updates instead of polling.
Related Resources
Rate Limits
Understand API rate limiting
Error Handling
Handle pagination errors
List Expenses
Expenses list endpoint
Webhooks
Real-time event notifications