Introduction
The EaseLMS API is a RESTful API built with Next.js API routes that provides programmatic access to your learning management system. All API endpoints return JSON responses and use standard HTTP response codes.Base URL
All API requests should be made to:Versioning
The current API does not use versioning in the URL path. All endpoints are accessed directly under/api/ route.
Request Format
HTTP Methods
The API uses standard HTTP methods:GET- Retrieve resourcesPOST- Create new resourcesPATCH- Update existing resourcesPUT- Replace existing resourcesDELETE- Remove resources
Content Type
All requests with a body should useapplication/json content type:
Response Format
Success Responses
Successful responses return a200 status code with a JSON object:
Error Responses
Error responses include an error message and appropriate HTTP status code:Common HTTP Status Codes
CORS
The API supports Cross-Origin Resource Sharing (CORS) for API routes. CORS headers are automatically added:- Allowed Origin: Configured via
NEXT_PUBLIC_WEBSITE_URLenvironment variable (or*for development) - Allowed Methods:
GET, POST, PUT, DELETE, OPTIONS - Allowed Headers:
Content-Type, Authorization - Max Age:
86400seconds (24 hours)
Rate Limiting
Currently, the API does not implement rate limiting. This may be added in future versions.Common Patterns
Pagination
Most list endpoints support query parameters for filtering:Filtering by IDs
Multiple resources can be retrieved by ID using comma-separated values:Service Role Access
Public endpoints (like course listings) can be accessed without authentication. Protected endpoints require valid authentication tokens.Environment Variables
The API requires the following environment variables:string
required
Your Supabase project URL
string
required
Your Supabase anonymous/public API key
string
required
Your Supabase service role key for bypassing Row Level Security (RLS)
string
Your website URL for CORS configuration (optional, defaults to
* in development)string
Your application URL for internal API calls (optional, defaults to
http://localhost:3000)Next Steps
Authentication
Learn how to authenticate API requests
Courses API
Work with courses and lessons
Users API
Manage users and profiles
Enrollments API
Handle course enrollments