Pagination

(Difference between revisions)
Jump to: navigation, search
m (1 revision: Release 97)
(Sample response)
Line 1: Line 1:
Large resources lists require pagination. Pagination is controlled by two query parameters, '''marker''' and  '''limit'''. They are optional and if not given, the first page will be returned.
+
Large resources lists require pagination. Pagination is controlled by two query parameters, '''page''' and  '''pageSize'''. If they are not specified (meaning, the client is requesting the full list), the API will attempt to return the full list. If there are more than 100 elements in the full list, the API will instead return a response code of 303 "See Other", with a '''Location''' header in the response containing the URL for the first page of the equivalent paginated call (where pageSize = 100).
  
'''GET''' /<url>?marker=markerId&limit=pageSize
+
'''GET''' /<url>?page=1&pageSize=20
  
;marker
+
;page
: ''Optional'' The id of the last resource on the previous page. All resources greater than marker up to limit will be returned.
+
: ''Optional'' The 1-based index of the page of results requested. '''page''' is required if '''pageSize''' has been provided.
  
;limit
+
;pageSize
: ''Optional'' The maximum number of resources that will be returned by the the resource list.
+
: ''Optional'' The maximum number of resources to be returned on each page of the paginated request. This value cannot currently exceed 400; any requests with pageSize > 400 will result in a response code of 303 "See Other", with a '''Location''' header in the response containing the URL for the same page of a paginated call with pageSize=400. '''pageSize''' is required if '''page''' has been provided.
 +
 
 +
== Sample response ==
 +
 
 +
<nowiki>
 +
{
 +
  "list": [
 +
    {... resource 1 ...},
 +
    {... resource 2 ...},
 +
    ...
 +
  ],
 +
  "links": [
 +
    {"rel": "self", "href": "/<url>?page=5&pageSize=20"},
 +
    {"rel": "previous", "href": "/<url>?page=4&pageSize=20"},
 +
    {"rel": "first", "href": "/<url>?page=1&pageSize=20"},
 +
    {"rel": "next", "href": "/<url>?page=6&pageSize=20"},
 +
    {"rel": "last", "href": "/<url>?page=231&pageSize=20"},
 +
  ]
 +
}
 +
</nowiki>
 +
 
 +
The '''previous''' and '''first''' links will be omitted if the current page is the first page, and the '''next''' and '''last''' links will be omitted if the current page is the last page.
  
 
== See also ==
 
== See also ==

Revision as of 16:16, 16 June 2015

Large resources lists require pagination. Pagination is controlled by two query parameters, page and pageSize. If they are not specified (meaning, the client is requesting the full list), the API will attempt to return the full list. If there are more than 100 elements in the full list, the API will instead return a response code of 303 "See Other", with a Location header in the response containing the URL for the first page of the equivalent paginated call (where pageSize = 100).

GET /<url>?page=1&pageSize=20

page
Optional The 1-based index of the page of results requested. page is required if pageSize has been provided.
pageSize
Optional The maximum number of resources to be returned on each page of the paginated request. This value cannot currently exceed 400; any requests with pageSize > 400 will result in a response code of 303 "See Other", with a Location header in the response containing the URL for the same page of a paginated call with pageSize=400. pageSize is required if page has been provided.

Sample response

{
  "list": [
    {... resource 1 ...},
    {... resource 2 ...},
    ...
  ],
  "links": [
    {"rel": "self", "href": "/<url>?page=5&pageSize=20"},
    {"rel": "previous", "href": "/<url>?page=4&pageSize=20"},
    {"rel": "first", "href": "/<url>?page=1&pageSize=20"},
    {"rel": "next", "href": "/<url>?page=6&pageSize=20"},
    {"rel": "last", "href": "/<url>?page=231&pageSize=20"},
  ]
}
 

The previous and first links will be omitted if the current page is the first page, and the next and last links will be omitted if the current page is the last page.

See also


blog comments powered by Disqus

Personal tools
Namespaces
Variants
Actions
APIs
Navigation
Toolbox