- 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
Example
Response
hydra:view object contains links to navigate the collection:
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). - Count on the first page - With
X-Pagination-Enable-Partial: 0,hydra:totalItemscounts the items that match the request and its cursor: on a page requested throughhydra:next, only the items after the cursor. Request the total on the first page, without a cursor. - Availability - Cursor pagination is available on most collection endpoints.
Bounded count
Counting every item of a very large collection can take too long. Some endpoints accept theX-Pagination-Bounded-Count: 1 header, which limits the count:
Send it together with
X-Pagination-Enable-Partial: 0:
- When the items that match the request are within the limit, the response includes the exact
hydra:totalItems. - When they exceed the limit, the response omits
hydra:totalItems. The collection has more items than the limit. To count them, narrow the request with filters, such as an issue date range. - With cursor pagination, without
X-Pagination-Enable-Partial: 0, the header has no effect and the response omitshydra:totalItems.