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

# Pagination

> Use page and limit query parameters to navigate paginated list endpoints and iterate through results

# Pagination

List endpoints return paginated results. Use query parameters to control which page and how many items to return.

## Parameters

| Parameter | Type    | Default | Max   | Description             |
| --------- | ------- | ------- | ----- | ----------------------- |
| `page`    | integer | `1`     | —     | Page number (1-indexed) |
| `limit`   | integer | `20`    | `100` | Items per page          |

## Example request

```bash theme={null}
curl "https://api.dronelist.io/v1/equipment?page=2&limit=10" \
  -H "X-API-Key: dl_your_key_here"
```

## Response format

Every paginated response includes a `meta.pagination` object:

```json theme={null}
{
  "success": true,
  "data": [ ... ],
  "meta": {
    "pagination": {
      "page": 2,
      "limit": 10,
      "total": 42,
      "hasMore": true
    }
  }
}
```

| Field     | Type    | Description                                   |
| --------- | ------- | --------------------------------------------- |
| `page`    | integer | Current page number                           |
| `limit`   | integer | Items per page                                |
| `total`   | integer | Total number of items across all pages        |
| `hasMore` | boolean | `true` if there are more pages after this one |

## Paginated endpoints

| Endpoint                        | Notes                               |
| ------------------------------- | ----------------------------------- |
| `GET /v1/equipment`             | In-memory pagination                |
| `GET /v1/equipment/:id/flights` | Native DB pagination (limit/offset) |
| `GET /v1/projects`              | In-memory pagination                |

Non-paginated endpoints (`GET /v1/services`) return all results directly without a `meta.pagination` wrapper.

## Iterating through all pages

<CodeGroup>
  ```javascript Node.js theme={null}
  async function fetchAll(endpoint, apiKey) {
    const items = [];
    let page = 1;
    let hasMore = true;

    while (hasMore) {
      const res = await fetch(
        `https://api.dronelist.io${endpoint}?page=${page}&limit=100`,
        { headers: { 'X-API-Key': apiKey } }
      );
      const json = await res.json();

      items.push(...json.data);
      hasMore = json.meta.pagination.hasMore;
      page++;
    }

    return items;
  }
  ```

  ```python Python theme={null}
  import requests

  def fetch_all(endpoint, api_key):
      items = []
      page = 1
      has_more = True

      while has_more:
          response = requests.get(
              f'https://api.dronelist.io{endpoint}',
              params={'page': page, 'limit': 100},
              headers={'X-API-Key': api_key}
          )
          data = response.json()

          items.extend(data['data'])
          has_more = data['meta']['pagination']['hasMore']
          page += 1

      return items
  ```
</CodeGroup>

<Tip>
  Use `limit=100` (the maximum) when iterating to minimize the number of requests.
</Tip>
