Get Course
curl --request GET \
--url https://api.example.com/api/course/:idimport requests
url = "https://api.example.com/api/course/:id"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/course/:id', 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/:id",
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/:id"
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/:id")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/course/:id")
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,
"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"
}
}
Course API
Get Course
Retrieve detailed information about a specific course by ID
GET
/
api
/
course
/
:id
Get Course
curl --request GET \
--url https://api.example.com/api/course/:idimport requests
url = "https://api.example.com/api/course/:id"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/course/:id', 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/:id",
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/:id"
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/:id")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/course/:id")
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,
"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"
}
}
Endpoint
GET /api/course/:id
Authentication
No authentication required. This is a public endpoint.Path Parameters
string
required
The unique MongoDB ObjectId of the course to retrieve
Response
boolean
required
Indicates whether the request was successful
string
Error message when the course is not found (only present when success is false)
object
Detailed course information including content structure
Show Course Data Object
Show Course Data 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 of the course
number
required
Discount percentage applied to the course (0-100)
array
required
Array of chapters containing course content
Show Chapter Object
Show Chapter Object
string
required
Unique identifier for the chapter
number
required
Order of the chapter in the course
string
required
Title of the chapter
array
required
Array of lectures within the chapter
Show Lecture Object
Show Lecture Object
string
required
Unique identifier for the lecture
string
required
Title of the lecture
number
required
Duration of the lecture in minutes
string
required
URL to the lecture video (empty string if not free preview)
boolean
required
Whether the lecture is available as a free preview
number
required
Order of the lecture within the chapter
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,
"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"
}
}
Error Responses
{
"success": false,
"message": "Course not found"
}
{
"success": false,
"message": "An unexpected error occurred"
}
Error Codes
Success (with error message)
The request was processed successfully, but the course was not found. Check the
success field and message in the response.Internal Server Error
An unexpected error occurred while fetching the course. This typically indicates a database connection issue, invalid ObjectId format, or server error.
Implementation Notes
- Both published and unpublished courses can be retrieved with this endpoint
- The following fields are excluded from the response:
courseRatings(individual user ratings array)enrolledStudents(list of enrolled student IDs)
- The
educatorIdfield is populated with basic educator information (name and image) - Free Preview Protection: Lectures where
isPreviewFreeisfalsewill have theirlectureUrlfield set to an empty string to prevent unauthorized access - If an invalid MongoDB ObjectId is provided, a 500 error will be returned
- The course content structure is fully included, allowing clients to build course curriculum displays
Code Examples
const 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 axios = require('axios');
const getCourseDetails = async (courseId) => {
try {
const { data } = await axios.get(
`https://api.skillrise.com/api/course/${courseId}`
);
if (!data.success) {
throw new Error(data.message);
}
const course = data.courseData;
// Calculate final price after discount
const finalPrice = course.coursePrice * (1 - course.discount / 100);
return {
id: course._id,
title: course.courseTitle,
description: course.courseDescription,
instructor: course.educatorId.name,
price: finalPrice.toFixed(2),
originalPrice: course.coursePrice,
rating: course.averageRating,
totalRatings: course.totalRatings,
enrolled: course.totalEnrolledStudents,
chapters: course.courseContent.length,
totalLectures: course.totalLectures,
duration: `${Math.floor(course.totalDurationMinutes / 60)}h ${course.totalDurationMinutes % 60}m`
};
} catch (error) {
console.error('Failed to fetch course:', error.message);
throw error;
}
};
// Usage
getCourseDetails('65f8a2b3c4d5e6f7a8b9c0d1')
.then(course => console.log(course));
import requests
def get_course_curriculum(course_id):
response = requests.get(f'https://api.skillrise.com/api/course/{course_id}')
data = response.json()
if not data['success']:
raise Exception(data.get('message', 'Unknown error'))
course = data['courseData']
curriculum = []
for chapter in course['courseContent']:
chapter_info = {
'title': chapter['chapterTitle'],
'order': chapter['chapterOrder'],
'lectures': []
}
for lecture in chapter['chapterContent']:
chapter_info['lectures'].append({
'title': lecture['lectureTitle'],
'duration': lecture['lectureDuration'],
'isFree': lecture['isPreviewFree'],
'hasAccess': bool(lecture['lectureUrl'])
})
curriculum.append(chapter_info)
return curriculum
# Usage
try:
curriculum = get_course_curriculum('65f8a2b3c4d5e6f7a8b9c0d1')
for chapter in curriculum:
print(f"Chapter {chapter['order']}: {chapter['title']}")
print(f" Lectures: {len(chapter['lectures'])}")
except Exception as e:
print(f"Error: {e}")
curl -X GET 'https://api.skillrise.com/api/course/65f8a2b3c4d5e6f7a8b9c0d1' \
-H 'Accept: application/json'
Use Cases
Display Course Details Page
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
};
};
Show Free Preview Content
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;
};
Build Course Table of Contents
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);
};
⌘I