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

# Pagination

> Every list comes back in pages. Follow nextCursor until it is null.

Every list endpoint returns one page at a time:

```json theme={null}
{
  "data": [ ... ],
  "nextCursor": "eyJ2IjoxLCJhdCI6IjIwMjYtMDkt…"
}
```

To get the next page, send the same request again with `?cursor=` set to `nextCursor`. Stop when `nextCursor` is `null`.

```bash theme={null}
curl "https://api-demo.scoutworks.app/api/v1/members?limit=200&cursor=PASTE_NEXT_CURSOR_HERE" \
  -H "Authorization: Bearer sw_live_473adcc6c7236916021f0f24559db36576a53bab071d0f0c08a025adb510b6ab"
```

## Rules

* **`limit`** is 1 to 200. The default is 50. Use 200 to make fewer requests.
* **Pass the cursor back unchanged.** It is not a page number. Do not read it, build it or change it. Its format can change at any time.
* **Keep the same filters and limit.** A cursor belongs to one query. If you change `status` or `sectionId` between pages, the pages you get are not reliable. To change a filter, start again without a cursor.
* **A cursor you changed gets `400`.** The message tells you to start again without one.
* **Spell parameters exactly.** The API rejects a parameter it does not know with `400 invalid_request`, so a typo fails loudly instead of being ignored.

## A loop that reads every page

<CodeGroup>
  ```python Python theme={null}
  import requests

  API_KEY = "sw_live_473adcc6c7236916021f0f24559db36576a53bab071d0f0c08a025adb510b6ab"
  url = "https://api-demo.scoutworks.app/api/v1/members?limit=200"

  members, cursor = [], None
  while True:
      params = {"cursor": cursor} if cursor else {}
      page = requests.get(url, params=params, headers={"Authorization": f"Bearer {API_KEY}"})
      page.raise_for_status()
      body = page.json()
      members += body["data"]
      cursor = body["nextCursor"]
      if cursor is None:
          break

  print(len(members), "members")
  ```

  ```javascript JavaScript theme={null}
  const API_KEY = 'sw_live_473adcc6c7236916021f0f24559db36576a53bab071d0f0c08a025adb510b6ab';

  const members = [];
  let cursor = null;
  do {
    const url = new URL('https://api-demo.scoutworks.app/api/v1/members?limit=200');
    if (cursor) url.searchParams.set('cursor', cursor);
    const res = await fetch(url, { headers: { Authorization: `Bearer ${API_KEY}` } });
    if (!res.ok) throw new Error((await res.json()).error.code);
    const body = await res.json();
    members.push(...body.data);
    cursor = body.nextCursor;
  } while (cursor);

  console.log(members.length, 'members');
  ```
</CodeGroup>
