> ## Documentation Index
> Fetch the complete documentation index at: https://upstash-dx-3009-array-sdk-docs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AROP

> Aggregate values in an inclusive array range.

`SUM`, `MIN`, and `MAX` aggregate numeric values. `AND`, `OR`, and `XOR` fold values as 64-bit integers, truncating fractions. These operations skip non-numeric values. `USED` counts occupied slots. `MATCH` counts values equal to the supplied value.

## Arguments

<ParamField body="key" type="string" required>
  The array key.
</ParamField>

<ParamField body="start" type="number | string" required>
  The first index of the inclusive range.
</ParamField>

<ParamField body="end" type="number | string" required>
  The last index of the inclusive range.
</ParamField>

<ParamField body="operation" type="ArOpOperation<TData>" required>
  The reduction to apply. See the operations below.
</ParamField>

Pass `"SUM"`, `"MIN"`, `"MAX"`, `"AND"`, `"OR"`, `"XOR"`, or `"USED"` (lowercase is also accepted). For equality matching, pass `{ match: value }` as the operation.

## Response

<ResponseField type="number | null" required>
  The numeric aggregate, or `null` (TypeScript) / `None` (Python) if no values can be used. `USED` and `MATCH` return zero for an empty range.
</ResponseField>

<RequestExample>
  ```ts Example theme={"system"}
  await redis.arset("readings", 0, 1, 2, 3);
  console.log(await redis.arop("readings", 0, 2, "SUM")); // 6

  await redis.arset("statuses", 0, "ok", "error", "error");
  console.log(await redis.arop("statuses", 0, 2, { match: "error" })); // 2
  ```
</RequestExample>

See the [server command reference](/redis/commands/array/arop) for protocol details.
