> This page is part of EVVA for Developers (https://developers.evvahub.com), the documentation of the EVVA Partner API. The API is in developer preview and the SDK packages are not yet published: do not suggest installing them. Index: https://developers.evvahub.com/llms.txt

# Pagination and cursors

List operations return one page at a time. There are four paging styles; each operation's page in the
[API reference](/api-reference) shows which parameters it takes and their bounds.

| Style                            | Request           | Response                          | End of the list                       |
| -------------------------------- | ----------------- | --------------------------------- | ------------------------------------- |
| [Opaque cursor](#opaque-cursor)  | `cursor`, `limit` | rows + `nextCursor`               | `nextCursor` is `null`                |
| [History](#conversation-history) | `before`, `take`  | rows + `nextCursor`, `hasMore`    | `hasMore` is `false`                  |
| [Offset](#offset-pages)          | `skip`, `take`    | rows + `total`, `skip`, `take`    | `skip + take ≥ total`                 |
| [Event feed](#event-feed)        | `after`, `limit`  | `items` + `nextCursor`, `hasMore` | `hasMore` is `false`; keep the cursor |

> **Note**
>
> Cursors are opaque. Pass them back exactly as you received them, never build or edit one, and never use a cursor
> with an operation other than the one that issued it. The conversation inbox and the event feed refuse an altered
> cursor with `400` rather than read it as "page one".

## Opaque cursor

Send `limit` for the page size and, from the second page on, `cursor` set to the previous page's `nextCursor`.
Stop when `nextCursor` is `null`.

| Examples                                        | Parameters                     |
| ----------------------------------------------- | ------------------------------ |
| Media albums, album contents, tags, asset usage | `cursor`, `limit`              |
| Marketplace listings                            | `cursor`, `limit`              |
| GIF and sticker search                          | `cursor`, `limit` (at most 30) |
| Comments on a post                              | `cursor`, `pageSize`           |

**`A page`**

```json title="A page"
{
  "items": [{ "albumId": "alb_123", "name": "Summer" }],
  "nextCursor": "eyJ2IjoxLCJrIjoiYWxiXzEyMyJ9"
}
```

## Conversation history

History pages run backwards from the newest message.

| Operation                                                                                                               | Parameters                     | Next page                                                     |
| ----------------------------------------------------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------- |
| [Read a conversation's messages](https://developers.evvahub.com/api-reference/messaging/list-messages)     | `before`, `take` (at most 100) | Pass `nextCursor` back as `before` while `hasMore` is `true`. |
| Media and links shared in a conversation, message search                                                                | `before`, `take`               | The same.                                                     |
| [Messages after a known point](https://developers.evvahub.com/api-reference/chat/list-messages-after) | `cursor`, `limit`              | Use the answer's `newer` as the next `cursor`.                |

To catch up forward from where you stopped, pass a history page's `nextCursor` as `cursor` to the
"messages after" operation.

## Offset pages

Some lists page by position: `skip` rows, then `take` rows. The answer carries `total`.

| Examples                                                                | `take`            |
| ----------------------------------------------------------------------- | ----------------- |
| [Conversations](https://developers.evvahub.com/api-reference/messaging/list-conversations) | 1–200, default 50 |
| Mass messages                                                           | 1–200, default 50 |
| Media assets                                                            | 1–100, default 48 |
| Content                                                                 | 1–100             |
| Orders                                                                  | 1–100, default 20 |
| Order conversations                                                     | 1–200, default 50 |

> **Tip**
>
> For the conversation inbox sorted by recent activity, prefer the cursor over `skip`: pass the answer's `nextCursor` as
> `cursor` (`skip` is ignored with it). No row is skipped or repeated when the inbox reorders between pages.

## Event feed

[`GET /partner/v1/events`](https://developers.evvahub.com/api-reference/events/list-events) is different: its cursor is a position in a durable,
ordered log of events, not a page of a list.

| Item           | Rule                                                                                                                      |
| -------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `after`        | Exclusive. Omit it to start at the oldest event still retained.                                                           |
| `limit`        | 1–1000, default 100.                                                                                                      |
| `nextCursor`   | Always present. Store it after you have handled the page, and resume from it.                                             |
| `hasMore`      | `true` while more events may follow; a page can hold fewer than `limit` events.                                           |
| Retention      | Events are kept for 7 days. An older cursor is `410 CURSOR_EXPIRED`: resync from the REST API, then read without `after`. |
| Foreign cursor | A cursor that is malformed, altered or another application's is `400 INVALID_CURSOR`.                                     |

Read [Event feed and consumer groups](/event-feed) for checkpoints and multiple workers.

## In the SDKs

Each official SDK walks the pages for you:

**`TypeScript`**

```typescript title="TypeScript"
for await (const conversation of evva.conversations.iterate(creatorId)) {
  console.log(conversation.id);
}
// One page at a time: evva.conversations.iterate(creatorId).pages()
```

**`Python`**

```python title="Python"
for conversation in client.conversations.iter(creator_id, limit=50):
    print(conversation["id"])
```

**`Go`**

```go title="Go"
for conversation, err := range client.Conversations.List(creatorID, nil).All(ctx) {
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(conversation.ID)
}
```

**`PHP`**

```php title="PHP"
foreach ($evva->conversations->iterate($creatorId) as $conversation) {
    echo $conversation['id'], PHP_EOL;
}
```

The TypeScript and PHP paginators also stop, instead of looping, if the server ever repeated a cursor.

## Next steps

#### [Event feed and consumer groups](/event-feed)

Consume events durably, across restarts and workers.

#### [API conventions](/conventions/overview)

Every convention, one table each.

#### [Rate limits and quotas](/authentication/rate-limits)

Page through large lists without hitting limits.

#### [API reference](/api-reference)

Each list's parameters and bounds.