Sign In

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

FieldTypeRequiredDescription
Source Arraytemplate stringYesVariable 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

FieldTypeRequiredDescription
Max ItemsnumberNoMaximum number of items to keep. Defaults to 10. Minimum is 1.

Offset

FieldTypeRequiredDescription
OffsetnumberNoNumber of items to skip from the start before taking. Defaults to 0. Only applies when Keep Last is off.

Keep Last Items

FieldTypeRequiredDescription
Keep Last ItemstoggleNoWhen enabled, takes the last N items instead of the first N. Offset is ignored in this mode. Defaults to off.

Output

FieldTypeDescription
itemsarrayThe truncated array
totalnumberTotal number of items in the original source array before limiting

Example

An API returns 500 search results, but you only need the top 20:

  1. Add a Limit node after the HTTP Request node.
  2. Set Source Array to nodes.httpRequest_1.body.results.
  3. Set Max Items to 20.
  4. Leave Offset at 0 and 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.

On this page

Limit | Buildorado