Introduction
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.
Base Information
Base URL: /wp-json/lp/v1/
Authentication: All APIs require authentication using WordPress REST API authentication methods (OAuth, API keys, or cookie-based authentication).
Rate Limiting: 100 requests per minute per IP address.
1. Courses API
| Endpoint | Method | Description | Parameters | Permissions |
|---|---|---|---|---|
| /courses/archive-course | GET | Retrieve a list of courses with filtering and sorting options |
| Public or authenticated |
| /courses/courses-widget-by-page | GET | Get courses for widget display |
| Public |
| /courses/purchase-course | POST | Purchase a course |
| Authenticated |
| /courses/enroll-course | POST | Enroll in a course |
| Authenticated |
| /courses/retake-course | POST | Retake a course |
| Authenticated |
| /courses/continue-course | POST | Continue a course |
| Authenticated |
| /courses/{key} | GET | Get course details by key |
| Public or authenticated |
2. Profile API
| 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/update-profile | POST | Update profile information |
| Authenticated |
| /profile/update-password | POST | Update password |
| Authenticated |
| /profile/update-email | POST | Update email address |
| Authenticated |
3. Users API
| Endpoint | Method | Description | Parameters | Permissions |
|---|---|---|---|---|
| /users/register | POST | Register new user |
| Public |
| /users/login | POST | User login |
| Public |
| /users/forgot-password | POST | Request password reset |
| Public |
| /users/reset-password | POST | Reset password |
| Public |
4. Orders API
| Endpoint | Method | Description | Parameters | Permissions |
|---|---|---|---|---|
| /orders/verify-payment | POST | Verify payment status |
| Authenticated |
| /orders/cancel | POST | Cancel an order |
| Authenticated |
5. Material API
| Endpoint | Method | Description | Parameters | Permissions |
|---|---|---|---|---|
| /material/upload | POST | Upload course material |
| Admin/Instructor |
| /material/download | GET | Download course material |
| Authenticated |
| /material/delete | DELETE | Delete course material |
| Admin/Instructor |
6. Admin API
| Endpoint | Method | Description | Parameters | Permissions |
|---|---|---|---|---|
| /admin/courses | GET | Get all courses for admin |
| Admin |
| /admin/users | GET | Get all users for admin |
| Admin |
| /admin/orders | GET | Get all orders for admin |
| Admin |
| /admin/settings | GET/PUT | Get/Update system settings |
| Admin |
Error Handling
All API endpoints return appropriate HTTP status codes and error messages in the following format:
{
"code": "error_code",
"message": "Error message",
"data": {
"status": 400
}
}
Common Error Codes
- 400: Bad Request – Invalid parameters
- 401: Unauthorized – Authentication required
- 403: Forbidden – Insufficient permissions
- 404: Not Found – Resource not found
- 429: Too Many Requests – Rate limit exceeded
- 500: Internal Server Error – Server error
Authentication
To authenticate API requests, include the authentication token in the Authorization header:
Authorization: Bearer {token}
Token Types
- Access Token: Short-lived token for API access
- Refresh Token: Long-lived token for getting new access tokens
Rate Limiting
API requests are limited to 100 requests per minute per IP address. When the limit is exceeded, the API will return a 429 status code with the following headers:
- X-RateLimit-Limit: Maximum number of requests per minute
- X-RateLimit-Remaining: Number of requests remaining
- X-RateLimit-Reset: Time when the rate limit will reset
Versioning
The API is versioned using the URL path. The current version is v1. When making breaking changes, a new version will be released.
Backward Compatibility
All API changes will maintain backward compatibility within the same major version. Breaking changes will only be introduced in new major versions.
