# HGET

> Get the value of one field of a hash.

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

```
HGET key field
```

- Group: Hash
- Complexity: O(1)
- HotKV Cloud: all plans
- On-Premise: no license needed

`HGET` returns the value stored in `field` of the hash at `key`. A field whose
time to live has passed is treated as missing.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Field exists | Bulk string: the value | Bulk string |
| Field or key does not exist | Nil bulk string | Null |

`HGET` replies with a `WRONGTYPE` error if `key` holds a value that is not a
hash.

## Examples

```
127.0.0.1:6379> HSET user:1 name "Ada"
(integer) 1
127.0.0.1:6379> HGET user:1 name
"Ada"
127.0.0.1:6379> HGET user:1 email
(nil)
```

## Compatibility

Same as Redis 7.4 and Valkey 8.

## See also

[HMGET](https://docs.hotkv.com/commands/hmget/index.md), [HGETALL](https://docs.hotkv.com/commands/hgetall/index.md), [HGETEX](https://docs.hotkv.com/commands/hgetex/index.md),
[HEXISTS](https://docs.hotkv.com/commands/hexists/index.md), [HSET](https://docs.hotkv.com/commands/hset/index.md)