Skip to main content
Use ZRANGE to read a range of members from a sorted set. By default <start> and <stop> are zero-based indexes into the ordering, inclusive, and may be negative to count from the end, so 0 -1 returns everything and 0 9 the ten lowest scoring members. The option that follows changes what those two arguments mean. BYSCORE reads them as score bounds, inclusive unless prefixed with ( and accepting -inf and +inf. BYLEX reads them as member bounds written [member, (member, -, or +, which is only meaningful when all members share the same score. REV reverses the order, and with BYSCORE or BYLEX it also means the bounds are given from the higher one to the lower one. LIMIT <offset> <count> pages through the result and requires BYSCORE or BYLEX. WITHSCORES includes each member’s score. ZRANGE covers everything ZRANGEBYSCORE, ZRANGEBYLEX, ZREVRANGE, and their variants do, and it is the command Redis recommends for new code. Use ZRANGESTORE to store the result instead of returning it.

Syntax

Arguments

Important points

  • Pair-based results may be flattened into one alternating array in RESP2 while RESP3 preserves nested pairs or a map.
  • 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.
Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples

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