> For the complete documentation index, see [llms.txt](https://docs.saas.haut.ai/haut.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.saas.haut.ai/haut.ai/developers/pagination.md).

# Pagination

How to page through large Haut.AI API responses with the page and page\_size query parameters, and what the response returns.

## 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 be `null` if you’re on the last page.
* **`previous`**: URL for the previous page of results, if available. This will be `null` if you’re on the first page.
* **`results`**: List of data items for the current page.

### Query Parameters

1. **`page`**: This parameter allows you to request a specific page of results.
2. **`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

```json
{
  "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:

1. **Initial Request**:
   * By default, the API returns the first page of results. You can control the number of results per page with the `page_size` parameter.
   * Example request for the first 10 results:

     ```bash
     curl -X GET "http://saas.haut.ai/api/v1/companies/{company_id}/datasets/?page=1&page_size=10"
     ```
2. **Navigating to the Next Page**:
   * To retrieve the next page of results, use the URL in the **`next`** field or set the `page` parameter manually.
   * Example:

     ```bash
     curl -X GET "http://saas.haut.ai/api/v1/companies/{company_id}/datasets/?page=4&page_size=10"
     ```
3. **Going Back to the Previous Page**:
   * Similarly, you can use the **`previous`** field or specify the page in the request URL to go back.
   * Example:

     ```bash
     curl -X GET "http://saas.haut.ai/api/v1/companies/{company_id}/datasets/?page=2&page_size=10"
     ```
4. **Customizing Page Size**:
   * If you need more or fewer items per page, use the `page_size` parameter to control how many results are returned on each page.
   * Example for 25 results per page:

     ```bash
     curl -X GET "http://saas.haut.ai/api/v1/companies/{company_id}/datasets/?page=1&page_size=25"
     ```

### Handling Edge Cases:

* **`next` is `null`**: You’re on the last page of results.
* **`previous` is `null`**: You’re on the first page of results.

***

{% hint style="warning" %}
Not a Haut.AI client yet?
{% endhint %}

<a href="https://haut.ai/book-a-demo?utm_source=referral&#x26;utm_medium=saas_docs&#x26;utm_campaign=Docs_SaaS_HautAI" class="button primary" data-icon="user-vneck">Book a demo</a> <a href="https://haut.ai/product/ai-skin-analysis?utm_source=referral&#x26;utm_medium=saas_docs&#x26;utm_campaign=Docs_SaaS_HautAI" class="button secondary" data-icon="external-link">Platform overview on haut.ai</a>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.saas.haut.ai/haut.ai/developers/pagination.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
