# XREADGROUP

> Reads data from a stream as part of a consumer group.

## Arguments

<ParamField body="group" type="string" required>
  The consumer group name.
</ParamField>

<ParamField body="consumer" type="string" required>
  The consumer name within the group.
</ParamField>

<ParamField body="key" type="string | string[]" required>
  The stream key(s) to read from. Can be a single stream key or an array of stream keys for multiple streams.
</ParamField>

<ParamField body="ids" type="string | string[]" required>
  The starting ID(s) to read from. Use ">" to read messages never delivered to any consumer in the group.
  For multiple streams, provide an array of IDs corresponding to each stream.
</ParamField>

<ParamField body="options">
  <Expandable title="properties">
    <ParamField body="count" type="number">
      The maximum number of messages to return per stream.
    </ParamField>
    <ParamField body="NOACK" type="boolean">
      Don't add messages to the pending entries list (messages won't need acknowledgment).
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField type="Array<[string, Array<[string, string[]]>]> | null">
  Returns an array where each element represents a stream and contains:
  - The stream key
  - An array of messages (ID and field-value pairs)
  
  Returns null if no data is available.
</ResponseField>

<RequestExample>
```ts Read new messages
const result = await redis.xreadgroup("mygroup", "consumer1", "mystream", ">");
```

```ts With count option
const result = await redis.xreadgroup("mygroup", "consumer1", "mystream", ">", {
  count: 5
});
```

```ts With NOACK option
const result = await redis.xreadgroup("mygroup", "consumer1", "mystream", ">", {
  NOACK: true
});
```

```ts Multiple streams
const result = await redis.xreadgroup(
  "mygroup", 
  "consumer1", 
  ["stream1", "stream2"], 
  [">", ">"],
  { count: 1 }
);
```

```ts Read pending messages
const result = await redis.xreadgroup("mygroup", "consumer1", "mystream", "0");
```
</RequestExample>

<ResponseExample>
```ts
[
  ["mystream", [
    ["1638360173533-0", ["field1", "value1", "field2", "value2"]],
    ["1638360173533-1", ["field1", "value3", "field2", "value4"]]
  ]]
]
```
</ResponseExample>
