kinto
kinto copied to clipboard
feat: Add offset-based pagination support
Add Offset-Based Pagination Support
Problem
Currently, Kinto only supports token-based pagination which requires sequential access to records. Users cannot jump directly to specific record positions (e.g., records 100-120) without paging through all previous records.
Solution
This PR adds support for _offset parameter alongside the existing token-based pagination, allowing direct access to any record position.
Changes
- New
_offsetparameter: Allows specifying starting position for records - Backward compatible: Existing token-based pagination continues to work unchanged
- Enhanced response format: Includes pagination metadata for offset requests
- Manual offset handling: Implements offset slicing for memory backend
Key Features
- Direct Access:
GET /records?_limit=20&_offset=100returns records 100-119 directly - Pagination Metadata: Response includes
paginationobject with limit, offset, total, has_more - Next Page URLs: Automatically generated with correct offset values
- Priority System: Offset takes precedence over token when both are provided
API Examples
# Offset pagination
GET /records?_limit=20&_offset=100
# Response
{
"data": [...],
"pagination": {
"limit": 20,
"offset": 100,
"total": null,
"has_more": true
},
"next": "/records?_limit=20&_offset=120"
}
# Backward compatibility maintained
GET /records?_limit=20&_token=abc123 # Still works
This addresses the feature request in #3403