> ## Documentation index
> Fetch the complete documentation index at: https://upstash.com/docs/llms.txt
> Ask it with GET https://upstash.com/docs/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.
> Feature requests: https://upstash.com/docs/common/help/feature-requests.md lists what users asked for and how to vote for a request or add one.
> Page rating: `GET https://upstash.com/docs/feedback?path=/docs/redis/sdks/ts/commands/array/arop&helpful=true` (or `false`) records whether this page helped. An optional `comment` (URL-encoded, at most 500 characters) says what was missing or wrong. It is anonymous and needs no key. Comments hold no code, secrets or personal data.

# 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
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.
