# 문서 내용 가져오기

{% openapi src="/files/fAmF2Kwil50sF5cXMoEX" path="/documents/{document\_id}/contents/" method="get" %}
[rememberizer\_openapi.yml](https://2913883985-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fs0e4JCKQXzEGPRlMO7nt%2Fuploads%2Fgit-blob-77b6137eeb641262ec8e531c78123c02b825b865%2Frememberizer_openapi.yml?alt=media\&token=ac0eeb18-73cf-42a3-93fe-2ff232a978a3)
{% 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: 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:

```
GET https://docs.rememberizer.ai/ko/undefined-1/api-docs/retrieve-document-contents.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
