curl --request GET \
--url https://api.example.com/api/course/all{
"success": true,
"courses": [
{
"_id": "65f8a2b3c4d5e6f7a8b9c0d1",
"courseTitle": "Complete Web Development Bootcamp",
"courseDescription": "Learn web development from scratch with HTML, CSS, JavaScript, React, Node.js and more",
"courseThumbnail": "https://example.com/thumbnails/web-dev-bootcamp.jpg",
"coursePrice": 49.99,
"isPublished": true,
"discount": 20,
"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"
},
{
"_id": "65f8a2b3c4d5e6f7a8b9c0d2",
"courseTitle": "Data Science with Python",
"courseDescription": "Master data analysis, visualization, and machine learning with Python",
"courseThumbnail": "https://example.com/thumbnails/data-science.jpg",
"coursePrice": 79.99,
"isPublished": true,
"discount": 0,
"averageRating": 4.9,
"totalRatings": 587,
"totalLectures": 203,
"totalDurationMinutes": 2650,
"educatorId": {
"_id": "65f8a1b2c3d4e5f6a7b8c9d1",
"name": "Sarah Johnson",
"imageUrl": "https://example.com/profiles/sarah-johnson.jpg"
},
"totalEnrolledStudents": 2341,
"createdAt": "2024-03-10T08:15:00.000Z",
"updatedAt": "2024-03-18T16:45:00.000Z"
}
]
}
Retrieve a list of all published courses
curl --request GET \
--url https://api.example.com/api/course/all{
"success": true,
"courses": [
{
"_id": "65f8a2b3c4d5e6f7a8b9c0d1",
"courseTitle": "Complete Web Development Bootcamp",
"courseDescription": "Learn web development from scratch with HTML, CSS, JavaScript, React, Node.js and more",
"courseThumbnail": "https://example.com/thumbnails/web-dev-bootcamp.jpg",
"coursePrice": 49.99,
"isPublished": true,
"discount": 20,
"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"
},
{
"_id": "65f8a2b3c4d5e6f7a8b9c0d2",
"courseTitle": "Data Science with Python",
"courseDescription": "Master data analysis, visualization, and machine learning with Python",
"courseThumbnail": "https://example.com/thumbnails/data-science.jpg",
"coursePrice": 79.99,
"isPublished": true,
"discount": 0,
"averageRating": 4.9,
"totalRatings": 587,
"totalLectures": 203,
"totalDurationMinutes": 2650,
"educatorId": {
"_id": "65f8a1b2c3d4e5f6a7b8c9d1",
"name": "Sarah Johnson",
"imageUrl": "https://example.com/profiles/sarah-johnson.jpg"
},
"totalEnrolledStudents": 2341,
"createdAt": "2024-03-10T08:15:00.000Z",
"updatedAt": "2024-03-18T16:45:00.000Z"
}
]
}
GET /api/course/all
Show Course Object
{
"success": true,
"courses": [
{
"_id": "65f8a2b3c4d5e6f7a8b9c0d1",
"courseTitle": "Complete Web Development Bootcamp",
"courseDescription": "Learn web development from scratch with HTML, CSS, JavaScript, React, Node.js and more",
"courseThumbnail": "https://example.com/thumbnails/web-dev-bootcamp.jpg",
"coursePrice": 49.99,
"isPublished": true,
"discount": 20,
"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"
},
{
"_id": "65f8a2b3c4d5e6f7a8b9c0d2",
"courseTitle": "Data Science with Python",
"courseDescription": "Master data analysis, visualization, and machine learning with Python",
"courseThumbnail": "https://example.com/thumbnails/data-science.jpg",
"coursePrice": 79.99,
"isPublished": true,
"discount": 0,
"averageRating": 4.9,
"totalRatings": 587,
"totalLectures": 203,
"totalDurationMinutes": 2650,
"educatorId": {
"_id": "65f8a1b2c3d4e5f6a7b8c9d1",
"name": "Sarah Johnson",
"imageUrl": "https://example.com/profiles/sarah-johnson.jpg"
},
"totalEnrolledStudents": 2341,
"createdAt": "2024-03-10T08:15:00.000Z",
"updatedAt": "2024-03-18T16:45:00.000Z"
}
]
}
{
"success": false,
"message": "An unexpected error occurred"
}
isPublished is truecourseContent (chapter and lecture details)courseRatings (individual user ratings)enrolledStudents (list of enrolled student IDs)educatorId field is populated with basic educator information (name and image)const response = await fetch('https://api.skillrise.com/api/course/all');
const data = await response.json();
if (data.success) {
console.log(`Found ${data.courses.length} courses`);
data.courses.forEach(course => {
console.log(`${course.courseTitle} - $${course.coursePrice}`);
});
} else {
console.error('Failed to fetch courses:', data.message);
}
const displayCourseCatalog = async () => {
const response = await fetch('https://api.skillrise.com/api/course/all');
const { success, courses } = await response.json();
if (success) {
return courses.map(course => ({
id: course._id,
title: course.courseTitle,
instructor: course.educatorId.name,
price: course.coursePrice * (1 - course.discount / 100), // Apply discount
rating: course.averageRating,
students: course.totalEnrolledStudents,
duration: `${Math.floor(course.totalDurationMinutes / 60)}h ${course.totalDurationMinutes % 60}m`
}));
}
};
const searchCourses = async (query) => {
const response = await fetch('https://api.skillrise.com/api/course/all');
const { success, courses } = await response.json();
if (success) {
return courses.filter(course =>
course.courseTitle.toLowerCase().includes(query.toLowerCase()) ||
course.courseDescription.toLowerCase().includes(query.toLowerCase())
);
}
};