How do I paginate API results?

Question:
My company uses the API regularly, but certain methods return a long list of results. Are there any logic rules that allow me to index or paginate results?

You can paginate a long list of API results according to the following rules.

Set-Logic Rules

All row or page numbers are zero-indexed, meaning page 0 is the first page.

Individual records will not be indexed with their index in the original set. They will be returned in order but with no explicit index values.

You can find a start_index value in the result header to assist you in finding this set’s place in the original set. If start_index is absent from the API result header, a default value of 0 may be implied.

Parameters To Use

The following sections describe API parameter combinations available for pagination. These combinations are available for use with any API endpoint that returns a result set. Use them with the other parameters on the query string.

Row + Length

Row is the record number to start with, and length is the number of results you want in your result set. This always returns length records (or less).

Example: vehicle/location/?row=20&length=19 returns records 20-39 of the original set.

Row + End

Row is the record number to start with, and end is the record number to end with. This returns end-start records.

Example: vehicle/location/?row=20&end=39 returns records 20-39 of the original set.

Page + Page_Size

Page_size is how many records you want in the result set, and page is the index of that page in the complete set. This always returns page_size records (or less).

Example: vehicle/location/?page=1&page_size=20 returns records 20-39 of the original set.

Rows

Rows will return the first rows values from the original set, starting from the first record. This always returns rows records (or less).

Example: vehicle/location/?rows=20 returns records 0-19 of the original set.