- Offset-based pagination (default) - Navigate using page numbers
- Cursor-based pagination - Navigate using cursor tokens for large datasets
Offset-based Pagination
The default pagination style. Use page numbers to navigate through results.Query Parameters
| Parameter | Description | Default | Max |
|---|---|---|---|
itemsPerPage | Number of items per page | 20 | 1000 |
page | Page number | 1 | - |
Example
Response
hydra:view object contains links to navigate the collection:
| Field | Description |
|---|---|
hydra:first | Link to the first page |
hydra:previous | Link to the previous page (if available) |
hydra:next | Link to the next page (if available) |
hydra:last | Link to the last page |
Considerations
- Best for smaller datasets - Works well for collections with moderate size
- Page drift - If items are added or removed while paginating, you may see duplicates or miss items
- Performance - For large datasets, consider cursor-based pagination
Cursor-based Pagination
Uses opaque cursor tokens instead of page numbers. More efficient for large datasets and provides stable results even when items change during pagination.Benefits
- Better performance - More efficient database queries for large datasets
- Stable results - No duplicates or missed items when data changes during pagination
- Scalable - Performance doesn’t degrade as you paginate deeper into the collection
Example
Add theX-Pagination-Style: cursor header to enable cursor pagination:
hydra:next and hydra:previous URIs with the cursor token embedded. To fetch the next page, make a GET request to the hydra:next URI.
Considerations
- No total count by default - The
hydra:totalItemsfield is omitted to improve performance. To include it, add theX-Pagination-Enable-Partial: 0header (this may impact response times for large datasets). - Availability - Cursor pagination is available on most collection endpoints.