-
Notifications
You must be signed in to change notification settings - Fork 152
Pagination Rules and metadata
- requests for collections MUST always be paginated
- API clients MUST be able to clearly specify the slice of the data set they want to retrieve.
- you MUST use limit and offset query string attributes for pagination. It's a pattern that is well understood and used in most databases
- limit: the maximum number of elements to return at once
- MUST NOT be < 0
- MUST NOT be > 1000
- offset: where to start
- MUST NOT be < 0
- offset and limit MUST both be specified by API clients. If either is missing, default values are applied
- limit: 10
- offset: 0
- limit: the maximum number of elements to return at once
- you MUST use limit and offset query string attributes for pagination. It's a pattern that is well understood and used in most databases
- a paginated response MUST contain
- an "items" array containing the corresponding results
- respecting the rules defined in the filtering section
- a "metadata" object containing information about
- the pagination values
- the sorting parameters
- the ETag values for all the given items
- ...
- an "items" array containing the corresponding results
- pagination: an object containing all the pagination metadata:
- limit: the requested limit (provided by the client)
- offset: the requested offset (provided by the client)
- previousOffset: the previous offset or null if there is none
- nextOffset: the next offset or null if there is none
- currentPage: the current page or null if it does not exist (e.g., out of bounds)
- if the offset falls between two pages, then the currentPage number should be the one of the page that the first item of the resultset is part of
- pageCount: the total number of pages
- totalCount: the total number of elements in the collection
See concurrency section
See sorting section
You MAY add support for a "exclude-metadata" URI parameter if you want your API clients to be able to exclude the metadata.
This project is distributed under the terms of the EUPL FOSS license
REST Resources Design Workflow
REST Resources Single items and collections
REST Resources Many to many Relations
REST Resources Relations expansion
HTTP Status Codes Success (2xx)
HTTP Status Codes Redirection (3xx)
HTTP Status Codes Client Error (4xx)
HTTP Status Codes Server Error (5xx)
Pagination Out of range/bounds
Long-running Operations Example
Concurrency vs Delete operation
Caching and conditional requests About
Caching and conditional requests Rules
Caching and conditional requests HTTP headers
Error handling Example with a single error
Error handling Example with multiple errors
Error handling Example with parameters
Error handling Example with additional metadata
Bulk operations HTTP status codes
Bulk operations Resources naming convention
Bulk operations Creation example
Bulk operations Update example
Bulk operations Create and update example
File upload Simple file upload
File upload Simple file upload example
File upload Complex file upload
File upload Complex file upload example
REST Security General recommendations
REST Security Insecure direct object references