Skip to main content
GET
/
api
/
course
/
all
List 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"
    }
  ]
}

Endpoint

GET /api/course/all

Authentication

No authentication required. This is a public endpoint.

Query Parameters

This endpoint does not accept any query parameters.

Response

success
boolean
required
Indicates whether the request was successful
courses
array
required
Array of published course objects

Success Response

{
  "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"
    }
  ]
}

Error Response

{
  "success": false,
  "message": "An unexpected error occurred"
}

Error Codes

500
Internal Server Error
An unexpected error occurred while fetching courses. This typically indicates a database connection issue or server error.

Implementation Notes

  • This endpoint only returns courses where isPublished is true
  • The following fields are excluded from the response for performance:
    • courseContent (chapter and lecture details)
    • courseRatings (individual user ratings)
    • enrolledStudents (list of enrolled student IDs)
  • The educatorId field is populated with basic educator information (name and image)
  • Courses are returned in the order they are stored in the database

Code Examples

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);
}

Use Cases

Display Course Catalog

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`
    }));
  }
};

Filter and Search Courses

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())
    );
  }
};