CourseLayer Logo

Courses

Course browsing, enrollment, and consumption endpoints

Courses

Browse available courses, access enrolled courses, and track learning progress.

Search Courses

Search and browse all available courses. This endpoint is publicly accessible.

Endpoint

GET /api/v1/search

Query Parameters

ParameterTypeRequiredDescription
titlestringNoFilter courses by title (2-64 characters)
per_pageintegerNoNumber of results per page
pageintegerNoPage number for pagination
sort_bystringNoSort by field: title or created_at
order_bystringNoSort order: asc or desc

Example Request

GET /api/v1/search?title=javascript&per_page=10&page=1&sort_by=title&order_by=asc

Response

{
  "data": [
    {
      "id": 1,
      "title": "JavaScript Fundamentals",
      "description": "Learn the basics of JavaScript programming",
      "thumbnail": "https://example.com/thumbnail.jpg",
      "price": 49.99,
      "instructor": {
        "id": 10,
        "name": "Jane Smith"
      },
      "categories": ["Programming", "Web Development"],
      "created_at": "2024-01-01T00:00:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 10,
    "total": 50,
    "last_page": 5
  }
}
{
  "status": "ERROR",
  "message": "Unauthorized access"
}
{
  "status": "ERROR",
  "message": "Access forbidden"
}

Get Course Sales Page

Get detailed information about a specific course for the sales page.

Endpoint

GET /api/v1/sales-page/{id}

Path Parameters

ParameterTypeRequiredDescription
idintegerYesCourse ID

Example Request

GET /api/v1/sales-page/123

Response

{
  "id": 123,
  "title": "Advanced React Patterns",
  "description": "Master advanced React patterns and best practices",
  "long_description": "In this course, you'll learn...",
  "thumbnail": "https://example.com/thumbnail.jpg",
  "preview_video": "https://example.com/preview.mp4",
  "price": 99.99,
  "pricing_type": "one_time",
  "instructor": {
    "id": 10,
    "name": "Jane Smith",
    "bio": "Professional React developer",
    "avatar": "https://example.com/avatar.jpg"
  },
  "categories": ["Programming", "React"],
  "curriculum": {
    "total_lectures": 50,
    "total_duration": "10 hours"
  },
  "created_at": "2024-01-01T00:00:00Z"
}
{
  "status": "ERROR",
  "message": "Course not found"
}

My Courses

Requires authentication. Get all courses purchased by the authenticated user.

Endpoint

GET /api/v1/my-courses

Headers

Authorization: Bearer YOUR_ACCESS_TOKEN

Query Parameters

ParameterTypeRequiredDescription
titlestringNoFilter courses by title (2-64 characters)
per_pageintegerNoNumber of results per page
pageintegerNoPage number for pagination
sort_bystringNoSort by: title or created_at
order_bystringNoOrder: asc or desc

Example Request

GET /api/v1/my-courses?per_page=10&page=1&sort_by=title&order_by=asc

Response

{
  "data": [
    {
      "id": 1,
      "title": "JavaScript Fundamentals",
      "description": "Learn the basics of JavaScript",
      "thumbnail": "https://example.com/thumbnail.jpg",
      "progress": 45,
      "completed_lectures": 12,
      "total_lectures": 27,
      "last_accessed": "2024-01-15T10:30:00Z",
      "purchased_at": "2024-01-01T00:00:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 10,
    "total": 5,
    "last_page": 1
  }
}
{
  "status": "ERROR",
  "message": "Unauthorized"
}
{
  "status": "ERROR",
  "message": "Forbidden"
}
{
  "status": "ERROR",
  "message": "Student not found"
}

Get Course Content

Requires authentication. Access course curriculum and watch videos.

Endpoint

GET /api/v1/my-courses/{id}

Headers

Authorization: Bearer YOUR_ACCESS_TOKEN

Path Parameters

ParameterTypeRequiredDescription
idintegerYesCourse ID

Example Request

GET /api/v1/my-courses/123

Response

{
  "id": 123,
  "title": "Advanced React Patterns",
  "description": "Master advanced React patterns",
  "thumbnail": "https://example.com/thumbnail.jpg",
  "progress": 45,
  "curriculum": {
    "sections": [
      {
        "id": 1,
        "title": "Introduction",
        "order": 1,
        "lectures": [
          {
            "id": 101,
            "title": "Welcome to the Course",
            "type": "video",
            "duration": 300,
            "video_url": "https://example.com/video1.mp4",
            "completed": true,
            "current_time": 300
          },
          {
            "id": 102,
            "title": "Course Overview",
            "type": "video",
            "duration": 600,
            "video_url": "https://example.com/video2.mp4",
            "completed": false,
            "current_time": 180
          }
        ]
      }
    ]
  }
}
{
  "status": "ERROR",
  "message": "Unauthorized"
}
{
  "status": "ERROR",
  "message": "Forbidden - Course not purchased"
}
{
  "status": "ERROR",
  "message": "Student/Course not found"
}

Update Lecture Progress

Save student progress data for a specific lecture.

Endpoint

POST /api/v1/lecture/{id}

Headers

Authorization: Bearer YOUR_ACCESS_TOKEN
Content-Type: application/json

Path Parameters

ParameterTypeRequiredDescription
idintegerYesLecture (section item) ID

Request Body

Prop

Type

Example Request

{
  "completed": true,
  "current_time": 600
}

Response

{
  "id": 101,
  "lecture_id": 101,
  "student_id": 456,
  "completed": true,
  "current_time": 600,
  "updated_at": "2024-01-15T10:30:00Z"
}
{
  "status": "ERROR",
  "message": "Unauthorized"
}
{
  "status": "ERROR",
  "message": "Student not found"
}

Best Practices

Track Progress Regularly

Save lecture progress frequently to ensure students don't lose their place if they navigate away.

Handle Errors Gracefully

Implement proper error handling for network issues and unauthorized access.

Optimize API Calls

Cache course data where appropriate to reduce unnecessary API requests.

Respect Rate Limits

Implement exponential backoff for failed requests.