> ## Documentation Index
> Fetch the complete documentation index at: https://apidocs.noyax.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Pagination and search

> Reading list endpoints page by page and searching.

List endpoints that can return many records (e.g. [List customers](/en/v1/customers/list)) return results in pages.

## Parameters

<ParamField query="page" type="integer" default="1">
  Page number, starting from 1. Values below 1 are treated as 1.
</ParamField>

<ParamField query="pageSize" type="integer" default="50">
  Records per page, at most **50**. Values below 1 or above 50 are treated as 50.
</ParamField>

<ParamField query="search" type="string">
  Text to search for. The customer list does a "contains" search in the customer name, customer code and tax number.
</ParamField>

## Response

<ResponseField name="Data.Page" type="integer">Returned page number.</ResponseField>
<ResponseField name="Data.PageSize" type="integer">Page size that was applied.</ResponseField>
<ResponseField name="Data.TotalCount" type="integer">Total number of records matching the filter.</ResponseField>
<ResponseField name="Data.Items" type="array">Records on this page.</ResponseField>

Total number of pages: `ceil(TotalCount / PageSize)`.

## Reading all records

<CodeGroup>
  ```javascript Node.js theme={null}
  async function getAllCustomers(client) {
    const customers = [];
    let page = 1;

    while (true) {
      const { Data } = await client.get(`customers?page=${page}&pageSize=50`);
      customers.push(...Data.Items);

      if (page * Data.PageSize >= Data.TotalCount) break;
      page++;
    }

    return customers;
  }
  ```

  ```python Python theme={null}
  def get_all_customers(session):
      customers, page = [], 1
      while True:
          data = session.get(f"{BASE_URL}/customers", params={"page": page, "pageSize": 50}).json()["Data"]
          customers.extend(data["Items"])
          if page * data["PageSize"] >= data["TotalCount"]:
              break
          page += 1
      return customers
  ```
</CodeGroup>

<Note>
  If records are added or deleted while you page through a list, a record may appear twice or be skipped. De-duplicate records by `Id`.
</Note>

Sub-record lists (addresses, telephones and so on) belong to a single customer, so they are not paginated and return all records at once.
