Pagination
Pagination helps you navigate through multiple pages of results in the API response. Here are the details on how to use pagination in Gainly API.
Exceptions
The following endpoints implement pagination differently. Please see the endpoint page for details.
API request parameters¶
API requests that can return multiple pages of results accept, at a minimum, the following parameters:
Parameter | Description |
---|---|
page |
A cursor used for pagination when there are multiple pages of results. |
limit |
Limit on the maximum number of results to return per page. |
Gainly API uses cursor-based pagination through these parameters.
API response properties¶
API responses that can return multiple pages of results include, at a minimum, the following properties:
- has_more boolean
- Indicates whether more results are available.
- If
true
, additional pages can be retrieved. - If
false
, the current page is the last page of results.
- next_page integer
- Contains an integer value if
has_more
istrue
, andNULL
ifhas_more
isfalse
. - If
has_more
istrue
, pass this integer as thepage
parameter in your next API request to fetch the subsequent page of results.
- Contains an integer value if
In addition, the following API response properties are usually present for informational purposes:
- total_number_of_results integer
- The total number of results.
- page integer
- The current page of results.
- limit integer
- The number of results displayed per page.
How to implement pagination¶
To implement pagination:
- Don't include the
page
parameter in the initial API request for a given query. - If the
has_more
property in the API response istrue
, use thenext_page
value from the response as thepage
parameter in the next request. This will retrieve the next page of results.- Repeat this step until the
has_more
property in the API response isfalse
.
- Repeat this step until the