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

# Pagination

> The OnePerfectSlice API uses offset-based pagination. Pass limit and offset as query parameters to control which page of results you receive.

## Request parameters

| Parameter | Type    | Default | Range | What it does                                      |
| --------- | ------- | ------- | ----- | ------------------------------------------------- |
| `limit`   | integer | 20      | 1–100 | How many results to return per page               |
| `offset`  | integer | 0       | 0+    | How many results to skip before starting the page |

## Response metadata

Every paginated response includes a `meta.pagination` object that tells you where you are in the result set:

```json theme={null}
{
  "data": [ ... ],
  "meta": {
    "pagination": {
      "totalCount": 142,
      "hasMore": true,
      "limit": 20,
      "offset": 0
    }
  }
}
```

| Field        | Type    | What it tells you                           |
| ------------ | ------- | ------------------------------------------- |
| `totalCount` | integer | Total results across all pages              |
| `hasMore`    | boolean | Whether there are more pages after this one |
| `limit`      | integer | Page size (echoed from your request)        |
| `offset`     | integer | Current position in the result set          |

## Which endpoints are paginated?

| Endpoint             | What it returns                                |
| -------------------- | ---------------------------------------------- |
| `GET /slice-runs`    | Run history for your team                      |
| `POST /posts/search` | Summaries and scorecards matching your filters |

All other endpoints return the full result set in a single response.

## Fetching all pages

Use the `hasMore` field to loop through pages. Increment `offset` by `limit` each time until `hasMore` is `false`.

<CodeGroup>
  ```bash cURL theme={null}
  # First page
  curl "https://app.oneperfectslice.ai/api/public/v1/slice-runs?limit=20&offset=0" \
    -H "Authorization: Bearer sk_your_api_key"

  # Second page
  curl "https://app.oneperfectslice.ai/api/public/v1/slice-runs?limit=20&offset=20" \
    -H "Authorization: Bearer sk_your_api_key"
  ```

  ```python Python theme={null}
  import requests

  headers = {"Authorization": "Bearer sk_your_api_key"}
  base = "https://app.oneperfectslice.ai/api/public/v1/slice-runs"

  all_runs = []
  offset = 0
  limit = 20

  while True:
      resp = requests.get(base, headers=headers, params={"limit": limit, "offset": offset})
      page = resp.json()
      all_runs.extend(page["data"])

      if not page["meta"]["pagination"]["hasMore"]:
          break
      offset += limit

  print(f"Fetched {len(all_runs)} runs")
  ```

  ```typescript TypeScript theme={null}
  const headers = { Authorization: "Bearer sk_your_api_key" };
  const base = "https://app.oneperfectslice.ai/api/public/v1/slice-runs";

  const allRuns: any[] = [];
  let offset = 0;
  const limit = 20;

  while (true) {
    const resp = await fetch(`${base}?limit=${limit}&offset=${offset}`, { headers });
    const page = await resp.json();
    allRuns.push(...page.data);

    if (!page.meta.pagination.hasMore) break;
    offset += limit;
  }

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