Skip to main content

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 checking hasNext:

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
Requesting more than 100 items per page will result in a 400 Bad Request validation error.

Best Practices

  • 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 before fetching the next page. This prevents unnecessary API calls when you have reached the end of the results.
Add small delays between requests when fetching multiple pages to avoid hitting rate limits. See Rate Limits for details.
Cache paginated results to reduce redundant API calls, especially for data that does not change frequently.
Apply filters to narrow results before paginating, reducing the total number of pages and API calls needed.

Troubleshooting

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.
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.
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.

Rate Limits

Understand API rate limiting

Error Handling

Handle pagination errors

List Expenses

Expenses list endpoint

Webhooks

Real-time event notifications