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

# Pagination

> Cursor-based pagination for list endpoints

## Overview

List endpoints return paginated results using cursor-based pagination. This provides stable, efficient pagination even when data is being added or removed.

## Query parameters

| Parameter | Type    | Default | Description                                      |
| --------- | ------- | ------- | ------------------------------------------------ |
| `limit`   | integer | `25`    | Number of items per page (max `100`)             |
| `cursor`  | string  | —       | Cursor from `next_cursor` in a previous response |

## Response format

List responses follow a consistent format:

```json theme={null}
{
  "object": "list",
  "data": [
    { "id": "qr_123", "object": "qr_code", "..." : "..." },
    { "id": "qr_124", "object": "qr_code", "..." : "..." }
  ],
  "has_more": true,
  "next_cursor": "eyJpZCI6InFyXzEyNCJ9"
}
```

| Field         | Description                                                                          |
| ------------- | ------------------------------------------------------------------------------------ |
| `object`      | Always `"list"`                                                                      |
| `data`        | Array of resource objects                                                            |
| `has_more`    | `true` if there are more pages                                                       |
| `next_cursor` | Cursor to pass as the `cursor` parameter for the next page. `null` if no more pages. |

## Fetching all pages

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

  def fetch_all_qr_codes(api_key):
      all_codes = []
      cursor = None

      while True:
          params = {"limit": 100}
          if cursor:
              params["cursor"] = cursor

          response = requests.get(
              "https://api.useqrkit.com/v1/qr-codes",
              headers={"Authorization": f"Bearer {api_key}"},
              params=params,
          )
          data = response.json()
          all_codes.extend(data["data"])

          if not data["has_more"]:
              break
          cursor = data["next_cursor"]

      return all_codes
  ```

  ```javascript Node.js theme={null}
  async function fetchAllQrCodes(apiKey) {
    const allCodes = [];
    let cursor = null;

    while (true) {
      const params = new URLSearchParams({ limit: "100" });
      if (cursor) params.set("cursor", cursor);

      const response = await fetch(
        `https://api.useqrkit.com/v1/qr-codes?${params}`,
        { headers: { Authorization: `Bearer ${apiKey}` } }
      );
      const data = await response.json();
      allCodes.push(...data.data);

      if (!data.has_more) break;
      cursor = data.next_cursor;
    }

    return allCodes;
  }
  ```
</CodeGroup>

## Sorting

List endpoints support sorting with `sort` and `order` parameters:

| Parameter | Values                                           | Default      |
| --------- | ------------------------------------------------ | ------------ |
| `sort`    | `created_at`, `updated_at`, `name`, `scan_count` | `created_at` |
| `order`   | `asc`, `desc`                                    | `desc`       |

```bash theme={null}
curl "https://api.useqrkit.com/v1/qr-codes?sort=scan_count&order=desc&limit=10" \
  -H "Authorization: Bearer qr_live_..."
```

<Note>
  Sorting is available on the [List QR Codes](/api-reference/qr-codes/list) endpoint. Other list endpoints return results sorted by `created_at` descending.
</Note>
