Skip to main content

Analytics API

Base path: /analytics  •  Service: analytics-service (port 8088)

Every /analytics/** route requires hasRole('ADMIN'). Only actuator health/info are public. Date query params are optional LocalDate values in ISO format (yyyy-MM-dd).

:::warning Known gap The service consumes payment-completed + PaymentCompletedEvent, but payment-service publishes payment-success + PaymentSuccessEvent. Until these are aligned, paid-order revenue may not populate. See Kafka. :::


GET /analytics/dashboard

Headline metrics for the admin dashboard.

Response 200 OKDashboardResponse

FieldType
totalOrdersnumber (long)
paidOrdersnumber (long)
failedPaymentsnumber (long)
totalRevenuenumber (BigDecimal)
averageOrderValuenumber (BigDecimal)
booksSoldnumber (long)
paymentSuccessRatenumber (double)
{
"totalOrders": 1280,
"paidOrders": 1150,
"failedPayments": 130,
"totalRevenue": 84590.75,
"averageOrderValue": 73.56,
"booksSold": 3120,
"paymentSuccessRate": 89.84
}

GET /analytics/revenue

Total revenue plus daily and monthly breakdowns.

ParamInTypeRequired
fromquerydateno
toquerydateno

Response 200 OKRevenueResponse

FieldType
totalRevenuenumber (BigDecimal)
dailyarray<DailyRevenueItem>
monthlyarray<MonthlyRevenueItem>

DailyRevenueItem: date (date), revenue (BigDecimal), paidOrders (long). MonthlyRevenueItem: month (string), revenue (BigDecimal), paidOrders (long), ordersCreated (long).

{
"totalRevenue": 84590.75,
"daily": [ { "date": "2026-08-04", "revenue": 1299.50, "paidOrders": 18 } ],
"monthly": [ { "month": "2026-08", "revenue": 84590.75, "paidOrders": 1150, "ordersCreated": 1280 } ]
}

GET /analytics/revenue/daily

ParamInTypeRequired
fromquerydateno
toquerydateno

Response 200 OKList<DailyRevenueItem>.


GET /analytics/revenue/monthly

ParamInTypeRequired
fromquerydateno
toquerydateno

Response 200 OKList<MonthlyRevenueItem>.


GET /analytics/orders

ParamInTypeRequired
fromquerydateno
toquerydateno

Response 200 OKOrdersAnalyticsResponse

FieldType
totalOrdersnumber (long)
paidOrdersnumber (long)
dailyarray<DailyOrderItem>
monthlyarray<MonthlyRevenueItem>

DailyOrderItem: date (date), ordersCreated (long), paidOrders (long).


GET /analytics/books

Response 200 OKBooksAnalyticsResponse

FieldType
booksSoldnumber (long)
topBooksarray<TopBookItem>

TopBookItem: bookId (UUID), bookTitle (string), quantitySold (long), revenue (BigDecimal).

{
"booksSold": 3120,
"topBooks": [
{ "bookId": "abcabc01-2345-4678-89ab-cdef01234567", "bookTitle": "The Pragmatic Programmer", "quantitySold": 210, "revenue": 8397.90 }
]
}

GET /analytics/payments

Response 200 OKPaymentsAnalyticsResponse

FieldType
paidOrdersnumber (long)
failedPaymentsnumber (long)
paymentSuccessRatenumber (double)
{ "paidOrders": 1150, "failedPayments": 130, "paymentSuccessRate": 89.84 }

Ingestion pipeline