0% found this document useful (0 votes)
21 views9 pages

Dashboard API for Analytics & Stats

The Dashboard API provides analytics for monitoring academy performance, including student enrollment, course popularity, and revenue tracking, requiring staff-level authentication. Key endpoints include Dashboard Overview, Student Details, Course Details, and Earnings Details, each offering various statistics and trends based on optional time periods. The documentation also includes usage examples, performance notes, error responses, and potential future enhancements for the API.

Uploaded by

codersfly.com
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views9 pages

Dashboard API for Analytics & Stats

The Dashboard API provides analytics for monitoring academy performance, including student enrollment, course popularity, and revenue tracking, requiring staff-level authentication. Key endpoints include Dashboard Overview, Student Details, Course Details, and Earnings Details, each offering various statistics and trends based on optional time periods. The documentation also includes usage examples, performance notes, error responses, and potential future enhancements for the API.

Uploaded by

codersfly.com
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Dashboard API Documentation

Overview
The Dashboard API provides comprehensive analytics and statistics for ad-
min users to monitor the academy’s performance, including student enrollment,
course popularity, teacher stats, and revenue tracking.

Authentication
All dashboard endpoints require staff-level authentication (IsStaff permis-
sion).
Headers:
Authorization: Bearer <your_jwt_token>

Endpoints
1. Dashboard Overview
Get all statistics cards and charts in one request.
Endpoint: GET /api/dashboard/overview/
Query Parameters: - period (optional): Time period filter - today - Last 24
hours - week - Last 7 days (recommended for weekly reports) - 2weeks - Last
14 days - month - Last 30 days (default, recommended for monthly reports) -
3months - Last 90 days (quarterly review) - 6months - Last 180 days (bi-annual)
- year - Last 365 days (annual report) - all - All time data
Example Request:
GET /api/dashboard/overview/?period=month
Response Structure:
{
"success": true,
"message": "Dashboard overview for this month retrieved successfully",
"data": {
"period": "month",
"period_label": "this month",
"statistics": {
"students": {
"total": 1246,
"new": 98,
"growth": 12,
"growth_percentage": 13.95,

1
"label": "+98 new this month"
},
"courses": {
"total": 56,
"new": 4,
"growth": 1,
"label": "+4 new this month"
},
"teachers": {
"total": 22,
"new": 1,
"growth": 0,
"label": "+1 new this month"
},
"earnings": {
"total": 785000.00,
"period_earnings": 125000.00,
"growth": 25000.00,
"growth_percentage": 12.5,
"label": "+12.5% this month",
"currency": "BDT"
}
},
"charts": {
"enrollment_overview": {
"title": "Enrollment Overview - Last 12 Months",
"type": "bar",
"labels": ["Dec 2024", "Jan 2025", "Feb 2025", "..."],
"data": [45, 52, 67, ...],
"total_enrollments": 456
},
"popular_courses": {
"title": "Top 5 Popular Courses",
"type": "pie",
"labels": ["Web Development", "Data Science", "Mobile Dev", "..."],
"data": [125, 98, 87, 76, 65],
"course_ids": ["uuid1", "uuid2", "uuid3", "..."],
"total_enrollments": 451
}
}
}
}

2
2. Student Details
Get detailed student statistics and trends.
Endpoint: GET /api/dashboard/students/details/
Query Parameters: - period (optional): Same as overview endpoint
Example Request:
GET /api/dashboard/students/details/?period=month
Response Structure:
{
"success": true,
"message": "Student details retrieved successfully",
"data": {
"period": "month",
"summary": {
"total_students": 1246,
"active_students": 1246,
"inactive_students": 15,
"new_students": 98,
"enrolled_students": 1156,
"unenrolled_students": 90
},
"registration_trend": {
"title": "Daily Registrations - Last 30 Days",
"labels": ["2025-10-06", "2025-10-07", "..."],
"data": [3, 5, 2, 7, ...]
}
}
}

3. Course Details
Get detailed course statistics and enrollment data.
Endpoint: GET /api/dashboard/courses/details/
Query Parameters: - period (optional): Same as overview endpoint
Example Request:
GET /api/dashboard/courses/details/?period=3months
Response Structure:
{
"success": true,

3
"message": "Course details retrieved successfully",
"data": {
"period": "3months",
"summary": {
"total_courses": 56,
"published_courses": 48,
"draft_courses": 8,
"new_courses": 4
},
"top_courses": [
{
"id": "uuid",
"title": "Complete Web Development Bootcamp",
"total_enrollments": 125
},
...
]
}
}

4. Earnings Details
Get detailed earnings breakdown with payment methods and trends.
Endpoint: GET /api/dashboard/earnings/details/
Query Parameters: - period (optional): Same as overview endpoint
Example Request:
GET /api/dashboard/earnings/details/?period=year
Response Structure:
{
"success": true,
"message": "Earnings details retrieved successfully",
"data": {
"period": "year",
"summary": {
"total_earnings": 7850000.00,
"period_earnings": 5200000.00,
"currency": "BDT"
},
"by_payment_method": [
{
"method": "sslcommerz",

4
"total": 4500000.00,
"count": 145
},
{
"method": "bank_transfer",
"total": 700000.00,
"count": 12
}
],
"top_earning_courses": [
{
"course_id": "uuid",
"course_title": "Complete Web Development",
"total_revenue": 850000.00,
"total_orders": 65
},
...
],
"earnings_trend": {
"title": "Monthly Earnings - Last 12 Months",
"labels": ["Dec 2024", "Jan 2025", "..."],
"data": [420000.00, 485000.00, ...]
}
}
}

Usage Examples
Frontend Integration
React/[Link] Example
// Dashboard Overview Component
const DashboardOverview = () => {
const [period, setPeriod] = useState('month');
const [data, setData] = useState(null);

useEffect(() => {
fetch(`/api/dashboard/overview/?period=${period}`, {
headers: {
'Authorization': `Bearer ${token}`
}
})
.then(res => [Link]())
.then(data => setData([Link]));

5
}, [period]);

return (
<div>
{/* Period Filter */ }
<select onChange={(e) => setPeriod([Link])}>
<option value="today">Today</option>
<option value="week">This Week</option>
<option value="month" selected>This Month</option>
<option value="year">This Year</option>
</select>

{/* Statistics Cards */ }


<div className="stats-grid">
<Card title="Total Students"
value={data?.[Link]}
label={data?.[Link]} />
<Card title="Total Courses"
value={data?.[Link]}
label={data?.[Link]} />
<Card title="Total Teachers"
value={data?.[Link]}
label={data?.[Link]} />
<Card title="Total Earnings"
value={data?.[Link]}
label={data?.[Link]} />
</div>

{/* Charts */ }
<div className="charts-grid">
<BarChart
title={data?.charts.enrollment_overview.title}
labels={data?.charts.enrollment_overview.labels}
data={data?.charts.enrollment_overview.data} />

<PieChart
title={data?.charts.popular_courses.title}
labels={data?.charts.popular_courses.labels}
data={data?.charts.popular_courses.data} />
</div>
</div>
);
};

[Link] Integration

6
// Bar Chart - Enrollment Overview
const enrollmentChart = new Chart(ctx, {
type: 'bar',
data: {
labels: [Link].enrollment_overview.labels,
datasets: [{
label: 'Enrollments',
data: [Link].enrollment_overview.data,
backgroundColor: 'rgba(54, 162, 235, 0.5)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1
}]
},
options: {
responsive: true,
scales: {
y: {
beginAtZero: true
}
}
}
});

// Pie Chart - Popular Courses


const popularCoursesChart = new Chart(ctx, {
type: 'pie',
data: {
labels: [Link].popular_courses.labels,
datasets: [{
data: [Link].popular_courses.data,
backgroundColor: [
'rgba(255, 99, 132, 0.8)',
'rgba(54, 162, 235, 0.8)',
'rgba(255, 206, 86, 0.8)',
'rgba(75, 192, 192, 0.8)',
'rgba(153, 102, 255, 0.8)'
]
}]
},
options: {
responsive: true,
plugins: {
legend: {
position: 'bottom'
}
}

7
}
});

Filter Period Recommendations

Use Case Recommended Period Description


Daily monitoring today Quick check of today’s activity
Weekly reports week Weekly performance overview
Monthly reports month Standard monthly KPI tracking (default)
Quarterly reviews 3months Quarterly business analysis
Bi-annual reviews 6months Half-year performance
Annual reports year Yearly summary and trends
Historical analysis all Complete historical data

Performance Notes
• All endpoints are optimized with database aggregations
• Enrollment chart limited to last 12 months for performance
• Popular courses limited to top 5 to keep response size manageable
• Use appropriate caching on frontend for better UX
• Consider implementing polling or WebSocket for real-time updates

Error Responses
Unauthorized (401):
{
"success": false,
"message": "Authentication credentials were not provided."
}
Forbidden (403):
{
"success": false,
"message": "You do not have permission to perform this action."
}
Invalid Period (400): Returns data with default period (month) if invalid
period provided.

8
Future Enhancements
Potential additions based on requirements: - Geographic distribution of stu-
dents - Course completion rates - Teacher performance metrics - Student engage-
ment analytics - Revenue forecasting - Custom date range selection - Export to
CSV/PDF - Real-time WebSocket updates

Common questions

Powered by AI

The use of aggregation and performance optimization techniques in the Dashboard API enables efficient data retrieval and processing. Aggregations minimize the number of database queries needed by combining data operations, while performance optimizations like caching on the frontend reduce load times, enhancing user experience. Limiting chart data to the last 12 months and focusing on top courses helps maintain manageable response sizes and quick data access .

The earnings details structure in the Dashboard API includes several components: 'period', 'summary', 'by_payment_method', 'top_earning_courses', and 'earnings_trend'. The 'summary' provides total and period-specific earnings along with the currency. 'by_payment_method' details earnings by different payment methods such as 'sslcommerz' and 'bank_transfer'. 'top_earning_courses' lists courses with their respective revenues and orders. Finally, 'earnings_trend' tracks monthly earnings over the last 12 months .

The Dashboard API documentation recommends different time periods for queries to suit specific analysis needs. 'Today' is suggested for daily monitoring, 'week' for weekly performance, 'month' for standard KPI tracking, '3months' for quarterly analysis, '6months' for bi-annual reviews, 'year' for annual summaries, and 'all' for complete historical data. These recommendations optimize performance monitoring and are tailored to align with common business reporting cycles .

Integrating front-end technologies like React/Next.js with the Dashboard API enhances user experience by providing intuitive and interactive visualizations of data. This allows users to filter data by period and immediately update visual components, such as statistics cards and charts, through asynchronous data fetching. Additionally, chart integrations using libraries like Chart.js further enhance the visualization of complex datasets, thus improving usability and engagement with the real-time tracking of academy performance .

The Dashboard API requires staff-level authentication to access its endpoints, utilizing a Bearer token for authorization. Specifically, the endpoints necessitate the 'IsStaff' permission, ensuring that only users with adequate administrative rights can retrieve sensitive data from the API .

A detailed 'registration_trend' is significant as it provides daily registration data over a specified period, enabling stakeholders to track growth, identify fluctuations, and evaluate the effectiveness of recruitment strategies. This granular view aids in proactive decision-making, allowing institutions to swiftly adapt their marketing or program offerings in response to observed patterns or trends .

The response structure for course details in the Dashboard API includes a 'summary' of course counts and statuses (total, published, draft, and new), along with a list of 'top_courses' featuring titles and enrollment numbers. This detailed breakdown supports in-depth analysis by allowing educators to monitor course lifecycle stages, identify successful courses, and make data-driven decisions on curriculum development and promotional strategies .

The suggested future enhancements for the Dashboard API include geographic distribution of students, course completion rates, teacher performance metrics, student engagement analytics, revenue forecasting, custom date range selection, export options to CSV/PDF, and real-time WebSocket updates. These features would provide additional value by offering deeper insights, enabling more flexible data analysis, supporting informed decision-making, and improving real-time interaction with performance data .

The 'popular_courses' chart employs a pie chart format to visually represent course popularity, utilizing 'labels' for course names and 'data' to indicate enrollment numbers. By focusing on the top 5 popular courses, it provides a clear and concise summary of relative popularity, helping stakeholders quickly grasp which courses attract the most students. This concise representation aids in curriculum planning and targeted marketing efforts .

When an invalid period input is provided in a data request, the API enforces a default behavior by returning data for the default period set to 'month'. This approach ensures continuity in data service by providing a fallback mechanism, preventing data retrieval failures, and maintaining consistent performance reporting .

You might also like