Get Sales Analytics
Headers
Bearer token for authentication
Response
Indicates if the request was successful
Analytics data object
Daily sales data for the last 7 days
Array of day labels (e.g., [“Dom”, “Lun”, “Mar”, …])
Array of daily revenue values
Monthly sales data for the last 6 months
Array of month labels
Array of monthly revenue values
Top selling products by sales volume
Example Request
Example Response
Error Codes
401- Unauthorized500- Internal server error
Get Executive Summary
Headers
Bearer token for authentication
Response
Indicates if the request was successful
Executive summary data
Current month statistics
Total number of sales this month
Total revenue this month
Average order value this month
Last month statistics
Growth percentages
Revenue growth percentage
Sales growth percentage
Example Request
Example Response
Get Custom Period Analytics
Headers
Bearer token for authentication
Query Parameters
Start date for the analysis period (ISO 8601 format)
End date for the analysis period (ISO 8601 format)
Grouping interval: “day” or “month”
Response
Indicates if the request was successful
Custom period analytics data
Array of date labels based on groupBy parameter
Array of revenue values for each period
Example Request
Example Response
Get Today’s Statistics
Headers
Bearer token for authentication
Query Parameters
Set to today’s date to get today’s stats (ISO 8601 format)
Number of sales to retrieve
Response
Indicates if the request was successful
Array of today’s sales
Example Request
Example Response
The frontend calculates today’s statistics from the sales data, including total revenue, number of orders, products sold, and unique customers.
Get Inventory Analysis
Headers
Bearer token for authentication
Query Parameters
Maximum number of products to retrieve
Response
Indicates if the request was successful
Array of all products with stock information
Example Request
Example Response
The analytics service categorizes products as:
- Disponible: Stock > 10 or availability = “unlimited”
- Stock Bajo: Stock between 1 and 10
- Agotado: Stock = 0
Error Codes
401- Unauthorized500- Internal server error
Analytics Data Processing
The CEMAC analytics service includes fallback mechanisms:
- If
/analysis/salesendpoint is unavailable, analytics are calculated from/salesendpoint data - Daily data shows the last 7 days
- Monthly data shows the last 6 months
- Top products are ranked by sales volume
- All calculations include proper date filtering and aggregation