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

# BITOP

> Perform bitwise operations between strings.

The `BITOP` command in Redis is used to perform bitwise operations on multiple keys (or Redis strings) and store the result in a destination key. It is primarily used for performing logical AND, OR, XOR, and NOT operations on binary data stored in Redis.

## Arguments

<ParamField body="operation" type="AND | OR | XOR | NOT" required>
  Specifies the type of bitwise operation to perform, which can be one of the
  following: `AND`, `OR`, `XOR`, or `NOT`.
</ParamField>

<ParamField body="destkey" type="str" required>
  The key to store the result of the operation in.
</ParamField>

<ParamField body="keys" type="*List[str]" required>
  One or more keys to perform the operation on.
</ParamField>

## Response

<ResponseField type="int" required>
  The size of the string stored in the destination key.
</ResponseField>

<RequestExample>
  ```py Example
  # key1 = 00000001
  # key2 = 00000010
  redis.setbit("key1", 0, 1)
  redis.setbit("key2", 0, 0)
  redis.setbit("key2", 1, 1)

  assert redis.bitop("AND", "dest", "key1", "key2") == 1

  # result = 00000000
  assert redis.getbit("dest", 0) == 0
  assert redis.getbit("dest", 1) == 0
  ```
</RequestExample>
