Skip to main content

Get Dashboard Stats

GET /api/stats
Retrieves key dashboard metrics including product counts, user statistics, and pending items.

Authentication

Authorization
string
required
Bearer token with admin privileges
Requires: Admin role (requireAdmin middleware)

Response

success
boolean
required
Indicates if the request was successful
data
object
required
Dashboard statistics object
totalProducts
number
Total number of active products in the system
lowStockProducts
number
Number of products with stock level of 5 or less
totalUsers
number
Total number of registered users
recentSales
number
Total count of all sales
pendingInquiries
number
Number of pending technical consultations
{
  "success": true,
  "data": {
    "totalProducts": 245,
    "lowStockProducts": 12,
    "totalUsers": 1523,
    "recentSales": 487,
    "pendingInquiries": 8
  }
}

Get Sales Intelligence

GET /api/stats/intelligence
Retrieves comprehensive sales analytics including revenue metrics, trends, top products, and dead stock analysis.

Authentication

Authorization
string
required
Bearer token with admin privileges
Requires: Admin role (requireAdmin middleware)

Response

success
boolean
required
Indicates if the request was successful
data
object
required
Sales intelligence data object
kpis
object
Key performance indicators
grossRevenue
number
Total revenue for the current month (approved, sent, and delivered sales)
lowStockProducts
number
Number of products with stock level of 5 or less
pendingReview
number
Number of sales pending approval
pendingSupport
number
Number of pending technical consultations
charts
object
Chart data for visualization
salesTrend
array
Daily sales data for the last 30 days
date
string
Date in ISO format (YYYY-MM-DD)
count
number
Number of sales on that date
total
number
Total sales amount on that date
topProducts
array
Top 5 selling products in the last 30 days
name
string
Product name
quantity
number
Total quantity sold
deadStock
array
Products with no sales activity in the last 90 days
id
number
Product ID
name
string
Product name
stock
number
Current stock quantity
price
number
Product price
lastSale
string
Date of last sale (ISO format) or null if never sold
daysInactive
number
Number of days since last sale or creation
{
  "success": true,
  "data": {
    "kpis": {
      "grossRevenue": 45230.50,
      "lowStockProducts": 12,
      "pendingReview": 5,
      "pendingSupport": 8
    },
    "charts": {
      "salesTrend": [
        {
          "date": "2026-02-05",
          "count": 15,
          "total": 3250.75
        },
        {
          "date": "2026-02-06",
          "count": 18,
          "total": 4120.00
        }
      ],
      "topProducts": [
        {
          "name": "RTX 4090 Graphics Card",
          "quantity": 45
        },
        {
          "name": "Intel Core i9-14900K",
          "quantity": 38
        }
      ]
    },
    "deadStock": [
      {
        "id": 123,
        "name": "Old Keyboard Model",
        "stock": 25,
        "price": 45.99,
        "lastSale": "2025-10-15T10:30:00Z",
        "daysInactive": 142
      }
    ]
  }
}

Build docs developers (and LLMs) love