> ## 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/py/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="str" required>
  The array key.
</ParamField>

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

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

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

<ParamField body="value" type="ValueT">
  The value to match. Required for `MATCH`; omit it for other operations.
</ParamField>

Pass `"SUM"`, `"MIN"`, `"MAX"`, `"AND"`, `"OR"`, `"XOR"`, `"USED"`, or `"MATCH"`. For `MATCH`, also supply `value`.

## Response

<ResponseField type="int | float | None" 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>
```py Example
redis.arset("readings", 0, 1, 2, 3)
print(redis.arop("readings", 0, 2, "SUM"))  # 6

redis.arset("statuses", 0, "ok", "error", "error")
print(redis.arop("statuses", 0, 2, "MATCH", "error"))  # 2
```
</RequestExample>

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