This document provides frontend developers with comprehensive instructions on how to integrate the Course API endpoints into their applications.
All endpoints are prefixed with /api/courses
Bearer <your-jwt-token>Endpoint: GET /api/courses/search
Description: Search for courses by query string
Authentication: Optional
Request Parameters:
query (required): Search termExample Request:
fetch('/api/courses/search?query=javascript', {
headers: {
'Authorization': 'Bearer your-token-here' // optional
}
})
.then(response => response.json())
.then(data => console.log(data));
Response Structure:
{
success: boolean;
message?: string;
data?: {
id: string; // Course ID
title: string; // Course title
description: string; // Full description
shortDescription: string; // Brief description
provider: string; // e.g. "Udemy", "Coursera"
url: string; // Course URL
categories: string[]; // Course categories
isFree: boolean; // Free/paid status
imageUrl?: string; // Course image URL
isBookmarked?: boolean; // Only present if user authenticated
}[];
}
Endpoint: GET /api/courses/featured
Description: Get featured/popular courses
Authentication: Optional
Example Request:
fetch('/api/courses/featured', {
headers: {
'Authorization': 'Bearer your-token-here' // optional
}
})
Response Structure: Same as search endpoint
Endpoint: GET /api/courses/course/:id
Description: Get detailed information about a specific course
Authentication: Optional
Example Request:
fetch('/api/courses/course/507f1f77bcf86cd799439011', {
headers: {
'Authorization': 'Bearer your-token-here' // optional
}
})
Response Structure: Same as search endpoint (single course)
Endpoint: GET /api/courses/user/courses
Description: Get all courses bookmarked by the authenticated user
Authentication: Required
Example Request:
fetch('/api/courses/user/courses', {
headers: {
'Authorization': 'Bearer your-token-here'
}
})
Response Structure: Same as search endpoint (always includes isBookmarked)
Endpoint: POST /api/courses/:courseId/bookmark
Description: Bookmark or unbookmark a course
Authentication: Required
Request Body:
{
bookmark: boolean; // true to bookmark, false to unbookmark
}
Example Request:
fetch('/api/courses/507f1f77bcf86cd799439011/bookmark', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your-token-here'
},
body: JSON.stringify({ bookmark: true })
})
Response Structure:
{
success: boolean;
message?: string;
data?: {
isBookmarked: boolean; // New bookmark status
};
}
Handle potential errors by checking:
response.success - false indicates an errorAuthentication:
Pagination:
Caching:
Error States:
Rate Limiting: