{
  "schema_version": 2,
  "id": "commands/topk.add",
  "title": "TOPK.ADD",
  "url": "https://redis.io/docs/latest/commands/topk.add/",
  "summary": "Adds an item to a Top-k sketch. Multiple items can be added at the same time.",
  "since": "2.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-09-18T09:48:54+01:00",
  "page_type": "content",
  "content_hash": "c774f5a7a26ce131d0f666455a96138e3b4c2a6a534404e4f0f0f84f0f721296",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Adds an item to a Top-k sketch. \nMultiple items can be added at the same time.\nIf an item enters the Top-K sketch, the item that is expelled (if any) is returned.\nThis allows dynamic heavy-hitter detection of items being entered or expelled from Top-K sketch."
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nthe name of the sketch where items are added.\n\n</details>\n\n<details open><summary><code>item [item ...]</code></summary>\n\nthe items to be added.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "[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; Supported</span><br /> | <span title=\"Supported\"><nobr>&#x2705; Flexible & Annual</nobr></span><br /><span title=\"Supported\">&#x2705; Free & Fixed</nobr></span> |  |"
    },
    {
      "id": "return-information",
      "title": "Return information",
      "role": "returns",
      "text": "**RESP2:**\n\nOne of the following:\n\n* [Array](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays) of [bulk string replies](https://redis.io/docs/latest/develop/reference/protocol-spec#bulk-strings) containing either dropped elements or [nil (null bulk string)](https://redis.io/docs/latest/develop/reference/protocol-spec#bulk-strings).\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) in these cases: incorrect number of arguments or non-existant key.\n\n**RESP3:**\n\nOne of the following:\n\n* [Array](https://redis.io/docs/latest/develop/reference/protocol-spec#arrays) of [bulk string replies](https://redis.io/docs/latest/develop/reference/protocol-spec#bulk-strings) containing either dropped elements or [null](https://redis.io/docs/latest/develop/reference/protocol-spec#nulls).\n* [Simple error reply](https://redis.io/docs/latest/develop/reference/protocol-spec#simple-errors) in these cases: incorrect number of arguments, non-existant key, or key of the incorrect type."
    }
  ],
  "examples": [
    {
      "id": "examples-ex0",
      "language": "plaintext",
      "code": "redis> TOPK.ADD topk foo bar 42\n1) (nil)\n2) baz\n3) (nil)",
      "section_id": "examples"
    }
  ]
}
