Recupera i contenuti del documento¶
GET /documents/{document_id}/contents/¶
Retrieve contents of a document by its ID.
Returns the content of the document with the specified ID, along with the index of the latest retrieved chunk. Each call fetches up to 20 chunks. To get more, use the end_chunk value from the response as the start_chunk for the next call.
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
document_id |
path | integer | yes | The ID of the document to retrieve contents for. |
start_chunk |
query | integer | Indicate the starting chunk that you want to retrieve. If not specified, the default value is 0. | |
end_chunk |
query | integer | Indicate the ending chunk that you want to retrieve. If not specified, the default value is start_chunk + 20. |
Responses
200— Content of the document and index of the latest retrieved chunk.404— Document not found.500— Internal server error.
Esempi di Richieste¶
curl -X GET
"https://api.rememberizer.ai/api/v1/documents/12345/contents/?start_chunk=0&end_chunk=20"
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Info
Sostituisci YOUR_JWT_TOKEN con il tuo token JWT effettivo e 12345 con un ID documento reale.
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);
// Se ci sono più chunk, puoi recuperarli
if (data.end_chunk < totalChunks) {
// Recupera il prossimo insieme di chunk
await getDocumentContents(documentId, data.end_chunk, data.end_chunk + 20);
}
};
getDocumentContents(12345);
Info
Sostituisci YOUR_JWT_TOKEN con il tuo token JWT effettivo e 12345 con un ID documento reale.
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)
# Se ci sono più chunk, puoi recuperarli
# Questo è un esempio semplice - potresti voler implementare un controllo di ricorsione adeguato
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)
Info
Sostituisci YOUR_JWT_TOKEN con il tuo token JWT effettivo e 12345 con un ID documento reale.
Parametri del percorso¶
| Parametro | Tipo | Descrizione |
|---|---|---|
| document_id | intero | Obbligatorio. L'ID del documento di cui recuperare i contenuti. |
Parametri di Query¶
| Parametro | Tipo | Descrizione |
|---|---|---|
| start_chunk | intero | L'indice del chunk di partenza. Il valore predefinito è 0. |
| end_chunk | intero | L'indice del chunk finale. Il valore predefinito è start_chunk + 20. |
Formato di Risposta¶
Risposte di Errore¶
| Codice di Stato | Descrizione |
|---|---|
| 404 | Documento non trovato |
| 500 | Errore interno del server |
Paginazione per Documenti di Grandi Dimensioni¶
Per documenti di grandi dimensioni, il contenuto è suddiviso in parti. Puoi recuperare il documento completo effettuando più richieste:
- Effettua una richiesta iniziale con
start_chunk=0 - Usa il valore
end_chunkrestituito comestart_chunkper la richiesta successiva - Continua fino a quando non hai recuperato tutte le parti
Questo endpoint restituisce il contenuto testuale grezzo di un documento, consentendoti di accedere a tutte le informazioni per un'elaborazione o analisi dettagliata.