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

# Pagination

> How to page through list endpoints on the 9Squid API.

List endpoints on the 9Squid API return paginated results. This page explains how to request pages, interpret the response, and iterate through all records.

***

## Query Parameters

All list endpoints support the following pagination parameters:

| Parameter | Type    | Default | Description                  |
| --------- | ------- | ------- | ---------------------------- |
| `page`    | integer | `1`     | Page number (1-indexed)      |
| `limit`   | integer | `20`    | Records per page (max `100`) |

### Example

```bash theme={null}
curl "https://api.9squid.com/v1/api/originator/loans?page=2&limit=50" \
  -H "Authorization: Bearer <your_token>"
```

***

## Response Shape

Every paginated response includes a `pagination` object alongside `data`:

```json theme={null}
{
  "success": true,
  "data": [...],
  "pagination": {
    "page": 2,
    "limit": 50,
    "total": 134,
    "totalPages": 3,
    "hasNextPage": true,
    "hasPrevPage": true
  }
}
```

| Field         | Description                                |
| ------------- | ------------------------------------------ |
| `page`        | Current page number                        |
| `limit`       | Records per page requested                 |
| `total`       | Total number of records matching the query |
| `totalPages`  | Total number of pages                      |
| `hasNextPage` | `true` if there is a next page             |
| `hasPrevPage` | `true` if there is a previous page         |

***

## Iterating All Records

To fetch all records programmatically, loop until `hasNextPage` is `false`:

```javascript theme={null}
async function fetchAll(endpoint, token) {
  const results = [];
  let page = 1;
  let hasNextPage = true;

  while (hasNextPage) {
    const res = await fetch(`${endpoint}?page=${page}&limit=100`, {
      headers: { Authorization: `Bearer ${token}` }
    });
    const json = await res.json();

    results.push(...json.data);
    hasNextPage = json.pagination.hasNextPage;
    page++;
  }

  return results;
}
```

***

## Filtering and Sorting

List endpoints also support optional query parameters for filtering results. Available filters vary per endpoint — refer to the [API Reference](/api-reference/originator-loans/loanscontroller_initiateloan) for the full parameter list per endpoint.

Common filters across list endpoints:

| Parameter | Description                                              |
| --------- | -------------------------------------------------------- |
| `status`  | Filter by resource status (e.g. `IN_REVIEW`, `APPROVED`) |
| `type`    | Filter by loan type (e.g. `Auto`, `Mortgage`)            |
| `from`    | ISO 8601 date — records created after this date          |
| `to`      | ISO 8601 date — records created before this date         |

### Example — Fetch approved deals created in April 2026

```bash theme={null}
curl "https://api.9squid.com/v1/api/originator/loans?status=APPROVED&from=2026-04-01&to=2026-04-30&limit=100" \
  -H "Authorization: Bearer <your_token>"
```
