> 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/vi/tai-nguyen-cho-nha-phat-trien/api-docs/retrieve-document-contents.md).

# Lấy nội dung tài liệu

{% openapi src="/files/uCR2Hrq9CjDxpCLaqzhl" path="/documents/{document\_id}/contents/" method="get" %}
[rememberizer\_openapi.yml](https://4187618229-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fwbxu0T4faQnPtKbPzrD5%2Fuploads%2Fgit-blob-77b6137eeb641262ec8e531c78123c02b825b865%2Frememberizer_openapi.yml?alt=media\&token=b77a395b-ed7b-4546-9ec7-182d4939fd1b)
{% endopenapi %}

## Ví dụ Yêu cầu

{% 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" %}
Thay thế `YOUR_JWT_TOKEN` bằng mã thông báo JWT thực tế của bạn và `12345` bằng ID tài liệu thực tế.
{% 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);
  
  // Nếu có nhiều chunk hơn, bạn có thể lấy chúng
  if (data.end_chunk < totalChunks) {
    // Lấy tập hợp chunk tiếp theo
    await getDocumentContents(documentId, data.end_chunk, data.end_chunk + 20);
  }
};

getDocumentContents(12345);
```

{% hint style="info" %}
Thay thế `YOUR_JWT_TOKEN` bằng mã thông báo JWT thực tế của bạn và `12345` bằng ID tài liệu thực tế.
{% 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)
    
    # Nếu có nhiều chunk hơn, bạn có thể lấy chúng
    # Đây là một ví dụ đơn giản - bạn có thể muốn triển khai một kiểm tra đệ quy đúng
    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" %}
Thay thế `YOUR_JWT_TOKEN` bằng mã thông báo JWT thực tế của bạn và `12345` bằng ID tài liệu thực tế.
{% endhint %}
{% endtab %}
{% endtabs %}

## Tham số Đường dẫn

| Tham số      | Loại      | Mô tả                                          |
| ------------ | --------- | ---------------------------------------------- |
| document\_id | số nguyên | **Bắt buộc.** ID của tài liệu để lấy nội dung. |

## Tham số truy vấn

| Tham số      | Loại      | Mô tả                                                |
| ------------ | --------- | ---------------------------------------------------- |
| start\_chunk | số nguyên | Chỉ số khối bắt đầu. Mặc định là 0.                  |
| end\_chunk   | số nguyên | Chỉ số khối kết thúc. Mặc định là start\_chunk + 20. |

## Định dạng Phản hồi

```json
{
  "content": "Nội dung văn bản đầy đủ của các đoạn tài liệu...",
  "end_chunk": 20
}
```

## Phản hồi lỗi

| Mã trạng thái | Mô tả                   |
| ------------- | ----------------------- |
| 404           | Tài liệu không tìm thấy |
| 500           | Lỗi máy chủ nội bộ      |

## Phân trang cho Tài liệu Lớn

Đối với các tài liệu lớn, nội dung được chia thành các phần. Bạn có thể lấy toàn bộ tài liệu bằng cách thực hiện nhiều yêu cầu:

1. Thực hiện một yêu cầu ban đầu với `start_chunk=0`
2. Sử dụng giá trị `end_chunk` được trả về làm `start_chunk` cho yêu cầu tiếp theo
3. Tiếp tục cho đến khi bạn đã lấy tất cả các phần

Điểm cuối này trả về nội dung văn bản thô của một tài liệu, cho phép bạn truy cập đầy đủ thông tin để xử lý hoặc phân tích chi tiết.


---

# 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/vi/tai-nguyen-cho-nha-phat-trien/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.
