This API Reference documents all available RESTful endpoints provided by LearnPress, organized under the namespace lp/v1. These APIs allow developers to manage courses, profiles, users, instructors, orders, materials, and administrative tasks programmatically. All endpoints are secured with permission callbacks to ensure proper access control.
Base URL: /wp-json/lp/v1/
HTTP Methods Used:
- GET: Retrieve data
- POST: Create or trigger actions
- PUT: Update data
- DELETE: Remove data
1. Courses API
Manage courses within LearnPress.
Endpoint | Method | Description | Parameters | Permissions |
---|---|---|---|---|
/courses/archive-course | GET | Retrieve a list of courses | page, per_page, search | Public or authenticated |
/courses/purchase-course | POST | Purchase a course | course_id | Authenticated |
/courses/enroll-course | POST | Enroll in a course | course_id | Authenticated |
/courses/retake-course | POST | Retake a course | course_id | Authenticated |
/courses/continue-course | POST | Continue a course | course_id | Authenticated |
/courses/{id} | GET | Get detailed course information | id (Course ID) | Public or authenticated |
/courses/{id} | PUT | Update course information | id, course data (JSON) | Admin/Instructor |
/courses/{id} | DELETE | Delete a course | id | Admin |
2. Profile API
Manage user profiles and statistics.
Endpoint | Method | Description | Parameters | Permissions |
---|---|---|---|---|
/profile/student/statistic | GET | Get student statistics | None | Authenticated (Student) |
/profile/instructor/statistic | GET | Get instructor statistics | None | Authenticated (Instructor) |
/profile/course-tab | GET | Get list of courses in profile tab | tab (optional) | Authenticated |
/profile/course-attend | POST | Mark course attendance | course_id | Authenticated |
/profile/get-avatar | GET | Retrieve user avatar | None | Authenticated |
/profile/upload-avatar | POST | Upload a new avatar | image (file) | Authenticated |
/profile/remove-avatar | POST | Remove user avatar | None | Authenticated |
/profile/cover-image | POST | Manage cover image | image (file) | Authenticated |
3. Users API
Manage user accounts.
Endpoint | Method | Description | Parameters | Permissions |
---|---|---|---|---|
/users | GET | Retrieve a list of users | page, per_page, search | Admin |
/users/{id} | GET | Get user information | id (User ID) | Admin or self |
/users | POST | Create a new user | User data (JSON) | Admin |
/users/{id} | PUT | Update user information | id, user data (JSON) | Admin or self |
/users/{id} | DELETE | Delete a user | id | Admin |
4. Instructor API
Manage instructor-specific data.
Endpoint | Method | Description | Parameters | Permissions |
---|---|---|---|---|
/instructor | GET | Get instructor information | None | Authenticated (Instructor) |
/instructor/courses | GET | Get instructor’s course list | page, per_page | Authenticated (Instructor) |
/instructor/students | GET | Get list of students | page, per_page | Authenticated (Instructor) |
5. Orders API
Manage course purchase orders.
Endpoint | Method | Description | Parameters | Permissions |
---|---|---|---|---|
/orders | GET | Retrieve a list of orders | page, per_page, status | Admin or self |
/orders | POST | Create a new order | Order data (JSON) | Authenticated |
/orders/{id} | GET | Get order details | id (Order ID) | Admin or self |
6. Material API
Manage course materials.
Endpoint | Method | Description | Parameters | Permissions |
---|---|---|---|---|
/material | GET | Retrieve a list of materials | page, per_page | Authenticated |
/material | POST | Create a new material | Material data (JSON) | Admin/Instructor |
/material/{id} | GET | Get material details | id (Material ID) | Authenticated |
7. Admin API
Administrative tools and system management.
Endpoint | Method | Description | Parameters | Permissions |
---|---|---|---|---|
/admin/statistics | GET | Get system statistics | None | Admin |
/admin/reset-data | POST | Reset system data | None | Admin |
/admin/database | GET | Manage database | None | Admin |
/admin/tools | GET | Access admin tools | None | Admin |
8. Widgets API
Manage LearnPress widgets.
Endpoint | Method | Description | Parameters | Permissions |
---|---|---|---|---|
/widgets | GET | Retrieve a list of widgets | None | Admin |
/widgets/{id} | GET | Get widget information | id (Widget ID) | Admin |
9. Settings API
Manage system settings.
Endpoint | Method | Description | Parameters | Permissions |
---|---|---|---|---|
/settings | GET | Retrieve system settings | None | Admin |
/settings | PUT | Update system settings | Settings data (JSON) | Admin |
10. Lazy Loading API
Handle on-demand data loading.
Endpoint | Method | Description | Parameters | Permissions |
---|---|---|---|---|
/lazy-load | GET | Load data on demand | type, id, context | Authenticated |
Authentication & Permissions
- All APIs are protected by WordPress REST API authentication methods (e.g., OAuth, API keys, or cookie-based authentication).
- Permission callbacks ensure that only authorized users (e.g., Admin, Instructor, Student) can access specific endpoints.
- Use appropriate roles and capabilities when integrating these APIs into your application.
Example Usage
Retrieve a List of Courses
GET /wp-json/lp/v1/courses/archive-course?page=1&per_page=10
Response:
{ “courses”: [ { “id”: 1, “title”: “Course Title”, “description”: “Course Description” } ], “total”: 50, “pages”: 5 }
Enroll in a Course
POST /wp-json/lp/v1/courses/enroll-course Content-Type: application/json { "course_id": 1 }
Response:
{ "success": true, "message": "Enrolled successfully" }