Pagination #
Pagination is implemented using a cursor that allows for seeking. Consumers are free to move around in the result set using the $page
parameter with no performance penalty. Cursors are ephemeral. They are created when a search is first performed and the cursor’s ID must be given to subsequent requests for results.
The Link
header uses absolute paths; any path can be pulled out from the header and used as-is.
Initial request #
Request:
GET /maintenance/work_orders
Response:
X-Total: 38
X-Cursor: iCUbR5nAkW
Link: </maintenance/work_orders?$cursor=iCUbR5nAkW&$page=1>; rel="first",
</maintenance/work_orders?$cursor=iCUbR5nAkW&$page=2>; rel="next",
</maintenance/work_orders?$cursor=iCUbR5nAkW&$page=4>; rel="last"
The Link
header does not contain new line characters when working with the API. They were added to the example above for readability.
Second page #
Request:
GET /maintenance/work_orders?$cursor=iCUbR5nAkW&$page=2
Response:
X-Total: 38
X-Cursor: iCUbR5nAkW
Link: </maintenance/work_orders?$cursor=iCUbR5nAkW&$page=1>; rel="first",
</maintenance/work_orders?$cursor=iCUbR5nAkW&$page=1>; rel="prev",
</maintenance/work_orders?$cursor=iCUbR5nAkW&$page=3>; rel="next",
</maintenance/work_orders?$cursor=iCUbR5nAkW&$page=4>; rel="last"
The Link
header does not contain new line characters when working with the API. They were added to the example above for readability.
Limiting page size #
Request:
GET /maintenance/work_orders?$limit=5
Authorization: Bearer 12345
The response will be the same as the example above. The only indication that a limit has been set would be the number of results returned vs the total number of results.
Reference #
Headers #
Header | Description |
---|---|
X-Cursor |
Cursor ID. Created on initial request for records. |
X-Total |
Total number of records that are contained within the cursor. All records match the original search conditions, if specified. |
Link |
Optional. Quick links to additional pages of results. first and last will be available if the cursor has results. prev and next will be available if $page is greater than 0 and less than or equal to the maximum, respectively. Paths are absolute. |
Query string #
Parameter | Description |
---|---|
$limit |
Optional. Maximum number of items to return per page. Defaults to 10, with a maximum of 50. Can only be specified on initial request. |
$page |
Which page of results to return. |
$cursor |
ID of cursor that points to result set. |