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

# Pagination

> How to work with paginated API responses

# Pagination

Many API endpoints that return lists of items use cursor-based pagination.

## How It Works

Paginated responses include:

* `data` - Array of items for the current page
* `next_cursor` - Cursor for the next page (null if no more pages)

## Manual Pagination

```bash theme={null}
# First request
curl -X GET "https://api.example.com/items?limit=20"

# Response includes next_cursor
# Use it for the next request
curl -X GET "https://api.example.com/items?limit=20&cursor=abc123"
```

## SDK Examples

The SDKs handle pagination automatically using iterators:

<CodeGroup>
  ```python Python theme={null}
  from meibel import MeibelClient

  client = MeibelClient(api_key="your-api-key")

  # Pagination - iterate over all items
  for item in client.agents.list():
      print(item)
  ```

  ```typescript TypeScript theme={null}
  import { MeibelClient } from 'meibel';

  const client = new MeibelClient({ apiKey: 'your-api-key' });

  // Pagination - iterate over all items
  for await (const item of client.agents.list()) {
    console.log(item);
  }
  ```

  ```go Go theme={null}
  import v2 "github.com/meibel-ai/meibel-go/v2"

  client := v2.NewClient(v2.WithAPIKey("your-api-key"))
  ctx := context.Background()

  // Pagination - iterate over all items
  iter := client.Agents.List(ctx)
  for iter.Next(ctx) {
      item := iter.Item()
      fmt.Println(item)
  }
  if err := iter.Err(); err != nil {
      log.Fatal(err)
  }
  ```
</CodeGroup>
