Skip to content

Commit c834ec3

Browse files
authored
Merge pull request #486 from microsoft/corranrogue9/paging
Update pagination guidance to clarify the difference between server-side and client-side paging
2 parents bb1ae1c + f7e123a commit c834ec3

File tree

2 files changed

+50
-9
lines changed

2 files changed

+50
-9
lines changed

Guidelines.md

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ This document establishes the guidelines Microsoft REST APIs SHOULD follow so RE
9696
- [9.7.2. Operator examples](#972-operator-examples)
9797
- [9.7.3. Operator precedence](#973-operator-precedence)
9898
- [9.8. Pagination](#98-pagination)
99-
- [9.8.1. Server-driven paging](#981-server-driven-paging)
100-
- [9.8.2. Client-driven paging](#982-client-driven-paging)
101-
- [9.8.3. Additional considerations](#983-additional-considerations)
99+
- [9.8.1. Continuation tokens](#981-continuation-tokens)
100+
- [9.8.2. Server-driven paging](#982-server-driven-paging)
101+
- [9.8.3. Client-driven paging](#983-client-driven-paging)
102+
- [9.8.4. Additional considerations](#984-additional-considerations)
102103
- [9.9. Compound collection operations](#99-compound-collection-operations)
103104
- [9.10. Empty Results](#910-empty-results)
104105
- [10. Delta queries](#10-delta-queries)
@@ -954,8 +955,9 @@ Client-driven paging enables clients to request only the number of resources tha
954955

955956
Sorting and Filtering parameters MUST be consistent across pages, because both client- and server-side paging is fully compatible with both filtering and sorting.
956957

957-
#### 9.8.1. Server-driven paging
958-
Paginated responses MUST indicate a partial result by including a continuation token in the response.
958+
#### 9.8.1. Continuation tokens
959+
960+
Paginated responses MUST indicate a partial result by including a continuation token in the response using the OData control information `@nextLink`.
959961
The absence of a continuation token means that no additional pages are available.
960962

961963
Clients MUST treat the continuation URL as opaque, which means that query options may not be changed while iterating over a set of partial results.
@@ -976,7 +978,45 @@ Content-Type: application/json
976978
}
977979
```
978980

979-
#### 9.8.2. Client-driven paging
981+
The `@nextLink` MAY be populated using either server-driven paging or client-driven paging (`@nextLink`s generated using client-driven paging should not include the `$top` query parameter).
982+
983+
#### 9.8.2. Server-driven paging
984+
985+
The server MAY provide server-driven paging by populating the continuation token with a `$skiptoken` query parameter.
986+
The `$skiptoken` value is opaque for clients and its structure should not be assumed.
987+
`$skiptoken` values SHOULD expire after some period of time decided by the server.
988+
989+
Example:
990+
991+
```http
992+
GET http://api.contoso.com/v1.0/people HTTP/1.1
993+
Accept: application/json
994+
995+
HTTP/1.1 200 OK
996+
Content-Type: application/json
997+
998+
{
999+
...,
1000+
"value": [...],
1001+
"@nextLink": "http://api.contoso.com/v1.0/people?$skiptoken={opaquetoken}"
1002+
}
1003+
```
1004+
1005+
```http
1006+
GET http://api.contoso.com/v1.0/people?$skiptoken={opaquetoken} HTTP/1.1
1007+
Accept: application/json
1008+
1009+
HTTP/1.1 200 OK
1010+
Content-Type: application/json
1011+
1012+
{
1013+
...,
1014+
"value": [...],
1015+
"@nextLink": "http://api.contoso.com/v1.0/people?$skiptoken={opaquetoken2}"
1016+
}
1017+
```
1018+
1019+
#### 9.8.3. Client-driven paging
9801020
Clients MAY use _$top_ and _$skip_ query parameters to specify a number of results to return and an offset into the collection.
9811021

9821022
The server SHOULD honor the values specified by the client; however, clients MUST be prepared to handle responses that contain a different page size or contain a continuation token.
@@ -1001,7 +1041,7 @@ Content-Type: application/json
10011041
}
10021042
```
10031043

1004-
#### 9.8.3. Additional considerations
1044+
#### 9.8.4. Additional considerations
10051045
**Stable order prerequisite:** Both forms of paging depend on the collection of items having a stable order.
10061046
The server MUST supplement any specified order criteria with additional sorts (typically by key) to ensure that items are always ordered consistently.
10071047

graph/GuidelinesGraph.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ Microsoft Graph APIs should support basic query options in conformance with ODat
237237
| :heavy_check_mark: **MUST** support `$select on resource` to enable properties projection. |
238238
| :ballot_box_with_check: **SHOULD** support `/entityTypeCollection/{id}?$expand=navProp1` option for navigation properties of entities. |
239239
| :ballot_box_with_check: **SHOULD** support `$filter` with `eq` and `ne` operations on properties of entity collections. |
240-
| :heavy_check_mark: **MUST** support [server-driven pagination](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#981-server-driven-paging) of collections using a [nextLink](http://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#sec_ControlInformationnextLinkodatanextL). |
241-
| :ballot_box_with_check: **SHOULD** support [client-driven pagination](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#982-client-driven-paging) of collections using `$top` and `$skip` (or `$skipToken`). |
240+
| :heavy_check_mark: **MUST** support pagination of collections (of entity types or complex types) using a [nextLink](http://docs.oasis-open.org/odata/odata-json-format/v4.01/odata-json-format-v4.01.html#sec_ControlInformationnextLinkodatanextL). |
241+
| :ballot_box_with_check: **MAY** support [server-driven pagination](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#981-server-driven-paging) of collections using `$skiptoken`. |
242+
| :ballot_box_with_check: **SHOULD** support [client-driven pagination](https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#982-client-driven-paging) of collections using `$top` and `$skip`. |
242243
| :ballot_box_with_check: **SHOULD** support `$count` for collections. |
243244
| :ballot_box_with_check: **SHOULD** support sorting with `$orderby` both ascending and descending on properties of the entities. |
244245

0 commit comments

Comments
 (0)