Skip to main content
GET
/
api
/
get-stats.php
System Statistics
curl --request GET \
  --url https://api.example.com/api/get-stats.php
{
  "success": true,
  "stats": {
    "conversations": {
      "total": 123,
      "active": 123,
      "archived": 123,
      "total_messages": 123
    },
    "documents": {
      "total": 123,
      "by_type": {},
      "total_size_mb": 123
    },
    "vectors": 123
  },
  "error": "<string>"
}

Overview

The statistics endpoint provides comprehensive metrics for the dashboard, including conversation counts, document statistics, and vector embedding information.

Endpoint

GET /api/get-stats.php

Response

success
boolean
required
Indicates if the request was successful
stats
object
required
Statistics object containing all metrics
conversations
object
Conversation statistics from ConversationService
total
number
Total number of conversations
active
number
Number of active conversations
archived
number
Number of archived conversations
total_messages
number
Total messages across all conversations
documents
object
Document statistics from DocumentService
total
number
Total number of uploaded documents
by_type
object
Document counts grouped by file type (e.g., PDF, DOCX, TXT)
total_size_mb
number
Total size of all documents in megabytes
vectors
number
Total number of vector embeddings stored in the system
error
string
Error message if the request failed (only present when success is false)

Status Codes

  • 200 OK: Statistics retrieved successfully
  • 500 Internal Server Error: Error retrieving statistics

Example Response

{
  "success": true,
  "stats": {
    "conversations": {
      "total": 156,
      "active": 42,
      "archived": 114,
      "total_messages": 3240
    },
    "documents": {
      "total": 87,
      "by_type": {
        "pdf": 45,
        "docx": 28,
        "txt": 14
      },
      "total_size_mb": 234.5
    },
    "vectors": 12847
  }
}

Implementation Details

The endpoint aggregates data from three core services:
  1. ConversationService: Retrieves conversation and message statistics
    • Source: api/get-stats.php:24
    • Method: getConversationStats()
  2. DocumentService: Collects document upload statistics
    • Source: api/get-stats.php:25
    • Method: getDocumentStats()
  3. VectorSearchService: Counts stored vector embeddings
    • Source: api/get-stats.php:26
    • Method: countVectors()

Configuration

The endpoint uses the following configuration values:
  • uploads.path: Document storage location
  • uploads.allowed_types: Permitted file types
  • uploads.max_size: Maximum upload size
  • rag.similarity_method: Vector similarity calculation method

Use Cases

  • Dashboard Display: Show real-time metrics on admin dashboard
  • Usage Monitoring: Track system usage and growth over time
  • Capacity Planning: Identify when storage or resources need scaling
  • Analytics: Generate reports on conversation and document trends

Error Handling

The endpoint uses output buffering to ensure clean JSON responses. All exceptions are caught and logged, returning a generic error message to prevent information leakage.

Build docs developers (and LLMs) love