> For the complete documentation index, see [llms.txt](https://docs.rememberizer.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rememberizer.ai/zh-cn/kai-fa-zhe-zi-yuan/api-docs/retrieve-document-contents.md).

# 检索文档内容

{% openapi src="/files/MHZeBzqvJFrULa5h2LlV" path="/documents/{document\_id}/contents/" method="get" %}
[rememberizer\_openapi.yml](https://1371168417-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4gvX7KIUy0DhcQETj8Ux%2Fuploads%2Fgit-blob-77b6137eeb641262ec8e531c78123c02b825b865%2Frememberizer_openapi.yml?alt=media\&token=cce1ab0d-330f-4bed-b7da-5635aaf25472)
{% endopenapi %}

## 示例请求

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X GET \
  "https://api.rememberizer.ai/api/v1/documents/12345/contents/?start_chunk=0&end_chunk=20" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
```

{% hint style="info" %}
将 `YOUR_JWT_TOKEN` 替换为您的实际 JWT 令牌，将 `12345` 替换为实际的文档 ID。
{% endhint %}
{% endtab %}

{% tab title="JavaScript" %}

```javascript
const getDocumentContents = async (documentId, startChunk = 0, endChunk = 20) => {
  const url = new URL(`https://api.rememberizer.ai/api/v1/documents/${documentId}/contents/`);
  url.searchParams.append('start_chunk', startChunk);
  url.searchParams.append('end_chunk', endChunk);
  
  const response = await fetch(url.toString(), {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_JWT_TOKEN'
    }
  });
  
  const data = await response.json();
  console.log(data);
  
  // 如果还有更多块，您可以获取它们
  if (data.end_chunk < totalChunks) {
    // 获取下一组块
    await getDocumentContents(documentId, data.end_chunk, data.end_chunk + 20);
  }
};

getDocumentContents(12345);
```

{% hint style="info" %}
将 `YOUR_JWT_TOKEN` 替换为您的实际 JWT 令牌，将 `12345` 替换为实际的文档 ID。
{% endhint %}
{% endtab %}

{% tab title="Python" %}

```python
import requests

def get_document_contents(document_id, start_chunk=0, end_chunk=20):
    headers = {
        "Authorization": "Bearer YOUR_JWT_TOKEN"
    }
    
    params = {
        "start_chunk": start_chunk,
        "end_chunk": end_chunk
    }
    
    response = requests.get(
        f"https://api.rememberizer.ai/api/v1/documents/{document_id}/contents/",
        headers=headers,
        params=params
    )
    
    data = response.json()
    print(data)
    
    # 如果还有更多块，您可以获取它们
    # 这是一个简单的示例 - 您可能想要实现一个适当的递归检查
    if 'end_chunk' in data and data['end_chunk'] < total_chunks:
        get_document_contents(document_id, data['end_chunk'], data['end_chunk'] + 20)

get_document_contents(12345)
```

{% hint style="info" %}
将 `YOUR_JWT_TOKEN` 替换为您的实际 JWT 令牌，将 `12345` 替换为实际的文档 ID。
{% endhint %}
{% endtab %}
{% endtabs %}

## 路径参数

| 参数           | 类型 | 描述                  |
| ------------ | -- | ------------------- |
| document\_id | 整数 | **必填。** 要检索内容的文档ID。 |

## 查询参数

| 参数           | 类型 | 描述                            |
| ------------ | -- | ----------------------------- |
| start\_chunk | 整数 | 起始块索引。默认值为 0。                 |
| end\_chunk   | 整数 | 结束块索引。默认值为 start\_chunk + 20。 |

## 响应格式

```json
{
  "content": "文档块的完整文本内容...",
  "end_chunk": 20
}
```

## 错误响应

| 状态码 | 描述      |
| --- | ------- |
| 404 | 文档未找到   |
| 500 | 服务器内部错误 |

## 大型文档的分页

对于大型文档，内容被分成多个块。您可以通过多次请求来检索完整文档：

1. 先发起一个请求，使用 `start_chunk=0`
2. 将返回的 `end_chunk` 值作为下一个请求的 `start_chunk`
3. 继续直到您检索到所有块

此端点返回文档的原始文本内容，使您能够访问完整信息以进行详细处理或分析。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.rememberizer.ai/zh-cn/kai-fa-zhe-zi-yuan/api-docs/retrieve-document-contents.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
