# Pagination

Some Limy API endpoints return paginated results. These endpoints accept `limit` and `offset` query parameters.

## Parameters

| Parameter | Type    | Default | Description                        |
| --------- | ------- | ------- | ---------------------------------- |
| `limit`   | integer | 50      | Number of items per page (max 100) |
| `offset`  | integer | 0       | Number of items to skip            |

## Paginated Response

Paginated endpoints include a `pagination` object:

```json
{
  "data": [...],
  "pagination": {
    "total": 247,
    "limit": 50,
    "offset": 0,
    "hasMore": true
  }
}
```

| Field     | Type    | Description                                      |
| --------- | ------- | ------------------------------------------------ |
| `total`   | integer | Total number of items matching the query         |
| `limit`   | integer | Items per page (as requested)                    |
| `offset`  | integer | Current offset                                   |
| `hasMore` | boolean | Whether more items exist beyond the current page |

## Example: Iterating Through Pages

### Python

```python
import requests

offset = 0
limit = 50
all_data = []

while True:
    response = requests.get(
        f'{BASE_URL}/v1/prompts/analytics',
        headers={"X-API-Key": API_KEY},
        params={'limit': limit, 'offset': offset}
    )
    result = response.json()
    all_data.extend(result['data'])

    if not result['pagination']['hasMore']:
        break
    offset += limit

print(f"Fetched {len(all_data)} total items")
```

## Which Endpoints Are Paginated?

| Endpoint                   | Default Limit |
| -------------------------- | ------------- |
| Prompts Analytics          | 50            |
| Commerce Category Products | 50            |
| Commerce Top Products      | 5             |

Most analytics endpoints return the full dataset in a single response without pagination.


---

# Agent Instructions: 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:

```
GET https://api-reference.limy.ai/getting-started/pagination.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
