Get Enrolled Courses
curl --request GET \
--url https://api.example.com/api/user/enrolled-coursesimport requests
url = "https://api.example.com/api/user/enrolled-courses"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/user/enrolled-courses', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/user/enrolled-courses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/user/enrolled-courses"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/user/enrolled-courses")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/user/enrolled-courses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"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
}
]
}
User API
Get Enrolled Courses
Retrieve list of courses the authenticated user is enrolled in with course details and user ratings
GET
/
api
/
user
/
enrolled-courses
Get Enrolled Courses
curl --request GET \
--url https://api.example.com/api/user/enrolled-coursesimport requests
url = "https://api.example.com/api/user/enrolled-courses"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/user/enrolled-courses', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/user/enrolled-courses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/user/enrolled-courses"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/user/enrolled-courses")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/user/enrolled-courses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"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. TheuserId is automatically extracted from the authentication token.
Response
boolean
required
Indicates whether the request was successful
array
Array of enrolled course objects
Show course properties
Show course properties
string
Course unique identifier
string
Course title
string
URL to course thumbnail image
number
Course price
object
Course educator information (populated from educatorId)
number
Total number of lectures in the course
number
Total duration of the course in minutes
number | null
User’s rating for this course (1-5) or null if not rated
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 Code | Description |
|---|---|
| 200 | Success |
| 401 | Unauthorized - Invalid or missing authentication token |
| 404 | User not found |
| 500 | Internal server error |
Notes
- The
enrolledStudentsfield is excluded from course data in the response - User ratings are retrieved from the
courseRatingsarray within each course - Courses are populated with full course details using MongoDB populate
⌘I