Skip to main content

List Courses

Retrieves a list of published courses or all courses (admin/instructor only).

Query Parameters

Returns only the 4 most recently published courses when set to true
ids
string
Comma-separated list of course IDs to filter by (e.g., “1,2,3”)
all
boolean
Admin/instructor only: Returns all courses including unpublished drafts when set to true

Response

courses
array
Array of course objects

Example Request

curl https://your-domain.com/api/courses?recommended=true

Example Response

{
  "courses": [
    {
      "id": 1,
      "title": "Introduction to Programming",
      "description": "Learn the basics of programming",
      "image": "https://example.com/image.jpg",
      "price": 49.99,
      "enrolledStudents": 125,
      "totalHours": 12.5,
      "totalDurationMinutes": 750,
      "lessons": [...],
      "settings": {
        "enrollment": {
          "enrollmentMode": "paid",
          "price": 49.99
        }
      }
    }
  ]
}

Create Course

Creates a new course. Requires admin authentication.

Request Body

title
string
required
Course title
description
string
Course description
image
string
Course thumbnail image URL
price
number
Course price
enrollment_mode
string
Enrollment mode: “free” or “paid”

Response

course
object
The created course object

Example Request

curl -X POST https://your-domain.com/api/courses \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Advanced JavaScript",
    "description": "Master JavaScript concepts",
    "price": 99.99,
    "enrollment_mode": "paid"
  }'

Get Course Details

Retrieves detailed information about a specific course including lessons, quizzes, instructors, and prerequisites.

Path Parameters

id
string
required
Course ID or slug (e.g., “123” or “course-title-123”)

Response

course
object
Detailed course object with lessons, creator, instructors, prerequisites

Example Request

curl https://your-domain.com/api/courses/introduction-to-programming-123

Delete Course

Deletes a course and all related data (lessons, quizzes, enrollments, progress). Requires admin authentication. Payment and certificate records are preserved for historical purposes.

Path Parameters

id
string
required
Course ID or slug

Response

message
string
Success confirmation message

Example Request

curl -X DELETE https://your-domain.com/api/courses/123

Save/Update Course Draft

Saves or updates a course draft including all lessons, quizzes, resources, prerequisites, and instructors.

Request Body

courseId
string
Course ID for updates, or “new” for creating a new course
isPublished
boolean
Whether the course should be published (visible to students)
courseData
object
required
Complete course data including basicInfo, lessons, settings

Response

course
object
Updated course object
courseId
number
Course ID (useful for newly created courses)

Get Quiz Attempts

Retrieves the latest quiz attempt for a specific lesson.

Path Parameters

id
string
required
Course ID

Query Parameters

lessonId
string
required
Lesson ID

Response

attempt
object
Latest quiz attempt object with question_order and answer_orders for shuffled quizzes
attemptNumber
number
Current attempt number (0 if no attempts exist)

Get Quiz Results

Retrieves all quiz results for the authenticated user in a course.

Path Parameters

id
string
required
Course ID

Response

results
array
Array of quiz result objects
resultsByLesson
object
Results grouped by lesson ID

Submit Quiz Results

Submits quiz answers and calculates results. Handles quiz retakes and shuffle logic.

Path Parameters

id
string
required
Course ID

Request Body

lessonId
number
required
Lesson ID
answers
array
required
Array of answer objects with questionId and userAnswer

Response

message
string
Success message
results
array
Saved quiz result records
stats
object

Error Codes

Status CodeDescription
200Success
400Bad Request - Invalid parameters
401Unauthorized - Authentication required
403Forbidden - Insufficient permissions
404Not Found - Course not found
409Conflict - Already enrolled
500Internal Server Error