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

# Range

The range method is used to retrieve documents in chunks with pagination. This method supports a variety of options to configure the query to your needs.

<Note>
  The range command is stateless, meaning you need to pass all of the parameters in each subsequent request.
</Note>

## Arguments

<ParamField body="cursor" type="string" required>
  The cursor to the last retrieved document. Should be set to `0` in the initial range request.
</ParamField>

<ParamField body="prefix" type="string">
  A string prefix to match document IDs. All documents with IDs that start with this prefix will be retrieved.
</ParamField>

<ParamField body="limit" type="number" required>
  The number of maximum documents wanted in the response of range. (page size)
</ParamField>

## Response

<ResponseField name="RangeResponse" type="Object" required>
  <Expandable defaultOpen="true">
    <ResponseField name="nextCursor" type="string">
      The cursor for the next set of documents. When it becomes "", it means all documents were retrieved.
    </ResponseField>

    <ResponseField name="documents" type="Document[]">
      The list of documents retrieved in this range.
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```typescript Basic theme={"system"}
  const responseRange = await index.range({
    cursor: "0",
    limit: 2,
  });

  /*
  {
    nextCursor: '2',
    documents: [
      { id: "doc1", content: { ... }, metadata: { ... } },
      { id: "doc2", content: { ... }, metadata: { ... } }
    ]
  }
  */
  ```

  ```typescript ID prefix theme={"system"}
  const responseRange = await index.range({
    cursor: "0",
    limit: 2,
    prefix: "test-",
  });

  /*
  {
    nextCursor: '2',
    documents: [
      { id: "test-1", content: { ... }, metadata: { ... } },
      { id: "test-2", content: { ... }, metadata: { ... } }
    ]
  }
  */
  ```
</RequestExample>
