# Pagination

To efficiently manage large datasets, most of our API endpoints support pagination. When requesting lists of records, you can control the number of results returned per page and navigate through the available pages of data.

#### Parameters

* **`page (optional)`**. Specifies the page number to retrieve. Pages are 1-based, meaning the first page is 1.&#x20;
* **`size (optional)`**. Defines the number of records returned per page defaulting to 100.

#### Response Metadata

Each paginated response includes metadata in the response body that helps you navigate through the results:

* **`totalRecords`**. The total number of records available.&#x20;
* **`totalPages.`**&#x54;he total number of pages available based on the current page size.&#x20;
* **`currentPage`**. The current page number.&#x20;
* **`pageSize`**. The number of records returned per page (matching the size parameter).

#### Example

```bash
GET /api/inventory?page=2&size=50
```

```json
{
  "data": [
    { "inventoryId": "abc123", "name": "MacBook Pro", "status": "Available" },
    { "inventoryId": "def456", "name": "Dell XPS", "status": "Deployed" }
  ],
  "pagination": {
    "totalRecords": 200,
    "totalPages": 4,
    "currentPage": 2,
    "pageSize": 50
  }
}
```

#### Fetching all records

To retrieve all records, you’ll need to paginate through the results by incrementing the page parameter in successive requests until the last page is reached. Each response will contain the totalPages value to indicate the total number of pages available.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.firstbase.com/getting-started/pagination.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
