> 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/es/recursos-para-desarrolladores/api-docs/retrieve-document-contents.md).

# Recuperar contenidos de documentos

{% openapi src="/files/5V7ybptH1vsfKadO6dio" path="/documents/{document\_id}/contents/" method="get" %}
[rememberizer\_openapi.yml](https://983989491-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FeFTiuIsKOMpUEE73g7bP%2Fuploads%2Fgit-blob-77b6137eeb641262ec8e531c78123c02b825b865%2Frememberizer_openapi.yml?alt=media\&token=03079f98-60fe-4914-9e1b-443e008fd108)
{% endopenapi %}

## Ejemplos de Solicitudes

{% 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" %}
Reemplace `YOUR_JWT_TOKEN` con su token JWT real y `12345` con un ID de documento real.
{% 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);
  
  // Si hay más fragmentos, puede obtenerlos
  if (data.end_chunk < totalChunks) {
    // Obtener el siguiente conjunto de fragmentos
    await getDocumentContents(documentId, data.end_chunk, data.end_chunk + 20);
  }
};

getDocumentContents(12345);
```

{% hint style="info" %}
Reemplace `YOUR_JWT_TOKEN` con su token JWT real y `12345` con un ID de documento real.
{% 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)
    
    # Si hay más fragmentos, puede obtenerlos
    # Este es un ejemplo simplista - puede que desee implementar una verificación de recursión adecuada
    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" %}
Reemplace `YOUR_JWT_TOKEN` con su token JWT real y `12345` con un ID de documento real.
{% endhint %}
{% endtab %}
{% endtabs %}

## Parámetros de Ruta

| Parámetro    | Tipo   | Descripción                                                           |
| ------------ | ------ | --------------------------------------------------------------------- |
| document\_id | entero | **Requerido.** El ID del documento para el cual recuperar contenidos. |

## Parámetros de Consulta

| Parámetro    | Tipo   | Descripción                                                                  |
| ------------ | ------ | ---------------------------------------------------------------------------- |
| start\_chunk | entero | El índice del fragmento inicial. El valor predeterminado es 0.               |
| end\_chunk   | entero | El índice del fragmento final. El valor predeterminado es start\_chunk + 20. |

## Formato de Respuesta

```json
{
  "content": "El texto completo del contenido de los fragmentos del documento...",
  "end_chunk": 20
}
```

## Respuestas de Error

| Código de Estado | Descripción                |
| ---------------- | -------------------------- |
| 404              | Documento no encontrado    |
| 500              | Error interno del servidor |

## Paginación para Documentos Grandes

Para documentos grandes, el contenido se divide en fragmentos. Puedes recuperar el documento completo haciendo múltiples solicitudes:

1. Haz una solicitud inicial con `start_chunk=0`
2. Usa el valor `end_chunk` devuelto como `start_chunk` para la siguiente solicitud
3. Continúa hasta que hayas recuperado todos los fragmentos

Este endpoint devuelve el contenido de texto sin procesar de un documento, lo que te permite acceder a toda la información para un procesamiento o análisis detallado.


---

# 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/es/recursos-para-desarrolladores/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.
