# Source: https://upstash.com/docs/redis/sdks/ts/commands/zset/zscan.md

# Source: https://upstash.com/docs/redis/sdks/py/commands/zset/zscan.md

> ## 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.

# ZSCAN

> Scan a sorted set

Return a paginated list of members and their scores of an ordered set matching a pattern.

## Arguments

<ParamField body="key" type="str" required>
  The key of the sorted set.
</ParamField>

<ParamField body="cursor" type="int" required>
  The cursor, use `0` in the beginning and then use the returned cursor for subsequent calls.
</ParamField>

<ParamField body="match" type="str">
  Glob-style pattern to filter by members.
</ParamField>

<ParamField body="count" type="int">
  Number of members to return per call.
</ParamField>

## Response

<ResponseField type="Tuple[int, List[str]]" required>
  The new cursor and keys as a tuple.
  If the new cursor is `0` the iteration is complete.
</ResponseField>

<RequestExample>
  ```py Example theme={"system"}
  # Get all elements of an ordered set.

  cursor = 0
  results = []

  while True:
      cursor, keys = redis.zscan("myzset", cursor, match="*")

      results.extend(keys)
      if cursor == 0:
          break

  for key, score in results:
      print(key, score)
  ```
</RequestExample>