Overview
The MTB Backend API uses page-based pagination to handle large datasets efficiently. All list endpoints return paginated results with metadata about the total number of items and pages.Pagination Parameters
Control pagination using thepagination query parameters:
| Parameter | Type | Description | Default | Maximum |
|---|---|---|---|---|
pagination[page] | integer | Page number to retrieve | 1 | - |
pagination[pageSize] | integer | Number of items per page | 25 | 100 |
The default page size is 25 items, with a maximum of 100 items per page as configured in the API settings.
Basic Usage
Pagination Response Format
Paginated responses include both data and metadata:Response Fields
Array of resources for the current page
Pagination Limits
The API enforces the following limits (configured inconfig/api.ts):
- Default limit:
25items per page - Maximum limit:
100items per page - Count included: Total count is always included in responses (
withCount: true)
Requesting a
pageSize greater than 100 will automatically be capped at the maximum limit of 100 items.Iterating Through Pages
Use the pagination metadata to iterate through all pages:Combining with Filters and Sorting
Pagination works seamlessly with filtering and sorting:Disabling Pagination
For small datasets, you can disable pagination to retrieve all results at once:Use with caution: Disabling pagination on large datasets can impact performance and response times. This is only recommended for collections with a known small number of items.
Best Practices
Optimize Page Size
Optimize Page Size
Choose an appropriate page size based on your use case:
- Small page sizes (10-25): Better for UI pagination, faster initial response
- Large page sizes (50-100): More efficient for data processing, fewer requests
- Maximum page size (100): Use when fetching all data in batches
Handle Edge Cases
Handle Edge Cases
Always check pagination metadata before processing:
Cache Pagination Results
Cache Pagination Results
For frequently accessed pages, consider caching:
- Cache individual pages with appropriate TTL
- Invalidate cache when data changes
- Store pagination metadata separately
