Skip to main content

Overview

All Smartbills API list endpoints support pagination to help you efficiently retrieve large datasets. We use cursor-based pagination for optimal performance and consistency.
Cursor-based pagination: Smartbills uses cursor-based pagination rather than offset-based pagination for better performance and reliability with large datasets.

How Pagination Works

Request Parameters

All list endpoints accept these pagination 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

Response Format

Paginated responses include both data and pagination metadata:

Pagination Object

object
Pagination metadata

Basic Examples

First Page

Retrieve the first page of results:

Next Page

Navigate to the next page:

Iterating Through All Pages

Simple Iteration

Loop through all pages to retrieve all results:

With Error Handling

Production-ready pagination with error handling:

Best Practices

Choose the right page size for your use case:
  • Small pages (20-50): Better for UI pagination, faster initial response
  • Large pages (100): Better for batch processing, fewer API calls
  • Default (20): Good balance for most use cases
Always check if there’s a next page before making the request:
This prevents unnecessary API calls when you’ve reached the end.
Add delays when fetching multiple pages:
See Rate Limits for more details.
Cache paginated results to reduce API calls:
Provide feedback when fetching many pages:

Pagination with Filters

Combine pagination with filtering:

Pagination Limits

Maximum Page Size

  • Maximum: 100 items per page
  • Default: 20 items per page
  • Minimum: 1 item per page
Requesting more than 100 items per page will result in a validation error. The API will return a 400 Bad Request response.

Maximum Pages

There is no hard limit on the number of pages, but:
  • Very large datasets may take time to process
  • Consider using filters to narrow results
  • Implement caching for frequently accessed data

Common Patterns

Infinite Scroll (UI)

Implement infinite scroll in your application:
Implement page-based navigation:

Troubleshooting

Problem: Getting empty results even though pagination says there are more pagesPossible causes:
  • Data was deleted between requests
  • Filters are too restrictive
  • Race condition with concurrent modifications
Solution: Refetch from the beginning or adjust filters
Problem: Total pages changes between requestsReason: This is normal! Data can be added or removed while you’re paginating.Solution:
  • Use hasNext instead of relying on totalPages
  • Implement refresh mechanisms
  • Consider using timestamps to detect changes
Problem: Pagination is slow, especially on later pagesSolutions:
  • Use larger page sizes (up to 100)
  • Add filters to reduce total dataset
  • Cache results when appropriate
  • Consider using webhooks for real-time updates instead

Filtering

Learn how to filter results

Rate Limits

Understand API rate limiting

List Expenses

Expenses list endpoint

Error Handling

Handle pagination errors

Summary

  • ✅ Use page and pageSize parameters
  • ✅ Check hasNext before fetching next page
  • ✅ Maximum page size is 100 items
  • ✅ Add delays between requests for rate limiting
  • ✅ Handle errors gracefully
  • ✅ Cache results when possible
  • ✅ Show progress for large datasets
Performance tip: For batch processing, use the maximum page size (100) to minimize the number of API calls.