Skip to main content
GET
/
api
/
user
/
enrolled-courses
Get Enrolled Courses
curl --request GET \
  --url https://api.example.com/api/user/enrolled-courses
{
  "success": true,
  "enrolledCourses": [
    {
      "_id": "60d5ec49f1b2c72b8c8e4f1a",
      "title": "Complete Web Development Bootcamp",
      "thumbnail": "https://res.cloudinary.com/skillrise/image/upload/v1234567890/courses/web-dev.jpg",
      "price": 49.99,
      "educator": {
        "_id": "educator_123abc",
        "name": "Jane Smith",
        "imageUrl": "https://..."
      },
      "totalLectures": 120,
      "totalDurationMinutes": 1800,
      "userRating": 5
    },
    {
      "_id": "60d5ec49f1b2c72b8c8e4f1b",
      "title": "Python for Data Science",
      "thumbnail": "https://res.cloudinary.com/skillrise/image/upload/v1234567890/courses/python-ds.jpg",
      "price": 39.99,
      "educator": {
        "_id": "educator_456def",
        "name": "Bob Johnson",
        "imageUrl": "https://..."
      },
      "totalLectures": 80,
      "totalDurationMinutes": 1200,
      "userRating": null
    }
  ]
}

Authentication

This endpoint requires authentication via Clerk. The userId is automatically extracted from the authentication token.

Response

success
boolean
required
Indicates whether the request was successful
enrolledCourses
array
Array of enrolled course objects
message
string
Error message if success is false

Response Examples

{
  "success": true,
  "enrolledCourses": [
    {
      "_id": "60d5ec49f1b2c72b8c8e4f1a",
      "title": "Complete Web Development Bootcamp",
      "thumbnail": "https://res.cloudinary.com/skillrise/image/upload/v1234567890/courses/web-dev.jpg",
      "price": 49.99,
      "educator": {
        "_id": "educator_123abc",
        "name": "Jane Smith",
        "imageUrl": "https://..."
      },
      "totalLectures": 120,
      "totalDurationMinutes": 1800,
      "userRating": 5
    },
    {
      "_id": "60d5ec49f1b2c72b8c8e4f1b",
      "title": "Python for Data Science",
      "thumbnail": "https://res.cloudinary.com/skillrise/image/upload/v1234567890/courses/python-ds.jpg",
      "price": 39.99,
      "educator": {
        "_id": "educator_456def",
        "name": "Bob Johnson",
        "imageUrl": "https://..."
      },
      "totalLectures": 80,
      "totalDurationMinutes": 1200,
      "userRating": null
    }
  ]
}
{
  "success": false,
  "message": "User not found"
}
{
  "success": false,
  "message": "An unexpected error occurred"
}

Error Codes

Status CodeDescription
200Success
401Unauthorized - Invalid or missing authentication token
404User not found
500Internal server error

Notes

  • The enrolledStudents field is excluded from course data in the response
  • User ratings are retrieved from the courseRatings array within each course
  • Courses are populated with full course details using MongoDB populate