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

## Arguments

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

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

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

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

## Response

<ResponseField type="[number, TMember[]]" required>
  The new cursor and the members.
  If the new cursor is `0` the iteration is complete.
</ResponseField>

<RequestExample>
  ```ts Example theme={"system"}
  await redis.zadd("key", 
      { score: 1, member: "a" },
      { score: 2, member: "ab" },
      { score: 3, member: "b" },
      { score: 4, member: "c" },
      { score: 5, member: "d" },
  )
  const [newCursor, members] = await redis.zscan("key", 0, { match: "a*"});
  console.log(newCursor); // likely `0` since this is a very small set
  console.log(members); // ["a", "ab"]
  ```

  ```ts withCount theme={"system"}
  await redis.zadd("key", 
      { score: 1, member: "a" },
      { score: 2, member: "ab" },
      { score: 3, member: "b" },
      { score: 4, member: "c" },
      { score: 5, member: "d" },
  )
  const [newCursor, members] = await redis.zscan("key", 0, { match: "a*", count: 1});
  console.log(newCursor); // likely `0` since this is a very small set
  console.log(members); // ["a"]
  ```
</RequestExample>
