Pagination - Version 0.1-wip 🔗

This document describes a mechanism by which a server can return a set of records to a client in an incremental fashion. Often this will be used when a client is doing a query for a set of records and the result set is too large to return in one response.

Notations and Terminology 🔗

Notational Conventions 🔗

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC2119.

Client Request 🔗

When a client sends a request to a server which is meant to result in a set of records being returned, the client MAY include extra attributes to control how those records are to be returned if the results can not fit within one response message.

Client Attributes 🔗

The follow list of attributes MAY be included in a client's request for a set of records from a server. The client MUST only specify these on the initial request for the set. If the results can not fit within one response then these attributes MUST NOT be added to subsequent requests by the client. Note, the server MAY include these attributes within the URI-reference returned in a response message, but the client MUST NOT modify those values.

limit 🔗

Server Response 🔗

When a server returns a subset of records, it MAY include additional attributes to help the client retrieve the next subset of records.

Server Attributes 🔗

The following list of attributes MAY be included in a server's response to a client's request for a set of records.

Note: in the examples listed below, the use of certain query parameters in the response messages from the server, such as offset and limit, are an implementation detail of the server. How the server encodes the information it needs to retrieve a certain subset of records is not mandated by this specification.

rel 🔗

expires 🔗

count 🔗

HTTP Binding 🔗

THe following describes how the attributes defined above would appear in a flow of HTTP messages during the retrieval of a set of records.

Request for a record set 🔗

To request a set of records from a server, a client will send an HTTP GET request to the server. How this URL is determined is out of scope of this specification.

The client MAY include the limit attribute as part of this request. Unless there is some out-of-bands negotiation to determine a different mechanism, the server MUST accept the limit attribute as a query parameter (named limit, case sensitive) in the URL.

For example:

http://example.com/people?limit=100

Response for a record set 🔗

Each successful response from the server MUST adhere to the following:

Additionally, Links MUST appear in the HTTP response as HTTP headers using the format described in RFC5988.

Example 1:

Link: <http://example.com?limit=100&offset=3>;rel=next
Link: <http://example.com?limit=100&offset=1>;rel=prev

Example 2:

Link: <http://example.com?resultset=83d71>;rel=next
Expires: Thu, 01 Dec 2021 16:00:00 GMT

Example 3:

Link: <http://example.com?id=1001>;rel=next;count=3000
Link: <http://example.com?id=0>;rel=prev;count=3000

Iterating over the record set 🔗

Once the record set retrieval has started, the client MAY use the Links returned from the server to iterate through the full set of records. Typically, the client will use the next Link from each response to retrieve the next subset of records until a response is returned without a next Link - indicating that it has reached the end.

However, if other Links are provided by the server, then the client MAY use those Links instead to follow a different traversal path through the records.