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

# Pagination

> Navigate through large result sets with page-based pagination

# Pagination

All list endpoints return paginated results. Use the `page` and `limit` query parameters to control which slice of data you receive.

## Query Parameters

| Parameter | Type | Default | Description |
| - | - | - | - |
| `page` | integer | `1` | Page number (1-indexed) |
| `limit` | integer | `25` | Items per page (max `100`) |

## Response Structure

Every paginated response includes a `pagination` object:

```json theme={null}
{
  "data": [...],
  "pagination": {
    "page": 1,
    "limit": 25,
    "total_pages": 4,
    "total_items": 100,
    "has_more": true
  }
}
```

| Field | Description |
| - | - |
| `page` | Current page number |
| `limit` | Items per page (as requested) |
| `total_pages` | Total number of pages available |
| `total_items` | Total number of items across all pages |
| `has_more` | `true` if there are more pages after the current one |

## Iterating Through All Pages

Use the `has_more` field to know when to stop:

<CodeGroup>
  ```python Python theme={null}
  import httpx

  BASE_URL = "https://api.ya.onl/v1/orders"
  HEADERS = {"X-API-Key": "yv_live_v1_your_api_key"}

  all_orders = []
  page = 1

  while True:
      response = httpx.get(BASE_URL, params={"page": page, "limit": 100}, headers=HEADERS)
      body = response.json()
      all_orders.extend(body["data"])

      if not body["pagination"]["has_more"]:
          break
      page += 1

  print(f"Fetched {len(all_orders)} orders")
  ```

  ```javascript Node.js theme={null}
  const BASE_URL = "https://api.ya.onl/v1/orders";
  const HEADERS = { "X-API-Key": "yv_live_v1_your_api_key" };

  const allOrders = [];
  let page = 1;
  let hasMore = true;

  while (hasMore) {
    const response = await fetch(`${BASE_URL}?page=${page}&limit=100`, {
      headers: HEADERS,
    });
    const body = await response.json();
    allOrders.push(...body.data);
    hasMore = body.pagination.has_more;
    page++;
  }

  console.log(`Fetched ${allOrders.length} orders`);
  ```
</CodeGroup>

## Limits

* The maximum value for `limit` is **100**. Requesting more than 100 returns a `400 Bad Request` error.
* Page numbers start at **1**. Requesting page 0 or a negative number returns a validation error.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.