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

# Pagination

> How to page through list endpoints with the pageSize and pageNumber query parameters.

List endpoints return one page at a time, wrapped in a page envelope. They take the paging parameters in the query string.

## v2 endpoints

These endpoints are paginated:

| Endpoint | Order |
| - | - |
| [`GET /organizations`](/v2/api-reference/organizations/list-organizations) | Newest first. Your customer organizations. |
| [`GET /organization/{organizationId}/payment_accounts`](/v2/api-reference/payment-accounts/list-payment-accounts) | Oldest first. |
| [`GET /orders`](/v2/api-reference/orders/list-orders) | Newest first. The orders of your organization and all its customer organizations, or one organization's with `?organizationId=`. |

### Request

| Parameter | Default | Rule |
| - | - | - |
| `pageSize` | `30` | Items per page, 1 to 100. Other values return `400` `invalid-request`. |
| `pageNumber` | `0` | Which page to return. Starts at 0. |

```bash theme={null}
curl "https://api.sand.etherfuse.com/orders?pageSize=50&pageNumber=0" \
  -H "Authorization: <your_api_key>"
```

### Response

| Field | Type | Description |
| - | - | - |
| `items` | array | The items on this page. |
| `totalItems` | integer | Total items across all pages. |
| `pageSize` | integer | Items per page. |
| `pageNumber` | integer | Zero-based index of this page. |
| `totalPages` | integer | Total number of pages. |

```json theme={null}
{
  "items": [],
  "totalItems": 42,
  "pageSize": 30,
  "pageNumber": 0,
  "totalPages": 2
}
```

A `pageNumber` past the last page returns an empty `items` array.

### Iterating through pages

Start at `pageNumber=0` and stop when `pageNumber + 1 >= totalPages`:

```js theme={null}
const pageSize = 100;
const all = [];

for (let page = 0; ; page++) {
  const res = await fetch(
    `https://api.sand.etherfuse.com/orders?pageSize=${pageSize}&pageNumber=${page}`,
    { headers: { Authorization: apiKey } },
  );
  const { items, totalPages } = await res.json();
  all.push(...items);
  if (page + 1 >= totalPages) break;
}
```

<Tip>
  To track orders as they change, subscribe to [webhooks](/v2/webhooks) instead of polling the list.
</Tip>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.