Limit
Cap the number of items in an array with offset and direction control.
The Limit node truncates an array to a maximum number of items. You can take from the beginning with an optional offset (like SQL's LIMIT and OFFSET), or take from the end of the array. Use it to implement pagination, cap result sets, or grab just the first or last few records.
Configuration
Source Array
| Field | Type | Required | Description |
|---|---|---|---|
| Source Array | template string | Yes | Variable path to the array to limit, e.g. nodes.httpRequest_1.body.results |
The source must resolve to an array. If it resolves to a non-array value, the node fails with a NOT_ARRAY error.
Max Items
| Field | Type | Required | Description |
|---|---|---|---|
| Max Items | number | No | Maximum number of items to keep. Defaults to 10. Minimum is 1. |
Offset
| Field | Type | Required | Description |
|---|---|---|---|
| Offset | number | No | Number of items to skip from the start before taking. Defaults to 0. Only applies when Keep Last is off. |
Keep Last Items
| Field | Type | Required | Description |
|---|---|---|---|
| Keep Last Items | toggle | No | When enabled, takes the last N items instead of the first N. Offset is ignored in this mode. Defaults to off. |
Output
| Field | Type | Description |
|---|---|---|
| items | array | The truncated array |
| total | number | Total number of items in the original source array before limiting |
Example
An API returns 500 search results, but you only need the top 20:
- Add a Limit node after the HTTP Request node.
- Set Source Array to
nodes.httpRequest_1.body.results. - Set Max Items to
20. - Leave Offset at
0and Keep Last off.
The output at nodes.limit_1.items contains only the first 20 items, and nodes.limit_1.total tells you how many existed before truncation.
To get the second page of results, set Offset to 20 and Max Items to 20. To grab the 5 most recent entries (assuming the array is sorted chronologically), enable Keep Last Items and set Max Items to 5.
See the Logic Nodes overview for a full list of available nodes.