curl --request GET \
--url https://api.example.com/api/get-documents{
"success": true,
"documents": [
{
"documents[].id": 123,
"documents[].filename": "<string>",
"documents[].original_name": "<string>",
"documents[].file_type": "<string>",
"documents[].file_size": 123,
"documents[].file_hash": "<string>",
"documents[].content_text": "<string>",
"documents[].chunk_count": 123,
"documents[].created_at": "<string>"
}
],
"error": "<string>"
}Retrieve a list of all uploaded documents with metadata
curl --request GET \
--url https://api.example.com/api/get-documents{
"success": true,
"documents": [
{
"documents[].id": 123,
"documents[].filename": "<string>",
"documents[].original_name": "<string>",
"documents[].file_type": "<string>",
"documents[].file_size": 123,
"documents[].file_hash": "<string>",
"documents[].content_text": "<string>",
"documents[].chunk_count": 123,
"documents[].created_at": "<string>"
}
],
"error": "<string>"
}created_at descending (newest first)curl -X GET https://your-domain.com/api/get-documents
{
"success": true,
"documents": [
{
"id": 42,
"filename": "65f8a3b2c1d4e_1710345654.pdf",
"original_name": "company-handbook.pdf",
"file_type": "pdf",
"file_size": 2458624,
"file_hash": "5d41402abc4b2a76b9719d911017c592",
"content_text": "Welcome to our company handbook..." ,
"chunk_count": 127,
"created_at": "2026-03-06 10:30:45"
},
{
"id": 41,
"filename": "65f89f1a2b3c4_1710342123.docx",
"original_name": "product-specs.docx",
"file_type": "docx",
"file_size": 892416,
"file_hash": "7d793037a0760186574b0282f2f435e7",
"content_text": "Product Specifications..." ,
"chunk_count": 45,
"created_at": "2026-03-06 09:15:23"
},
{
"id": 40,
"filename": "65f87d5e3a1b2_1710338567.txt",
"original_name": "faq.txt",
"file_type": "txt",
"file_size": 12345,
"file_hash": "098f6bcd4621d373cade4e832627b4f6",
"content_text": "Frequently Asked Questions..." ,
"chunk_count": 8,
"created_at": "2026-03-06 08:02:47"
}
]
}
{
"success": false,
"error": "Error al obtener documentos"
}
DocumentService::getAllDocuments() which queries with a default limit (DocumentService.php:96-103):
public function getAllDocuments($limit = 100)
{
$limit = (int) $limit;
return $this->db->fetchAll(
"SELECT * FROM documents ORDER BY created_at DESC LIMIT {$limit}",
[]
);
}
{uniqid}_{timestamp}.{extension} (DocumentService.php:44)updateChunkCount() (DocumentService.php:122-130)const response = await fetch('/api/get-documents');
const { documents } = await response.json();
const totalChunks = documents.reduce((sum, doc) => sum + doc.chunk_count, 0);
console.log(`Total indexed chunks: ${totalChunks}`);
const { documents } = await response.json();
const totalBytes = documents.reduce((sum, doc) => sum + doc.file_size, 0);
const totalMB = (totalBytes / 1024 / 1024).toFixed(2);
console.log(`Total storage: ${totalMB} MB`);
const typeCount = documents.reduce((acc, doc) => {
acc[doc.file_type] = (acc[doc.file_type] || 0) + 1;
return acc;
}, {});
console.log(typeCount); // { pdf: 15, docx: 8, txt: 3 }