1HOUSE API Documentation

Education

Access courses, lessons, and educational content

Manage courses, lessons, and educational content with video upload capabilities.

Video Processing

The Education API includes advanced video processing with automatic transcoding to multiple resolutions, HLS streaming, and thumbnail generation.

Overview

The Education API provides:

  • Course management (CRUD)
  • Lesson management (CRUD)
  • Video upload workflow (S3 pre-signed URLs)
  • Learning progress tracking
  • Module organization

Base Paths:

  • Courses: /v1/courses
  • Lessons: /v1/lessons

Courses

Get All Courses

GET /v1/courses
ParameterTypeDescription
pagenumberPage number (default: 1)
limitnumberResults per page (default: 10)
categorystringFilter by category
levelstringFilter by level (beginner, intermediate, advanced)

Example:

# Development
curl "https://api-gateway.dev.1houseglobalservices.com/v1/courses?page=1&limit=10" \
  -H "X-API-Key: your-development-api-key" \
  -H "Authorization: Bearer your-jwt-token"

# Production
curl "https://api-gateway.prod.1houseglobalservices.com/v1/courses?page=1&limit=10" \
  -H "X-API-Key: your-production-api-key" \
  -H "Authorization: Bearer your-jwt-token"
{
  "success": true,
  "status": 200,
  "message": "Courses retrieved successfully",
  "data": [
    {
      "id": "course_123",
      "title": "Forex Trading Masterclass",
      "description": "Learn professional forex trading from scratch",
      "instructor": {
        "id": "user_456",
        "firstName": "John",
        "lastName": "Doe"
      },
      "level": "beginner",
      "category": "trading",
      "duration": 1200,
      "moduleCount": 8,
      "lessonCount": 45,
      "enrolledCount": 1523,
      "rating": 4.8,
      "price": 299.00,
      "thumbnail": "https://cdn.yourdomain.com/courses/course_123.jpg",
      "createdAt": "2025-01-15T00:00:00.000Z"
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 25,
    "pages": 3
  },
  "meta": {
    "timestamp": "2025-10-21T12:00:00.000Z",
    "version": "v1"
  }
}

Get Course by ID

GET /v1/courses/:courseId
{
  "success": true,
  "status": 200,
  "data": {
    "id": "course_123",
    "title": "Forex Trading Masterclass",
    "description": "Complete course description...",
    "instructor": {...},
    "modules": [
      {
        "id": "module_1",
        "title": "Introduction to Forex",
        "order": 1,
        "lessonCount": 5,
        "duration": 120
      },
      {
        "id": "module_2",
        "title": "Technical Analysis",
        "order": 2,
        "lessonCount": 8,
        "duration": 240
      }
    ],
    "syllabus": [...],
    "requirements": [...],
    "learningOutcomes": [...]
  }
}

Create Course (Educator/Admin)

POST /v1/courses
{
  "title": "Advanced Technical Analysis",
  "description": "Master chart patterns and indicators",
  "level": "advanced",
  "category": "trading",
  "price": 499.00,
  "thumbnail": "https://...",
  "syllabus": [
    "Chart patterns",
    "Technical indicators",
    "Trading systems"
  ]
}

Update Course

PUT /v1/courses/:courseId

Request Body: Same as Create (partial updates allowed)

Delete Course

DELETE /v1/courses/:courseId

Get Course Modules

GET /v1/courses/:courseId/modules

Lessons

Get All Lessons

GET /v1/lessons?moduleId=module_123
{
  "success": true,
  "status": 200,
  "data": [
    {
      "id": "lesson_456",
      "title": "Understanding Support and Resistance",
      "description": "Learn to identify key price levels",
      "moduleId": "module_123",
      "courseId": "course_123",
      "order": 1,
      "duration": 420,
      "videoUrl": "https://cdn.yourdomain.com/videos/lesson_456/master.m3u8",
      "thumbnailUrl": "https://cdn.yourdomain.com/videos/lesson_456/thumb.jpg",
      "status": "published",
      "viewCount": 2341,
      "createdAt": "2025-01-20T00:00:00.000Z"
    }
  ]
}

Create Lesson (Educator/Admin)

POST /v1/lessons
{
  "title": "Understanding RSI Indicator",
  "description": "Master the RSI indicator",
  "moduleId": "module_123",
  "order": 5,
  "duration": 300
}

Video Upload Workflow

Step 1: Request Upload URL

POST /v1/lessons/:lessonId/request-upload-url
{
  "fileName": "lesson-video.mp4",
  "fileSize": 52428800,
  "contentType": "video/mp4"
}
{
  "success": true,
  "status": 200,
  "data": {
    "uploadUrl": "https://nyc3.digitaloceanspaces.com/your-bucket/lessons/lesson_456/video.mp4?X-Amz-Signature=...",
    "fileKey": "lessons/lesson_456/1729512000-video.mp4",
    "expiresIn": 3600,
    "instructions": {
      "method": "PUT",
      "headers": {
        "Content-Type": "video/mp4"
      }
    }
  }
}

Upload Video to URL

// Client-side upload
const file = document.getElementById('videoFile').files[0];

await fetch(uploadUrl, {
  method: 'PUT',
  headers: {
    'Content-Type': 'video/mp4'
  },
  body: file
});

Complete Upload

POST /v1/lessons/:lessonId/complete-upload
{
  "fileKey": "lessons/lesson_456/1729512000-video.mp4"
}
{
  "success": true,
  "status": 200,
  "data": {
    "lessonId": "lesson_456",
    "fileKey": "lessons/lesson_456/1729512000-video.mp4",
    "status": "processing",
    "message": "Video uploaded and processing started"
  }
}

Check Processing Status

GET /v1/lessons/:lessonId/video-status
{
  "success": true,
  "status": 200,
  "data": {
    "lessonId": "lesson_456",
    "status": "complete",
    "videoUrl": "https://cdn.yourdomain.com/videos/lesson_456/master.m3u8",
    "thumbnailUrl": "https://cdn.yourdomain.com/videos/lesson_456/thumb.jpg",
    "duration": 420,
    "formats": {
      "1080p": "https://cdn.yourdomain.com/videos/lesson_456/1080p.mp4",
      "720p": "https://cdn.yourdomain.com/videos/lesson_456/720p.mp4",
      "480p": "https://cdn.yourdomain.com/videos/lesson_456/480p.mp4"
    }
  }
}

Status Values:

  • uploading - File being uploaded
  • processing - Video being transcoded
  • complete - Ready for playback
  • failed - Processing failed

Video Processing

When a video is uploaded, it's automatically processed:

  1. Metadata Extraction - Duration, resolution, format
  2. Thumbnail Generation - Multiple timestamps
  3. Transcoding - 1080p, 720p, 480p, 360p
  4. HLS Generation - Adaptive bitrate streaming
  5. S3 Upload - Processed files uploaded

Processing Time: 2-10 minutes depending on video length

Course Object

interface Course {
  id: string;
      instructor: {
    id: string;
    firstName: string;
    lastName: string;
    avatar?: string;
  };
  level: 'beginner' | 'intermediate' | 'advanced';
  category: string;
  duration: number;  // seconds
  moduleCount: number;
  lessonCount: number;
  enrolledCount: number;
  rating: number;  // 0-5
  price: number;
  currency: string;
  thumbnail: string;
  trailerUrl?: string;
  requirements: string[];
  learningOutcomes: string[];
  tags: string[];
  status: 'draft' | 'published' | 'archived';
  createdAt: string;
  updatedAt: string;
}

Lesson Object

interface Lesson {
  id: string;
      moduleId: string;
  courseId: string;
  order: number;
  duration: number;  // seconds
  videoUrl: string;  // HLS master playlist
  thumbnailUrl: string;
  downloadUrl?: string;
  resources: Array<{
        url: string;
    type: 'pdf' | 'doc' | 'link';
  }>;
  quiz?: {
    questions: number;
    passingScore: number;
  };
  status: 'draft' | 'published';
  viewCount: number;
  createdAt: string;
  updatedAt: string;
}

Code Examples

Fetch and Display Courses

async function getCourses() {
  const response = await fetch('/v1/courses?page=1&limit=10', {
    headers: {
      'X-API-Key': apiKey,
      'Authorization': `Bearer ${token}`
    }
  });

  const { data, pagination } = await response.json();
  
  data.forEach(course => {
    console.log(`${course.title} - $${course.price}`);
  });
}

Upload Lesson Video

async function uploadVideo(lessonId, videoFile) {
  // 1. Request upload URL
  const urlResponse = await fetch(`/v1/lessons/${lessonId}/request-upload-url`, {
    method: 'POST',
    headers: {
      'X-API-Key': apiKey,
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      fileName: videoFile.name,
      fileSize: videoFile.size,
      contentType: 'video/mp4'
    })
  });

  const { data } = await urlResponse.json();
  const { uploadUrl, fileKey } = data;

  // 2. Upload to S3
  await fetch(uploadUrl, {
    method: 'PUT',
    headers: {
      'Content-Type': 'video/mp4'
    },
    body: videoFile
  });

  // 3. Complete upload
  await fetch(`/v1/lessons/${lessonId}/complete-upload`, {
    method: 'POST',
    headers: {
      'X-API-Key': apiKey,
      'Authorization': `Bearer ${token}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ fileKey })
  });

  // 4. Poll for completion
  const checkStatus = setInterval(async () => {
    const status = await fetch(`/v1/lessons/${lessonId}/video-status`, {
      headers: {
        'X-API-Key': apiKey,
        'Authorization': `Bearer ${token}`
      }
    });

    const { data } = await status.json();
    
    if (data.status === 'complete') {
      clearInterval(checkStatus);
      console.log('Video ready!', data.videoUrl);
    }
  }, 10000);  // Check every 10 seconds
}