# INCRBY

> Add an integer to the integer stored at a key.

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

```
INCRBY key increment
```

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

`INCRBY` adds `increment`, which may be negative, to the number stored at
`key` and returns the new value. A missing key counts as `0`. Both the stored
value and `increment` must be signed 64-bit integers, and the key keeps its
time to live.

## Return value

| Case | RESP2 | RESP3 |
| --- | --- | --- |
| Always | Integer: the value after the increment | Integer |

Errors:

- `ERR value is not an integer or out of range` when `increment` or the stored
  value is not an integer.
- `ERR increment or decrement would overflow` when the result does not fit in
  a signed 64-bit integer.
- `WRONGTYPE` when the key holds a value that is not a string.

## Examples

```
127.0.0.1:6379> SET points 10
OK
127.0.0.1:6379> INCRBY points 15
(integer) 25
127.0.0.1:6379> INCRBY points -30
(integer) -5
127.0.0.1:6379> INCRBY points 1.5
(error) ERR value is not an integer or out of range
```

## Compatibility

Same as Redis 7 and Valkey 8.

## See also

[INCR](https://docs.hotkv.com/commands/incr/index.md), [DECRBY](https://docs.hotkv.com/commands/decrby/index.md),
[INCRBYFLOAT](https://docs.hotkv.com/commands/incrbyfloat/index.md)