# Pagination

> Every list is cursor paginated. Follow nextCursor until hasMore is false.

Source: https://mockflow.com/developers/concepts/pagination

Every list returns the same envelope: a `data` array, a `hasMore` flag and, when there is more, a `nextCursor` to pass back.

```json
{
  "data": [
    {
      "id": "brd_3f9e2a",
      "title": "Q4 Launch Planning"
    }
  ],
  "hasMore": true,
  "nextCursor": "eyJvIjoyNX0"
}
```

## Reading a whole list

Pass the `nextCursor` you were given as `?cursor=` and keep going until `hasMore` is false. Do not build a cursor yourself and do not parse one: it is opaque and its contents will change.

```javascript
let cursor = null;
const boards = [];

do {
  const url = new URL("https://api.mockflow.com/v1/boards");
  if (cursor) url.searchParams.set("cursor", cursor);

  const page = await fetch(url, {
    headers: { Authorization: `Bearer ${process.env.MOCKFLOW_API_KEY}` }
  }).then((r) => r.json());

  boards.push(...page.data);
  cursor = page.hasMore ? page.nextCursor : null;
} while (cursor);
```

## Page size

### Query parameters

- `limit` (integer): How many to return. Defaults to 50 and is capped at 100, whatever you ask for.
- `cursor` (string): The `nextCursor` from the previous response. Omit it for the first page.

> **Note** A cursor is tied to the filters it was made with. Change `q` or `sort` and start again from the first page.
