Skip to main content

API Reference Overview

The Akako LMS provides a comprehensive RESTful API for managing all aspects of the learning management system. This API is built with Next.js 14 App Router and follows modern API design principles.

Authentication​

All API endpoints require authentication using Clerk.js JWT tokens. Include the token in the Authorization header:

Authorization: Bearer <jwt_token>

Response Format​

All API responses follow a consistent format:

Success Response​

{
"success": true,
"data": {
// Response data
},
"message": "Operation completed successfully"
}

Error Response​

{
"success": false,
"error": "Error message",
"code": "ERROR_CODE",
"details": {
// Additional error details
}
}

HTTP Status Codes​

  • 200 - Success
  • 201 - Created
  • 400 - Bad Request
  • 401 - Unauthorized
  • 403 - Forbidden
  • 404 - Not Found
  • 409 - Conflict (duplicate resource)
  • 422 - Unprocessable Entity (validation error)
  • 500 - Internal Server Error

Rate Limiting​

API endpoints are protected with rate limiting using Redis:

  • General endpoints: 100 requests per minute per IP
  • Authentication endpoints: 10 requests per minute per IP
  • File upload endpoints: 20 requests per minute per user

Rate limit headers are included in responses:

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1640995200

API Endpoints​

Authentication​

MethodEndpointDescriptionAuth Required
POST/auth/syncSync user data from ClerkNo
GET/auth/profileGet current user profileYes
PUT/auth/profileUpdate user profileYes

User Management​

MethodEndpointDescriptionAuth RequiredRoles
GET/usersList all usersYesAdmin
GET/users/[id]Get user by IDYesAdmin
PUT/users/[id]Update userYesAdmin
POST/users/[id]/rolesAssign role to userYesAdmin
DELETE/users/[id]/rolesRemove role from userYesAdmin

Education System​

MethodEndpointDescriptionAuth RequiredRoles
GET/education/levelsList education levelsNo-
GET/education/levels/[id]/gradesGet grades for levelNo-
GET/education/grades/[id]/subjectsGet subjects for gradeNo-
GET/education/subjects/[id]/topicsGet topics for subjectNo-
POST/admin/education/levelsCreate education levelYesAdmin
PUT/admin/education/levels/[id]Update education levelYesAdmin
DELETE/admin/education/levels/[id]Delete education levelYesAdmin

File Management​

MethodEndpointDescriptionAuth RequiredRoles
POST/s3/document/uploadUpload documentYesAdmin, Mentor
GET/s3/document/streamStream documentYesAdmin, Mentor, Learner
DELETE/admin/education/topics/[id]/documents/[docId]Delete documentYesAdmin, Mentor

Video Management​

MethodEndpointDescriptionAuth RequiredRoles
PUT/admin/education/topics/[id]/videoUpload/update videoYesAdmin, Mentor
DELETE/admin/education/topics/[id]/videoDelete videoYesAdmin, Mentor

Enrollment System​

MethodEndpointDescriptionAuth RequiredRoles
POST/enrollment/requestRequest enrollmentYesLearner
GET/admin/enrollment/pendingGet pending enrollmentsYesAdmin
PUT/admin/enrollment/[id]/approveApprove enrollmentYesAdmin
PUT/admin/enrollment/[id]/rejectReject enrollmentYesAdmin

Mentor Applications​

MethodEndpointDescriptionAuth RequiredRoles
POST/mentor/applySubmit mentor applicationYesLearner
GET/admin/mentor/pendingGet pending applicationsYesAdmin
PUT/admin/mentor/[id]/approveApprove mentor applicationYesAdmin
PUT/admin/mentor/[id]/rejectReject mentor applicationYesAdmin

Error Handling​

Validation Errors​

When request validation fails, the API returns detailed error information:

{
"success": false,
"error": "Validation failed",
"code": "VALIDATION_ERROR",
"details": {
"field": "email",
"message": "Invalid email format",
"value": "invalid-email"
}
}

Role-based Access Errors​

When a user lacks required permissions:

{
"success": false,
"error": "Insufficient permissions",
"code": "FORBIDDEN",
"details": {
"required": ["ADMIN"],
"user_roles": ["LEARNER"]
}
}

Duplicate Resource Errors​

When attempting to create duplicate resources:

{
"success": false,
"error": "Resource already exists",
"code": "CONFLICT",
"details": {
"resource": "education_level",
"field": "name",
"value": "Primary School"
}
}

Pagination​

List endpoints support pagination using query parameters:

GET /api/users?page=1&limit=20&sort=createdAt&order=desc

Response includes pagination metadata:

{
"success": true,
"data": [...],
"pagination": {
"page": 1,
"limit": 20,
"total": 150,
"pages": 8,
"hasNext": true,
"hasPrev": false
}
}

Many endpoints support filtering and search:

GET /api/users?search=john&role=LEARNER&status=ACTIVE

Available Filters​

  • Search: Text search across relevant fields
  • Role: Filter by user roles
  • Status: Filter by user status
  • Date Range: Filter by creation/update dates
  • Boolean Fields: Filter by boolean properties

File Upload​

Document Upload​

Documents are uploaded using multipart form data:

POST /api/s3/document/upload
Content-Type: multipart/form-data

file: <binary_data>
topicId: "topic_id_here"
metadata: {"name": "document.pdf", "description": "Study material"}

Video Upload​

Videos are uploaded directly to topics:

PUT /api/admin/education/topics/[id]/video
Content-Type: multipart/form-data

video: <binary_data>

Webhooks​

The system supports webhooks for real-time notifications:

Clerk Webhooks​

POST /api/webhooks/clerk
Content-Type: application/json
X-Svix-Signature: <signature>

{
"type": "user.created",
"data": {
"id": "user_123",
"email_addresses": [...],
"first_name": "John",
"last_name": "Doe"
}
}

SDK and Client Libraries​

JavaScript/TypeScript​

import { AkakoAPI } from '@akako/lms-sdk';

const api = new AkakoAPI({
baseURL: 'https://akako.example.com/api',
token: 'your_jwt_token'
});

// Get education levels
const levels = await api.education.getLevels();

// Create new level
const newLevel = await api.education.createLevel({
name: 'High School',
description: 'Secondary education'
});

Python​

from akako_lms import AkakoAPI

api = AkakoAPI(
base_url='https://akako.example.com/api',
token='your_jwt_token'
)

# Get education levels
levels = api.education.get_levels()

# Create new level
new_level = api.education.create_level(
name='High School',
description='Secondary education'
)

Testing​

Postman Collection​

A complete Postman collection is available for testing all API endpoints:

Download Postman Collection

API Testing Script​

# Test authentication
curl -X POST https://akako.example.com/api/auth/sync \
-H "Content-Type: application/json" \
-d '{"userId": "user_123", "email": "test@example.com"}'

# Test education levels
curl -X GET https://akako.example.com/api/education/levels \
-H "Authorization: Bearer your_jwt_token"

Rate Limiting and Quotas​

Free Tier​

  • 1,000 API calls per month
  • 10 file uploads per month
  • Basic support

Pro Tier​

  • 10,000 API calls per month
  • 100 file uploads per month
  • Priority support
  • Advanced analytics

Enterprise Tier​

  • Unlimited API calls
  • Unlimited file uploads
  • Dedicated support
  • Custom integrations

Support​

For API support and questions:

Next Steps​