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

# Paginação

> Paginação baseada em cursor para endpoints de listagem.

## Como funciona

Todos os endpoints de listagem usam **paginação baseada em cursor**. Cada resposta inclui metadados de paginação:

```json theme={null}
{
  "data": [...],
  "pagination": {
    "cursor": "eyJpZCI6IjEyMyJ9",
    "hasMore": true,
    "total": 487
  }
}
```

## Solicitando páginas

Passe o `cursor` da resposta anterior para buscar a próxima página:

```bash theme={null}
# Primeira página (padrão: 50 itens)
curl ".../brands?limit=20"

# Próxima página
curl ".../brands?limit=20&cursor=eyJpZCI6IjEyMyJ9"
```

## Parâmetros

| Parâmetro | Tipo    | Padrão | Descrição                   |
| --------- | ------- | ------ | --------------------------- |
| `limit`   | integer | 50     | Itens por página (máx 100)  |
| `cursor`  | string  | —      | Cursor da resposta anterior |

## Iterando por todas as páginas

```javascript theme={null}
async function fetchAllBrands(workspaceId) {
  let cursor = null;
  const allBrands = [];

  do {
    const url = new URL(`.../brands`);
    url.searchParams.set('limit', '100');
    if (cursor) url.searchParams.set('cursor', cursor);

    const response = await fetch(url, { headers: { Authorization: `Bearer ${apiKey}` } });
    const { data, pagination } = await response.json();

    allBrands.push(...data);
    cursor = pagination.hasMore ? pagination.cursor : null;
  } while (cursor);

  return allBrands;
}
```
