Skip to main content

Overview

The lms-progress API provides a unified endpoint for retrieving progress, enrollment, and financial metrics across the platform. The Teacher and Admin Dashboards use this data to display performance statistics. The endpoint returns two datasets:
  1. Overall — Aggregated metrics for the entire platform.
  2. Per category — Detailed metrics broken down by course category.

Authentication

The API supports two methods of authentication:
  1. API Key (Recommended for server-to-server) — Pass your API key in the x-api-key header.
  2. Session Cookie (For frontend clients) — Pass the browser session cookie.
Generate an API Key in the Kunci API sidebar under the Teacher Dashboard. Once generated, include it in your HTTP requests using the x-api-key header:

Method 2: Using Session Cookies (Development)

To test the endpoint locally or via curl using browser cookies:
  1. Sign in to the LMS dashboard via your browser.
  2. Open the browser’s developer tools and copy the session cookie value (usually named authjs.session-token or similar).
  3. Run the curl command below, replacing <cookie-value> with your token:

Requesting from the browser (Frontend)

When fetching the API from frontend React components, you must include credentials. This ensures the browser attaches session cookies to the request.

Frontend integration guide

Use these TypeScript interfaces and React hooks to integrate the progress metrics into your dashboard page.

TypeScript type definitions

Define the structure of the API response to ensure strict type safety.

Code example: React fetch hook

This example shows a custom React state approach to fetch, handle errors, and manage loading states:

Technical calculation logic

The backend uses Drizzle ORM to perform queries and aggregates. Here is how the complex metrics are processed:

Completion rate calculation

To calculate the completionRate, the API computes the progress of each student in each enrolled course and averages them. It runs a SQL CTE (Common Table Expression) to perform the math:
  1. Calculate total chapters per course: Counts all chapters within modules mapped to the course.
  2. Calculate completed chapters per student: Counts unique records in student_progress where completed = true.
  3. Compute enrollment progress: Divides the completed chapters by the total chapters. If a course has 0 chapters, progress defaults to 0.
  4. Average the progress: Calculates the average progress across all enrollments.
The SQL CTE query executed by the database: