# Get Array Item

**Get Array Item** node is designed to extract a specific item from an array based on its index. This node is particularly useful when you need to access a particular element within an array for further processing or output in your workflow.

### Properties Panel

<table data-header-hidden><thead><tr><th width="147"></th><th width="413"></th><th></th></tr></thead><tbody><tr><td><strong>Field</strong></td><td><strong>Description</strong></td><td><strong>Required</strong></td></tr><tr><td>Node name</td><td><a href="/pages/jJ1qO0Ju8d7VFyPB2Jy3">Node Name</a></td><td>true</td></tr><tr><td>Variable Name</td><td>The name of the variable where the extracted item will be stored</td><td>true</td></tr><tr><td>Item Index</td><td>The index of the item to be extracted from the array (0-based)<br><br><code>-len(arr) &#x3C;= i &#x3C; len(arr)</code></td><td>true</td></tr><tr><td>Lookup Array</td><td>The array from which the item will be extracted</td><td>true</td></tr></tbody></table>

### Usage

1. Specify a variable name where the extracted item will be stored.
2. Enter the index value of the item you want to extract (remember that array indices start at 0).
3. Provide the lookup array from which the item will be extracted.

### Returns

The node stores the extracted item in the specified variable. You can access this using Magical Autocomplete (e.g., `$.variables.<variable_name>`) in any node below this node.

### Example

Let's say you have an array of user objects fetched from database using [List Records](/flow-builder/node-types/database-nodes/list-records.md) node and you want to extract the second user:

1. Set Variable name to `second_user`
2. Set Index value to 1 (remember, arrays are 0-indexed)
3. Set Lookup array to `$.listRecords.result` (assuming you're using `List Records` node and it's name is `listRecords`)

This will store the second user object in the variable `second_user`. You can then use this in subsequent nodes by `$.variables.second_user`

### Best Practices

* Always ensure that the index value is within the bounds of the array. Attempting to access an out-of-bounds index may result in an error.
* Negative Index are supported for extracting values from back but make sure it's within the size of lookup-array.
* Remember that array indices start at 0, so the first item is at index `0`, the second at index `1`, and so on.
* If you need to access the last item in an array of unknown length, you can use `-1` as index value.
* When working with potentially empty arrays, consider adding a condition to check the array length before attempting to extract an item.


---

# 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://docs.cosmocloud.io/flow-builder/node-types/variable-nodes/arrays/get-array-item.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.
