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

# ZINCRBY

> Increment member's score.

Use `ZINCRBY` to add an increment to the score of a member of a sorted set.

A member that is not there yet is created with the increment as its score, and a missing key is created too, so no initialization step is needed. The increment may be negative to move a member down. The reply is the new score.

Because the update is atomic and the set stays ordered, this is the core operation behind leaderboards, vote counts, and any ranking that has to reflect concurrent updates: increment a member's score and read the position back with [`ZRANK`](/docs/redis/commands/sorted-set/zrank) or the top of the ranking with [`ZRANGE`](/docs/redis/commands/sorted-set/zrange).

## Syntax

```redis theme={"system"}
ZINCRBY <key> <increment> <member>
```

## Arguments

| Argument      | Required | Repeatable | Description                          |
| ------------- | -------- | ---------- | ------------------------------------ |
| `<key>`       | Yes      | No         | Redis key targeted by the command.   |
| `<increment>` | Yes      | No         | Amount to add to the member's score. |
| `<member>`    | Yes      | No         | Member name.                         |

## Important points

* RESP2 represents floating-point reply values as bulk strings; RESP3 may use native double replies. Client libraries commonly decode either form to a language number.

## Response

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.

| Protocol | Reply                           |
| -------- | ------------------------------- |
| RESP2    | Bulk string containing a number |
| RESP3    | Double                          |

<Note>
  Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.
</Note>

## Examples

TCP examples use the TLS `REDIS_URL` from the Upstash console. REST examples use `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN`.

<AccordionGroup>
  <Accordion title="Redis CLI" icon="terminal">
    ```bash theme={"system"}
    ZINCRBY my-key 1 member
    ```
  </Accordion>

  <Accordion title="@upstash/redis" icon="node-js" iconType="brands">
    ```ts theme={"system"}
    import { Redis } from "@upstash/redis";

    const redis = Redis.fromEnv();

    await redis.zadd("key", 1, "member");
    const value = await redis.zincrby("key", 2, "member");
    console.log(value); // 3
    ```
  </Accordion>

  <Accordion title="upstash_redis" icon="python" iconType="brands">
    ```python theme={"system"}
    from upstash_redis import Redis

    redis = Redis.from_env()
    result = redis.zincrby("my-key", 1, "member")
    print(result)
    ```
  </Accordion>

  <Accordion title="ioredis" icon="node-js" iconType="brands">
    ```ts theme={"system"}
    import Redis from "ioredis";

    const redis = new Redis(process.env.REDIS_URL!);
    const result = await redis.zincrby("my-key", "1", "member");
    console.log(result);
    ```
  </Accordion>

  <Accordion title="node-redis" icon="node-js" iconType="brands">
    ```ts theme={"system"}
    import { createClient } from "redis";

    const client = await createClient({ url: process.env.REDIS_URL })
      .on("error", console.error)
      .connect();
    const result = await client.zIncrBy("my-key", 1, "member");
    console.log(result);
    ```
  </Accordion>

  <Accordion title="redis-py" icon="python" iconType="brands">
    ```python theme={"system"}
    import os
    import redis

    client = redis.from_url(os.environ["REDIS_URL"])
    result = client.zincrby("my-key", 1, "member")
    print(result)
    ```
  </Accordion>

  <Accordion title="go-redis" icon="golang" iconType="brands">
    ```go theme={"system"}
    package main

    import (
        "context"
        "fmt"
        "os"

        "github.com/redis/go-redis/v9"
    )

    func main() {
        opts, err := redis.ParseURL(os.Getenv("REDIS_URL"))
        if err != nil {
            panic(err)
        }
        client := redis.NewClient(opts)
        result, err := client.ZIncrBy(context.Background(), "my-key", 1, "member").Result()
        if err != nil {
            panic(err)
        }
        fmt.Println(result)
    }
    ```
  </Accordion>

  <Accordion title="jedis" icon="java" iconType="brands">
    ```java theme={"system"}
    import java.net.URI;

    import redis.clients.jedis.Jedis;

    try (Jedis jedis = new Jedis(new URI(System.getenv("REDIS_URL")))) {
      Object result = jedis.zincrby("my-key", 1, "member");
      System.out.println(result);
    }
    ```
  </Accordion>

  <Accordion title="redis-rs" icon="rust" iconType="brands">
    ```rust theme={"system"}
    use redis::TypedCommands;

    fn main() -> redis::RedisResult<()> {
        let url = std::env::var("REDIS_URL").expect("REDIS_URL is not set");
        let client = redis::Client::open(url)?;
        let mut connection = client.get_connection()?;

        let result = connection.zincr("my-key", "member", 1)?;
        println!("{result:?}");
        Ok(())
    }
    ```
  </Accordion>
</AccordionGroup>


## Related topics

- [ZINCRBY](/docs/redis/sdks/ts/commands/zset/zincrby.md)
- [Costs](/docs/redis/sdks/ratelimit-ts/costs.md)
- [ZRANK](/docs/redis/commands/sorted-set/zrank.md)
- [ZADD](/docs/redis/commands/sorted-set/zadd.md)
