# SMEMBERS

> Get all members of a set.

URL: https://docs.hotkv.com/commands/smembers/

```
SMEMBERS key
```

- Group: Set
- Complexity: O(N) where N is the size of the set
- HotKV Cloud: all plans
- On-Premise: no license needed

`SMEMBERS` returns every member of the set stored at `key`. The order is not
defined. For large sets, prefer [SSCAN](https://docs.hotkv.com/commands/sscan/index.md) so one reply does not
carry the whole set.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Set exists | Array of bulk strings | Set of bulk strings |
| Key does not exist | Empty array | Empty set |

`SMEMBERS` replies with a `WRONGTYPE` error if `key` holds a value that is not
a set.

## Examples

```
127.0.0.1:6379> SADD tags "redis" "cache"
(integer) 2
127.0.0.1:6379> SMEMBERS tags
1) "redis"
2) "cache"
127.0.0.1:6379> SMEMBERS nosuchkey
(empty array)
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[SSCAN](https://docs.hotkv.com/commands/sscan/index.md), [SISMEMBER](https://docs.hotkv.com/commands/sismember/index.md), [SCARD](https://docs.hotkv.com/commands/scard/index.md),
[SRANDMEMBER](https://docs.hotkv.com/commands/srandmember/index.md)