
{
  "id": "get",
  "title": "GET",
  "url": "https://redis.io/docs/latest/commands/get/",
  "summary": "Returns the string value of a key.",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-05-27T13:11:51-07:00",
  "page_type": "content",
  "content_hash": "e2e6a5fb8afc57bec95b1eef3f23c1cbdc65b1a01ac597cc3218b0d1936f4279",
  "sections": [
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "GET nonexisting\nSET mykey \"Hello\"\nGET mykey"
    },
    {
      "id": "code-examples",
      "title": "Code examples",
      "role": "example",
      "text": "Foundational: Retrieve the string value of a key using GET (returns nil if key doesn't exist)\n\n**Difficulty:** Beginner\n\n**Available in:** Python, JavaScript (Node.js), Java (Synchronous - Jedis), Go, C#-Sync (SE.Redis)\n\n##### Python\n\n[code example]\n\n##### JavaScript (Node.js)\n\n[code example]\n\n##### Java (Synchronous - Jedis)\n\n[code example]\n\n##### Go\n\n[code example]\n\n##### C#-Sync (SE.Redis)\n\n[code example]"
    },
    {
      "id": "redis-software-and-redis-cloud-compatibility",
      "title": "Redis Software and Redis Cloud compatibility",
      "role": "content",
      "text": "| Redis<br />Software | Redis<br />Cloud | <span style=\"min-width: 9em; display: table-cell\">Notes</span> |\n|:----------------------|:-----------------|:------|\n| <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> | <span title=\"Supported\">&#x2705; Standard</span><br /><span title=\"Supported\"><nobr>&#x2705; Active-Active</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): the value of the key.\n* [Nil reply](../../develop/reference/protocol-spec#bulk-strings): if the key does not exist.\n\n**RESP3:**\n\nOne of the following:\n* [Bulk string reply](../../develop/reference/protocol-spec#bulk-strings): the value of the key.\n* [Null reply](../../develop/reference/protocol-spec#nulls): key does not exist."
    }
  ],
  "examples": [
    {
      "id": "code-examples-ex0",
      "language": "python",
      "code": "\"\"\"\nCode samples for data structure store quickstart pages:\n    https://redis.io/docs/latest/develop/get-started/data-store/\n\"\"\"\n\nimport redis\n\nr = redis.Redis(host=\"localhost\", port=6379, db=0, decode_responses=True)\n\nres = r.set(\"bike:1\", \"Process 134\")\nprint(res)\n# >>> True\n\nres = r.get(\"bike:1\")\nprint(res)\n# >>> \"Process 134\"",
      "section_id": "code-examples"
    },
    {
      "id": "code-examples-ex1",
      "language": "javascript",
      "code": "import { createClient } from 'redis';\n\nconst client = createClient();\n\nclient.on('error', err => console.log('Redis Client Error', err));\n\nawait client.connect().catch(console.error);\n\nawait client.set('bike:1', 'Process 134');\nconst value = await client.get('bike:1');\nconsole.log(value);\n// returns 'Process 134'\n\nawait client.close();",
      "section_id": "code-examples"
    },
    {
      "id": "code-examples-ex2",
      "language": "java",
      "code": "package io.redis.examples;\n\nimport redis.clients.jedis.RedisClient;\n\n\npublic class SetGetExample {\n\n  public void run() {\n\n    RedisClient jedis = RedisClient.create(\"redis://localhost:6379\");\n\n    String status = jedis.set(\"bike:1\", \"Process 134\");\n\n    if (\"OK\".equals(status)) System.out.println(\"Successfully added a bike.\");\n\n    String value = jedis.get(\"bike:1\");\n\n    if (value != null) System.out.println(\"The name of the bike is: \" + value + \".\");\n\n\n    jedis.close();\n  }\n}",
      "section_id": "code-examples"
    },
    {
      "id": "code-examples-ex3",
      "language": "go",
      "code": "package example_commands_test\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\t\"github.com/redis/go-redis/v9\"\n)\n\nfunc ExampleClient_Set_and_get() {\n\tctx := context.Background()\n\n\trdb := redis.NewClient(&redis.Options{\n\t\tAddr:     \"localhost:6379\",\n\t\tPassword: \"\", // no password docs\n\t\tDB:       0,  // use default DB\n\t})\n\n\n\n\terr := rdb.Set(ctx, \"bike:1\", \"Process 134\", 0).Err()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(\"OK\")\n\n\tvalue, err := rdb.Get(ctx, \"bike:1\").Result()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Printf(\"The name of the bike is %s\", value)\n\n}",
      "section_id": "code-examples"
    },
    {
      "id": "code-examples-ex4",
      "language": "csharp",
      "code": "using NRedisStack.Tests;\nusing StackExchange.Redis;\n\npublic class SetGetExample\n{\n    public void Run()\n    {\n        var muxer = ConnectionMultiplexer.Connect(\"localhost:6379\");\n        var db = muxer.GetDatabase();\n\n        bool status = db.StringSet(\"bike:1\", \"Process 134\");\n\n        if (status)\n            Console.WriteLine(\"Successfully added a bike.\");\n\n        var value = db.StringGet(\"bike:1\");\n\n        if (value.HasValue)\n            Console.WriteLine(\"The name of the bike is: \" + value + \".\");\n\n    }\n}",
      "section_id": "code-examples"
    }
  ]
}
