Pagination
Using Pagination in the API with Query Parameters
When dealing with large responses, the API paginates results to make responses more manageable. To retrieve specific pages of data, you can use query parameters in the request URL.
Key Pagination Fields in the Response
count: Total number of items available across all pages.next: URL for the next page of results, if available. This will benullif you’re on the last page.previous: URL for the previous page of results, if available. This will benullif you’re on the first page.results: List of data items for the current page.
Query Parameters
page: This parameter allows you to request a specific page of results.page_size: This parameter defines how many items should be returned per page. If not specified, the API will use a default value.
Example Response
{
"count": 123,
"next": "http://saas.haut.ai/api/v1/companies/{company_id}/datasets/?page=4&page_size=10",
"previous": "http://saas.haut.ai/api/v1/companies/{company_id}/datasets/?page=2&page_size=10",
"results": [
// Data for the current page
]
}How to Use Pagination with Query Parameters:
Initial Request:
By default, the API returns the first page of results. You can control the number of results per page with the
page_sizeparameter.Example request for the first 10 results:
curl -X GET "http://saas.haut.ai/api/v1/companies/{company_id}/datasets/?page=1&page_size=10"
Navigating to the Next Page:
To retrieve the next page of results, use the URL in the
nextfield or set thepageparameter manually.Example:
curl -X GET "http://saas.haut.ai/api/v1/companies/{company_id}/datasets/?page=4&page_size=10"
Going Back to the Previous Page:
Similarly, you can use the
previousfield or specify the page in the request URL to go back.Example:
curl -X GET "http://saas.haut.ai/api/v1/companies/{company_id}/datasets/?page=2&page_size=10"
Customizing Page Size:
If you need more or fewer items per page, use the
page_sizeparameter to control how many results are returned on each page.Example for 25 results per page:
curl -X GET "http://saas.haut.ai/api/v1/companies/{company_id}/datasets/?page=1&page_size=25"
Handling Edge Cases:
nextisnull: You’re on the last page of results.previousisnull: You’re on the first page of results.
Last updated
Was this helpful?