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
| Status Code | Meaning |
|---|---|
200 | OK - Request succeeded |
201 | Created - Resource successfully created |
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Authentication required |
403 | Forbidden - Insufficient permissions |
404 | Not Found - Resource doesn’t exist |
409 | Conflict - Resource already exists |
500 | Internal Server Error - Server error occurred |
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:Your Supabase project URL
Your Supabase anonymous/public API key
Your Supabase service role key for bypassing Row Level Security (RLS)
Your website URL for CORS configuration (optional, defaults to
* in development)Your application URL for internal API calls (optional, defaults to
http://localhost:3000)