This document provides comprehensive documentation for the OpenLN API endpoints, including authentication, request/response formats, and usage examples.
- Base URL:
https://api.openln.dev/api/v1(Production) - Development URL:
http://localhost:5000/api/v1 - Content Type:
application/json - Authentication: JWT Bearer tokens
Authorization: Bearer <your-jwt-token>{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "user_id",
"email": "user@example.com",
"role": "user"
},
"expiresIn": "7d"
}{
"success": true,
"data": {
// Response data
},
"message": "Operation completed successfully"
}{
"success": false,
"error": {
"code": "ERROR_CODE",
"message": "Error description",
"details": {} // Additional error details
}
}{
"success": true,
"data": {
"items": [], // Array of items
"pagination": {
"currentPage": 1,
"totalPages": 10,
"totalItems": 100,
"itemsPerPage": 10,
"hasNext": true,
"hasPrev": false
}
}
}POST /auth/registerRequest Body:
{
"email": "user@example.com",
"password": "securePassword123",
"name": "John Doe",
"agreeToTerms": true
}Response:
{
"success": true,
"data": {
"token": "jwt-token-here",
"user": {
"id": "60f7b3b3b3b3b3b3b3b3b3b3",
"email": "user@example.com",
"name": "John Doe",
"role": "user",
"profile": {
"avatar": null,
"bio": null,
"preferences": {}
},
"createdAt": "2023-07-25T10:00:00.000Z"
}
},
"message": "User registered successfully"
}POST /auth/loginRequest Body:
{
"email": "user@example.com",
"password": "securePassword123"
}Response: Same as register response
GET /auth/googleRedirects to Google OAuth consent screen.
POST /auth/refreshRequest Body:
{
"refreshToken": "refresh-token-here"
}POST /auth/logoutHeaders: Authorization: Bearer <token>
POST /auth/forgot-passwordRequest Body:
{
"email": "user@example.com"
}POST /auth/reset-passwordRequest Body:
{
"token": "reset-token-from-email",
"newPassword": "newSecurePassword123"
}GET /users/meHeaders: Authorization: Bearer <token>
Response:
{
"success": true,
"data": {
"id": "user_id",
"email": "user@example.com",
"name": "John Doe",
"profile": {
"avatar": "avatar-url",
"bio": "User bio",
"location": "City, Country",
"website": "https://example.com"
},
"preferences": {
"learningStyle": "visual",
"notifications": {
"email": true,
"push": false
},
"theme": "light"
},
"stats": {
"coursesCompleted": 5,
"totalLearningTime": 1200,
"currentStreak": 7
}
}
}PUT /users/meHeaders: Authorization: Bearer <token>
Request Body:
{
"name": "Updated Name",
"profile": {
"bio": "Updated bio",
"location": "New City, Country"
},
"preferences": {
"learningStyle": "auditory",
"notifications": {
"email": false
}
}
}POST /users/me/avatarHeaders:
Authorization: Bearer <token>Content-Type: multipart/form-data
Request Body:
avatar: <file>
DELETE /users/meHeaders: Authorization: Bearer <token>
GET /courses?page=1&limit=10&category=programming&difficulty=beginnerQuery Parameters:
page(optional): Page number (default: 1)limit(optional): Items per page (default: 10, max: 50)category(optional): Filter by categorydifficulty(optional): Filter by difficulty (beginner, intermediate, advanced)search(optional): Search in title and description
Response:
{
"success": true,
"data": {
"items": [
{
"id": "course_id",
"title": "Introduction to React",
"description": "Learn React fundamentals",
"thumbnail": "thumbnail-url",
"difficulty": "beginner",
"category": "programming",
"duration": 1200,
"modules": 8,
"rating": 4.5,
"enrollments": 1500,
"instructor": {
"id": "instructor_id",
"name": "Jane Smith",
"avatar": "avatar-url"
},
"tags": ["react", "javascript", "frontend"],
"createdAt": "2023-07-01T00:00:00.000Z"
}
],
"pagination": {
"currentPage": 1,
"totalPages": 5,
"totalItems": 45,
"itemsPerPage": 10
}
}
}GET /courses/:idResponse:
{
"success": true,
"data": {
"id": "course_id",
"title": "Introduction to React",
"description": "Complete course description...",
"thumbnail": "thumbnail-url",
"difficulty": "beginner",
"category": "programming",
"duration": 1200,
"modules": [
{
"id": "module_id",
"title": "Getting Started",
"description": "Module description",
"duration": 300,
"lessons": [
{
"id": "lesson_id",
"title": "What is React?",
"type": "video",
"duration": 600,
"content": "lesson-content-url"
}
]
}
],
"prerequisites": ["javascript-basics"],
"learningObjectives": [
"Understand React components",
"Build interactive UIs"
],
"instructor": {
"id": "instructor_id",
"name": "Jane Smith",
"bio": "Expert in React development",
"avatar": "avatar-url"
},
"reviews": {
"average": 4.5,
"count": 250,
"distribution": {
"5": 150,
"4": 75,
"3": 20,
"2": 3,
"1": 2
}
}
}
}POST /courses/:id/enrollHeaders: Authorization: Bearer <token>
GET /users/me/coursesHeaders: Authorization: Bearer <token>
GET /courses/:id/progressHeaders: Authorization: Bearer <token>
Response:
{
"success": true,
"data": {
"courseId": "course_id",
"progress": {
"percentage": 65,
"completedModules": 5,
"totalModules": 8,
"completedLessons": 15,
"totalLessons": 24,
"timeSpent": 3600
},
"lastAccessed": "2023-07-25T10:00:00.000Z",
"currentLesson": {
"moduleId": "module_6",
"lessonId": "lesson_16"
}
}
}POST /courses/:courseId/lessons/:lessonId/progressHeaders: Authorization: Bearer <token>
Request Body:
{
"completed": true,
"timeSpent": 300,
"score": 85
}GET /goals?status=active&page=1&limit=10Headers: Authorization: Bearer <token>
Query Parameters:
status(optional): Filter by status (active, completed, paused)type(optional): Filter by goal typepage,limit: Pagination
Response:
{
"success": true,
"data": {
"items": [
{
"id": "goal_id",
"title": "Complete React Course",
"description": "Finish the React fundamentals course",
"type": "course_completion",
"target": {
"type": "completion",
"value": 100,
"deadline": "2023-08-31T23:59:59.000Z"
},
"progress": {
"current": 65,
"percentage": 65
},
"status": "active",
"priority": "high",
"createdAt": "2023-07-01T00:00:00.000Z"
}
]
}
}POST /goalsHeaders: Authorization: Bearer <token>
Request Body:
{
"title": "Learn TypeScript",
"description": "Master TypeScript fundamentals",
"type": "skill_development",
"target": {
"type": "time",
"value": 2400,
"deadline": "2023-12-31T23:59:59.000Z"
},
"priority": "medium",
"relatedCourses": ["typescript-course-id"]
}PUT /goals/:idHeaders: Authorization: Bearer <token>
DELETE /goals/:idHeaders: Authorization: Bearer <token>
POST /goals/:id/progressHeaders: Authorization: Bearer <token>
Request Body:
{
"progress": 75,
"notes": "Completed another module today"
}GET /ai/recommendationsHeaders: Authorization: Bearer <token>
Response:
{
"success": true,
"data": {
"courses": [
{
"id": "course_id",
"title": "Advanced React Patterns",
"reason": "Based on your progress in React fundamentals",
"confidence": 0.85
}
],
"goals": [
{
"title": "Build a Portfolio Project",
"description": "Apply your React skills",
"reason": "You've completed 3 React courses"
}
],
"nextLessons": [
{
"courseId": "current_course",
"lessonId": "next_lesson",
"title": "React Hooks Deep Dive",
"estimatedTime": 45
}
]
}
}POST /ai/learning-pathHeaders: Authorization: Bearer <token>
Request Body:
{
"goal": "Become a full-stack developer",
"currentSkills": ["html", "css", "basic-javascript"],
"timeCommitment": 10,
"preferredStyle": "hands-on"
}POST /ai/content-suggestionsHeaders: Authorization: Bearer <token>
Request Body:
{
"topic": "React performance optimization",
"difficulty": "intermediate",
"format": "video"
}GET /analytics/user?period=30dHeaders: Authorization: Bearer <token>
Query Parameters:
period: Time period (7d, 30d, 90d, 1y)
Response:
{
"success": true,
"data": {
"learningTime": {
"total": 7200,
"thisWeek": 480,
"average": 102.86
},
"progress": {
"coursesStarted": 8,
"coursesCompleted": 3,
"lessonsCompleted": 45
},
"goals": {
"total": 5,
"completed": 2,
"onTrack": 2,
"overdue": 1
},
"streaks": {
"current": 7,
"longest": 15
},
"timeline": [
{
"date": "2023-07-25",
"minutes": 120,
"lessonsCompleted": 3
}
]
}
}GET /analytics/courses/:idHeaders: Authorization: Bearer <token>
GET /search?q=react&type=courses&page=1&limit=10Query Parameters:
q: Search querytype: Content type (courses, users, goals, all)filters: Additional filters as JSON string
Response:
{
"success": true,
"data": {
"results": {
"courses": [
{
"id": "course_id",
"title": "React Fundamentals",
"type": "course",
"relevance": 0.95
}
],
"total": 15
},
"suggestions": ["react hooks", "react router"],
"filters": {
"categories": ["programming", "web-development"],
"difficulties": ["beginner", "intermediate"]
}
}
}| Code | Description |
|---|---|
AUTH_REQUIRED |
Authentication required |
AUTH_INVALID |
Invalid authentication token |
AUTH_EXPIRED |
Authentication token expired |
FORBIDDEN |
Insufficient permissions |
NOT_FOUND |
Resource not found |
VALIDATION_ERROR |
Request validation failed |
DUPLICATE_ENTRY |
Resource already exists |
RATE_LIMIT |
Rate limit exceeded |
SERVER_ERROR |
Internal server error |
SERVICE_UNAVAILABLE |
Service temporarily unavailable |
- Anonymous requests: 100 requests per hour
- Authenticated requests: 1000 requests per hour
- Upload endpoints: 10 requests per minute
Rate limit headers:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1627284000# Login
curl -X POST https://api.openln.dev/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"user@example.com","password":"password"}'
# Get courses (with token)
curl -X GET https://api.openln.dev/api/v1/courses \
-H "Authorization: Bearer YOUR_TOKEN"// Login
const loginResponse = await fetch('/api/v1/auth/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'user@example.com',
password: 'password'
})
});
const { data } = await loginResponse.json();
const token = data.token;
// Use authenticated endpoint
const coursesResponse = await fetch('/api/v1/courses', {
headers: { 'Authorization': `Bearer ${token}` }
});A Postman collection with all endpoints is available:
- Download Postman Collection
- Import into Postman for easy testing
- Environment variables included for different stages
For more information or support, please open an issue or join our discussions.