> For the complete documentation index, see [llms.txt](https://run-ai-docs.nvidia.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://run-ai-docs.nvidia.com/api/2.21/getting-started/using-the-rest-api/pagination.md).

# Pagination

Several List endpoints in the NVIDIA Run:ai control plane API return large collections. To retrieve results in smaller chunks, use offset/limit pagination.

## How Pagination Works

### Request Parameters

When an endpoint supports pagination, it typically exposes:

* `limit` - Maximum number of items to return (default 50, range 1..500)
* `offset` - The offset of the first item returned in the collection

Example (workloads): `GET /api/v1/workloads?offset=0&limit=50`&#x20;

### Pagination Response

List responses may include a `next` field, alongside the collection itself (for example, `workloads`).&#x20;

Example response shape (workloads):

```json
{
  "next": 1,
  "workloads": [ ... ]
}
```

Use `next` as the pointer for retrieving the next “page” of results. If `next` is not returned (or is empty), you’ve reached the end of the collection.

### Example: Paginate Through Workloads

#### Fetch the first page

```bash
curl -sS \
  -H "Authorization: Bearer <TOKEN>" \
  "https://<COMPANY-URL>/api/v1/workloads?offset=0&limit=50"
```

The endpoint supports `offset` and `limit`.

#### Fetch the next page

Take the `next` value from the response and use it in the next request (as the next offset/page pointer).&#x20;

### Combine Pagination with Sorting and Filtering

The workloads list endpoint also supports:

* **Sorting** - `sortBy` and `sortOrder`&#x20;
* **Structured filtering** - `filterBy` with operators like `==`, `!=`, `>=`, `=@` (contains), etc.
* **Free-text search** - `search`&#x20;

Example:

```bash
curl -sS \
  -H "Authorization: Bearer <TOKEN>" \
  "https://<COMPANY-URL>/api/v1/workloads?limit=100&offset=0&sortBy=createdAt&sortOrder=desc&filterBy=allocatedGPU>=2"
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://run-ai-docs.nvidia.com/api/2.21/getting-started/using-the-rest-api/pagination.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
