# Retrieve document contents

{% openapi src="/files/7T1Jx6BU3fZ2U5LsImW1" path="/documents/{document\_id}/contents/" method="get" %}
[rememberizer\_openapi.yml](https://2952947711-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyNqpTh7Mh66N0RnO0k24%2Fuploads%2Fgit-blob-77b6137eeb641262ec8e531c78123c02b825b865%2Frememberizer_openapi.yml?alt=media\&token=cbad765b-1613-4222-b591-9ae17a3b7cfa)
{% endopenapi %}

## Example Requests

{% 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" %}
Replace `YOUR_JWT_TOKEN` with your actual JWT token and `12345` with an actual document 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 there are more chunks, you can fetch them
  if (data.end_chunk < totalChunks) {
    // Fetch the next set of chunks
    await getDocumentContents(documentId, data.end_chunk, data.end_chunk + 20);
  }
};

getDocumentContents(12345);
```

{% hint style="info" %}
Replace `YOUR_JWT_TOKEN` with your actual JWT token and `12345` with an actual document 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 there are more chunks, you can fetch them
    # This is a simplistic example - you might want to implement a proper recursion check
    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" %}
Replace `YOUR_JWT_TOKEN` with your actual JWT token and `12345` with an actual document ID.
{% endhint %}
{% endtab %}
{% endtabs %}

## Path Parameters

| Parameter    | Type    | Description                                                    |
| ------------ | ------- | -------------------------------------------------------------- |
| document\_id | integer | **Required.** The ID of the document to retrieve contents for. |

## Query Parameters

| Parameter    | Type    | Description                                           |
| ------------ | ------- | ----------------------------------------------------- |
| start\_chunk | integer | The starting chunk index. Default is 0.               |
| end\_chunk   | integer | The ending chunk index. Default is start\_chunk + 20. |

## Response Format

```json
{
  "content": "The full text content of the document chunks...",
  "end_chunk": 20
}
```

## Error Responses

| Status Code | Description           |
| ----------- | --------------------- |
| 404         | Document not found    |
| 500         | Internal server error |

## Pagination for Large Documents

For large documents, the content is split into chunks. You can retrieve the full document by making multiple requests:

1. Make an initial request with `start_chunk=0`
2. Use the returned `end_chunk` value as the `start_chunk` for the next request
3. Continue until you have retrieved all chunks

This endpoint returns the raw text content of a document, allowing you to access the full information for detailed processing or analysis.


---

# 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/developer-resources/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.
