LearnPress API Reference

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
  • page (integer): Page number
  • per_page (integer): Items per page
  • search (string): Search keyword
  • term_id (string): Category IDs (comma-separated)
  • tag_id (string): Tag IDs (comma-separated)
  • order_by (string): Sort field (post_date, title, price)
  • order (string): Sort order (ASC/DESC)
  • sort_by (string): Special sorting (on_sale, on_free, on_paid, on_feature)
  • c_level (string): Course level filter
  • c_type (string): Course type (online/offline)
  • return_type (string): Response format (html/json)
Public or authenticated
/courses/courses-widget-by-page GET Get courses for widget display
  • limit (integer): Number of courses
  • order_by (string): Sort field
  • order (string): Sort order
  • category (string): Category filter
Public
/courses/purchase-course POST Purchase a course
  • course_id (integer): Course ID
  • payment_method (string): Payment method
  • coupon_code (string): Optional coupon code
Authenticated
/courses/enroll-course POST Enroll in a course
  • course_id (integer): Course ID
Authenticated
/courses/retake-course POST Retake a course
  • course_id (integer): Course ID
Authenticated
/courses/continue-course POST Continue a course
  • course_id (integer): Course ID
Authenticated
/courses/{key} GET Get course details by key
  • key (string): Course key or ID
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
  • display_name (string): Display name
  • first_name (string): First name
  • last_name (string): Last name
  • description (string): Biography
Authenticated
/profile/update-password POST Update password
  • current_password (string): Current password
  • new_password (string): New password
  • confirm_password (string): Confirm new password
Authenticated
/profile/update-email POST Update email address
  • email (string): New email
  • password (string): Current password
Authenticated

3. Users API

Endpoint Method Description Parameters Permissions
/users/register POST Register new user
  • username (string): Username
  • email (string): Email address
  • password (string): Password
  • first_name (string): First name
  • last_name (string): Last name
Public
/users/login POST User login
  • username (string): Username or email
  • password (string): Password
  • remember (boolean): Remember me
Public
/users/forgot-password POST Request password reset
  • email (string): Email address
Public
/users/reset-password POST Reset password
  • key (string): Reset key
  • password (string): New password
Public

4. Orders API

Endpoint Method Description Parameters Permissions
/orders/checkout POST Process order checkout
  • course_id (integer): Course ID
  • payment_method (string): Payment method
  • coupon_code (string): Optional coupon code
Authenticated
/orders/verify-payment POST Verify payment status
  • order_id (integer): Order ID
  • payment_method (string): Payment method
  • transaction_id (string): Transaction ID
Authenticated
/orders/cancel POST Cancel an order
  • order_id (integer): Order ID
  • reason (string): Cancellation reason
Authenticated

5. Material API

Endpoint Method Description Parameters Permissions
/material/upload POST Upload course material
  • course_id (integer): Course ID
  • file (file): Material file
  • title (string): Material title
  • description (string): Material description
Admin/Instructor
/material/download GET Download course material
  • material_id (integer): Material ID
Authenticated
/material/delete DELETE Delete course material
  • material_id (integer): Material ID
Admin/Instructor

6. Admin API

Endpoint Method Description Parameters Permissions
/admin/courses GET Get all courses for admin
  • page (integer): Page number
  • per_page (integer): Items per page
  • status (string): Course status
  • search (string): Search keyword
Admin
/admin/users GET Get all users for admin
  • page (integer): Page number
  • per_page (integer): Items per page
  • role (string): User role
  • search (string): Search keyword
Admin
/admin/orders GET Get all orders for admin
  • page (integer): Page number
  • per_page (integer): Items per page
  • status (string): Order status
  • search (string): Search keyword
Admin
/admin/settings GET/PUT Get/Update system settings
  • settings (object): Settings data (for PUT)
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.