List Courses
curl --request GET \
--url https://api.example.com/api/course/allimport requests
url = "https://api.example.com/api/course/all"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/course/all', 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/course/all",
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/course/all"
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/course/all")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/course/all")
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,
"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"
}
]
}
Course API
List Courses
Retrieve a list of all published courses
GET
/
api
/
course
/
all
List Courses
curl --request GET \
--url https://api.example.com/api/course/allimport requests
url = "https://api.example.com/api/course/all"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/course/all', 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/course/all",
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/course/all"
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/course/all")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/course/all")
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,
"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
boolean
required
Indicates whether the request was successful
array
required
Array of published course objects
Show Course Object
Show Course Object
string
required
Unique identifier for the course
string
required
Title of the course
string
required
Detailed description of the course
string
URL to the course thumbnail image
number
required
Price of the course in the platform’s currency
boolean
required
Publication status (always true for this endpoint)
number
required
Discount percentage applied to the course (0-100)
number
Average rating of the course (0-5)
number
Total number of ratings received
number
Total number of lectures in the course
number
Total duration of the course in minutes
object
required
number
Total number of students enrolled in the course
string
ISO 8601 timestamp of when the course was created
string
ISO 8601 timestamp of when the course was last updated
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
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
isPublishedistrue - 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
educatorIdfield 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);
}
const axios = require('axios');
try {
const { data } = await axios.get('https://api.skillrise.com/api/course/all');
if (data.success) {
const publishedCourses = data.courses;
console.log(`Total published courses: ${publishedCourses.length}`);
// Filter courses by educator
const educatorCourses = publishedCourses.filter(
course => course.educatorId.name === 'John Smith'
);
}
} catch (error) {
console.error('Error fetching courses:', error.response?.data || error.message);
}
import requests
response = requests.get('https://api.skillrise.com/api/course/all')
data = response.json()
if data['success']:
courses = data['courses']
print(f"Found {len(courses)} courses")
# Calculate average price
avg_price = sum(c['coursePrice'] for c in courses) / len(courses)
print(f"Average course price: ${avg_price:.2f}")
# Find top-rated courses
top_rated = [c for c in courses if c['averageRating'] >= 4.5]
print(f"Top-rated courses: {len(top_rated)}")
else:
print(f"Error: {data['message']}")
curl -X GET 'https://api.skillrise.com/api/course/all' \
-H 'Accept: application/json'
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())
);
}
};
⌘I