Analytics API
Access business analytics, metrics, and reports.
Dashboard
getDashboardOverview
const overview = await zenpays.analytics.getDashboardOverview('30d')
// { totalRevenue, totalTransactions, successRate, averageTransactionValue }
Revenue
getRevenueTrends
const trends = await zenpays.analytics.getRevenueTrends('30d', 'day')
getRevenueMetrics
const metrics = await zenpays.analytics.getRevenueMetrics('30d')
// { grossRevenue, netRevenue, fees, refunds }
Payment Analytics
getPaymentMethodBreakdown
const breakdown = await zenpays.analytics.getPaymentMethodBreakdown()
// [{ method: 'card', count: 150, volume: 50000, percentage: 60 }]
getPaymentStatusDistribution
const distribution = await zenpays.analytics.getPaymentStatusDistribution()
getRecentPayments
const payments = await zenpays.analytics.getRecentPayments(10)
getFailedPaymentsAnalysis
const analysis = await zenpays.analytics.getFailedPaymentsAnalysis()
// { totalFailed, failureRate, byReason: [...] }
Customer Analytics
getTopCustomers
const customers = await zenpays.analytics.getTopCustomers(10)
Business Insights
getBusinessInsights
const insights = await zenpays.analytics.getBusinessInsights()
// { topPerformingDays, peakHours, averageOrderValue, recommendations }
Reports
generateReport
const report = await zenpays.analytics.generateReport({
type: 'transactions',
format: 'csv',
from: '2024-01-01',
to: '2024-12-31',
})
listReports
const { data } = await zenpays.analytics.listReports()
getReport
const report = await zenpays.analytics.getReport('rpt_xxx')
createReportSchedule
await zenpays.analytics.createReportSchedule({
type: 'transactions',
format: 'csv',
frequency: 'weekly',
dayOfWeek: 1, // Monday
time: '09:00',
recipients: ['finance@example.com'],
})