All admin endpoints require authentication with a user account that has
role: "admin".Admin Statistics
Get comprehensive platform statistics including revenue, orders, users, and trends.Endpoint
Response
Statistics Breakdown
- Totals
- Trends
- Last 30 Days
- Status Counts
All-time totals across the platform:
- totalRevenue: Total revenue from completed orders (in TRX)
- totalOrders: Total number of orders created
- activeUsers: Number of active user accounts
- totalUsers: Total registered users
- networkFees: Total TRON network fees paid
Implementation Example
View All Sales
Retrieve a paginated list of all sales (orders) with filtering options.Endpoint
Query Parameters
- status (optional): Filter by order status (
pending,completed,refunded,failed,cancelled) - limit (optional): Number of results per page (default: 10)
- page (optional): Page number (default: 1)
Response
Implementation Example
View Customers
Get a list of all customers with their spending statistics and trends.Endpoint
Query Parameters
- search (optional): Search by username or email (case-insensitive)
- limit (optional): Number of results per page (default: 10)
- page (optional): Page number (default: 1)
Response
Customer Statistics
Fromsrc/api/admin/getCustomers.js:29, each customer includes:
- totalSpent: Net spending (completed orders minus refunded orders)
- wallet.address: Customer’s TRON wallet address
- isActive: Account status (active/inactive)
- lastLogin: Last login timestamp
stats object provides:
- total: Total number of customers
- totalVolume: Total spending across all customers
- totalChange: New customer growth vs previous 30 days
- volumeChange: Spending volume change vs previous 30 days
Implementation Example
Customer Spending Calculation
Fromsrc/api/admin/getCustomers.js:41, the total spending is calculated using MongoDB aggregation:
Trend Calculation
Fromsrc/api/admin/getStats.js:4, trends are calculated comparing 30-day periods:
Chart Data
The stats endpoint includeschartData for revenue visualization over 180 days from src/api/admin/getStats.js:125:
Building an Admin Dashboard
Complete Dashboard Example
Next Steps
Real-time Notifications
Monitor transactions in real-time with Socket.io
Payment Processing
Understand how payments are processed and confirmed