curl --request GET \
--url https://api.example.com/api/course/:id{
"success": true,
"courseData": {
"_id": "65f8a2b3c4d5e6f7a8b9c0d1",
"courseTitle": "Complete Web Development Bootcamp",
"courseDescription": "Learn web development from scratch with HTML, CSS, JavaScript, React, Node.js and more. This comprehensive course covers everything you need to become a full-stack web developer.",
"courseThumbnail": "https://example.com/thumbnails/web-dev-bootcamp.jpg",
"coursePrice": 49.99,
"isPublished": true,
"discount": 20,
"courseContent": [
{
"chapterId": "ch_001",
"chapterOrder": 1,
"chapterTitle": "Introduction to Web Development",
"chapterContent": [
{
"lectureId": "lec_001",
"lectureTitle": "Welcome to the Course",
"lectureDuration": 5,
"lectureUrl": "https://example.com/videos/welcome.mp4",
"isPreviewFree": true,
"lectureOrder": 1
},
{
"lectureId": "lec_002",
"lectureTitle": "Setting Up Your Development Environment",
"lectureDuration": 12,
"lectureUrl": "",
"isPreviewFree": false,
"lectureOrder": 2
}
]
},
{
"chapterId": "ch_002",
"chapterOrder": 2,
"chapterTitle": "HTML Fundamentals",
"chapterContent": [
{
"lectureId": "lec_003",
"lectureTitle": "HTML Basics and Structure",
"lectureDuration": 18,
"lectureUrl": "https://example.com/videos/html-basics.mp4",
"isPreviewFree": true,
"lectureOrder": 1
},
{
"lectureId": "lec_004",
"lectureTitle": "Working with Forms and Inputs",
"lectureDuration": 22,
"lectureUrl": "",
"isPreviewFree": false,
"lectureOrder": 2
}
]
}
],
"averageRating": 4.7,
"totalRatings": 342,
"totalLectures": 156,
"totalDurationMinutes": 1840,
"educatorId": {
"_id": "65f8a1b2c3d4e5f6a7b8c9d0",
"name": "John Smith",
"imageUrl": "https://example.com/profiles/john-smith.jpg"
},
"totalEnrolledStudents": 1523,
"createdAt": "2024-03-15T10:30:00.000Z",
"updatedAt": "2024-03-20T14:22:00.000Z"
}
}
Retrieve detailed information about a specific course by ID
curl --request GET \
--url https://api.example.com/api/course/:id{
"success": true,
"courseData": {
"_id": "65f8a2b3c4d5e6f7a8b9c0d1",
"courseTitle": "Complete Web Development Bootcamp",
"courseDescription": "Learn web development from scratch with HTML, CSS, JavaScript, React, Node.js and more. This comprehensive course covers everything you need to become a full-stack web developer.",
"courseThumbnail": "https://example.com/thumbnails/web-dev-bootcamp.jpg",
"coursePrice": 49.99,
"isPublished": true,
"discount": 20,
"courseContent": [
{
"chapterId": "ch_001",
"chapterOrder": 1,
"chapterTitle": "Introduction to Web Development",
"chapterContent": [
{
"lectureId": "lec_001",
"lectureTitle": "Welcome to the Course",
"lectureDuration": 5,
"lectureUrl": "https://example.com/videos/welcome.mp4",
"isPreviewFree": true,
"lectureOrder": 1
},
{
"lectureId": "lec_002",
"lectureTitle": "Setting Up Your Development Environment",
"lectureDuration": 12,
"lectureUrl": "",
"isPreviewFree": false,
"lectureOrder": 2
}
]
},
{
"chapterId": "ch_002",
"chapterOrder": 2,
"chapterTitle": "HTML Fundamentals",
"chapterContent": [
{
"lectureId": "lec_003",
"lectureTitle": "HTML Basics and Structure",
"lectureDuration": 18,
"lectureUrl": "https://example.com/videos/html-basics.mp4",
"isPreviewFree": true,
"lectureOrder": 1
},
{
"lectureId": "lec_004",
"lectureTitle": "Working with Forms and Inputs",
"lectureDuration": 22,
"lectureUrl": "",
"isPreviewFree": false,
"lectureOrder": 2
}
]
}
],
"averageRating": 4.7,
"totalRatings": 342,
"totalLectures": 156,
"totalDurationMinutes": 1840,
"educatorId": {
"_id": "65f8a1b2c3d4e5f6a7b8c9d0",
"name": "John Smith",
"imageUrl": "https://example.com/profiles/john-smith.jpg"
},
"totalEnrolledStudents": 1523,
"createdAt": "2024-03-15T10:30:00.000Z",
"updatedAt": "2024-03-20T14:22:00.000Z"
}
}
GET /api/course/:id
Show Course Data Object
Show Chapter Object
Show Lecture Object
{
"success": true,
"courseData": {
"_id": "65f8a2b3c4d5e6f7a8b9c0d1",
"courseTitle": "Complete Web Development Bootcamp",
"courseDescription": "Learn web development from scratch with HTML, CSS, JavaScript, React, Node.js and more. This comprehensive course covers everything you need to become a full-stack web developer.",
"courseThumbnail": "https://example.com/thumbnails/web-dev-bootcamp.jpg",
"coursePrice": 49.99,
"isPublished": true,
"discount": 20,
"courseContent": [
{
"chapterId": "ch_001",
"chapterOrder": 1,
"chapterTitle": "Introduction to Web Development",
"chapterContent": [
{
"lectureId": "lec_001",
"lectureTitle": "Welcome to the Course",
"lectureDuration": 5,
"lectureUrl": "https://example.com/videos/welcome.mp4",
"isPreviewFree": true,
"lectureOrder": 1
},
{
"lectureId": "lec_002",
"lectureTitle": "Setting Up Your Development Environment",
"lectureDuration": 12,
"lectureUrl": "",
"isPreviewFree": false,
"lectureOrder": 2
}
]
},
{
"chapterId": "ch_002",
"chapterOrder": 2,
"chapterTitle": "HTML Fundamentals",
"chapterContent": [
{
"lectureId": "lec_003",
"lectureTitle": "HTML Basics and Structure",
"lectureDuration": 18,
"lectureUrl": "https://example.com/videos/html-basics.mp4",
"isPreviewFree": true,
"lectureOrder": 1
},
{
"lectureId": "lec_004",
"lectureTitle": "Working with Forms and Inputs",
"lectureDuration": 22,
"lectureUrl": "",
"isPreviewFree": false,
"lectureOrder": 2
}
]
}
],
"averageRating": 4.7,
"totalRatings": 342,
"totalLectures": 156,
"totalDurationMinutes": 1840,
"educatorId": {
"_id": "65f8a1b2c3d4e5f6a7b8c9d0",
"name": "John Smith",
"imageUrl": "https://example.com/profiles/john-smith.jpg"
},
"totalEnrolledStudents": 1523,
"createdAt": "2024-03-15T10:30:00.000Z",
"updatedAt": "2024-03-20T14:22:00.000Z"
}
}
{
"success": false,
"message": "Course not found"
}
success field and message in the response.courseRatings (individual user ratings array)enrolledStudents (list of enrolled student IDs)educatorId field is populated with basic educator information (name and image)isPreviewFree is false will have their lectureUrl field set to an empty string to prevent unauthorized accessconst courseId = '65f8a2b3c4d5e6f7a8b9c0d1';
const response = await fetch(`https://api.skillrise.com/api/course/${courseId}`);
const data = await response.json();
if (data.success) {
const course = data.courseData;
console.log(`Course: ${course.courseTitle}`);
console.log(`Instructor: ${course.educatorId.name}`);
console.log(`Chapters: ${course.courseContent.length}`);
// Calculate total lectures
const totalLectures = course.courseContent.reduce(
(sum, chapter) => sum + chapter.chapterContent.length,
0
);
console.log(`Total lectures: ${totalLectures}`);
// Get free preview lectures
const freeLectures = course.courseContent.flatMap(chapter =>
chapter.chapterContent.filter(lecture => lecture.isPreviewFree)
);
console.log(`Free preview lectures: ${freeLectures.length}`);
} else {
console.error('Error:', data.message);
}
const CourseDetailsPage = async ({ courseId }) => {
const response = await fetch(`https://api.skillrise.com/api/course/${courseId}`);
const { success, courseData } = await response.json();
if (!success) {
return { error: 'Course not found' };
}
return {
title: courseData.courseTitle,
description: courseData.courseDescription,
thumbnail: courseData.courseThumbnail,
instructor: {
name: courseData.educatorId.name,
image: courseData.educatorId.imageUrl
},
pricing: {
original: courseData.coursePrice,
discount: courseData.discount,
final: courseData.coursePrice * (1 - courseData.discount / 100)
},
stats: {
rating: courseData.averageRating,
totalRatings: courseData.totalRatings,
students: courseData.totalEnrolledStudents,
lectures: courseData.totalLectures,
duration: courseData.totalDurationMinutes
},
curriculum: courseData.courseContent
};
};
const getFreePreviews = async (courseId) => {
const response = await fetch(`https://api.skillrise.com/api/course/${courseId}`);
const { success, courseData } = await response.json();
if (!success) return [];
const freeLectures = [];
courseData.courseContent.forEach(chapter => {
chapter.chapterContent.forEach(lecture => {
if (lecture.isPreviewFree && lecture.lectureUrl) {
freeLectures.push({
chapterTitle: chapter.chapterTitle,
lectureTitle: lecture.lectureTitle,
duration: lecture.lectureDuration,
url: lecture.lectureUrl
});
}
});
});
return freeLectures;
};
const buildTableOfContents = async (courseId) => {
const response = await fetch(`https://api.skillrise.com/api/course/${courseId}`);
const { success, courseData } = await response.json();
if (!success) return null;
return courseData.courseContent.map(chapter => ({
id: chapter.chapterId,
title: chapter.chapterTitle,
order: chapter.chapterOrder,
lectures: chapter.chapterContent.map(lecture => ({
id: lecture.lectureId,
title: lecture.lectureTitle,
duration: lecture.lectureDuration,
isFree: lecture.isPreviewFree,
isLocked: !lecture.lectureUrl,
order: lecture.lectureOrder
})).sort((a, b) => a.order - b.order)
})).sort((a, b) => a.order - b.order);
};