{
  "schema_version": 2,
  "id": "commands/xrevrange",
  "title": "XREVRANGE",
  "url": "https://redis.io/docs/latest/commands/xrevrange/",
  "summary": "Returns the messages from a stream within a range of IDs in reverse order.",
  "since": "5.0.0",
  "tags": [
    "docs",
    "develop",
    "stack",
    "oss",
    "rs",
    "rc",
    "oss",
    "kubernetes",
    "clients"
  ],
  "last_updated": "2026-07-24T11:07:00+02:00",
  "page_type": "content",
  "content_hash": "54a0ebb6c71fbf8d522d90bba0c3986d485b358901e8044f4b7f4b3b62435070",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "This command works like XRANGE, but returns entries in reverse order. Specify the end ID first, then the start ID. XREVRANGE returns the entries between those IDs, inclusive, starting from the end of the range.\n\nSo for example, to get all the elements from the higher ID to the lower\nID you can use:\n\n    XREVRANGE somestream + -\n\nSimilarly to get just the last element added into the stream it is\nenough to send:\n\n    XREVRANGE somestream + - COUNT 1"
    },
    {
      "id": "required-arguments",
      "title": "Required arguments",
      "role": "content",
      "text": "<details open><summary><code>key</code></summary>\n\nThe stream key.\n\n</details>\n\n<details open><summary><code>end</code></summary>\n\nThe end of the ID range, inclusive. Entries are returned in reverse order. Use `+` for the greatest ID.\n\n</details>\n\n<details open><summary><code>start</code></summary>\n\nThe start of the ID range, inclusive. Use `-` for the smallest ID.\n\n</details>"
    },
    {
      "id": "optional-arguments",
      "title": "Optional arguments",
      "role": "parameters",
      "text": "<details open><summary><code>COUNT count</code></summary>\n\nThe maximum number of entries to return.\n\n</details>"
    },
    {
      "id": "examples",
      "title": "Examples",
      "role": "example",
      "text": "redis> XADD writers * name Virginia surname Woolf\n\"1784722084747-0\"\nredis> XADD writers * name Jane surname Austen\n\"1784722084747-1\"\nredis> XADD writers * name Toni surname Morrison\n\"1784722084748-0\"\nredis> XADD writers * name Agatha surname Christie\n\"1784722084748-1\"\nredis> XADD writers * name Ngozi surname Adichie\n\"1784722084748-2\"\nredis> XLEN writers\n(integer) 5\nredis> XREVRANGE writers + - COUNT 1\n1) 1) \"1784722084748-2\"\n   2) 1) \"name\"\n      2) \"Ngozi\"\n      3) \"surname\"\n      4) \"Adichie\""
    },
    {
      "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\n[Array reply](../../develop/reference/protocol-spec#arrays): The command returns the entries with IDs matching the specified range. The returned entries are complete, which means that the ID and all the fields they are composed of are returned. Moreover, the entries are returned with their fields and values in the same order as `XADD` added them.\n\n**RESP3:**\n\n[Array reply](../../develop/reference/protocol-spec#arrays): The command returns the entries with IDs matching the specified range. The returned entries are complete, which means that the ID and all the fields they are composed of are returned. Moreover, the entries are returned with their fields and values in the same order as `XADD` added them."
    }
  ],
  "examples": []
}
