LearnPress Developer Documentation

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

EndpointMethodDescriptionParametersPermissions
/courses/archive-courseGETRetrieve 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-pageGETGet 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-coursePOSTPurchase a course

  • id (integer): Course ID

  • payment_method (string): Payment method

  • coupon_code (string): Optional coupon code


Authenticated
/courses/enroll-coursePOSTEnroll in a course
  • course_id (integer): Course ID
Authenticated
/courses/retake-coursePOSTRetake a course
  • course_id (integer): Course ID
Authenticated
/courses/continue-coursePOSTContinue a course
  • course_id (integer): Course ID
Authenticated
/courses/{key}GETGet course details by key
  • key (string): Course key or ID
Public or authenticated

2. Profile API

EndpointMethodDescriptionParametersPermissions
/profile/student/statisticGETGet student statisticsNoneAuthenticated (Student)
/profile/instructor/statisticGETGet instructor statisticsNoneAuthenticated (Instructor)
/profile/update-profilePOSTUpdate profile information
  • display_name (string): Display name
  • first_name (string): First name
  • last_name (string): Last name
  • description (string): Biography
Authenticated
/profile/update-passwordPOSTUpdate password
  • current_password (string): Current password
  • new_password (string): New password
  • confirm_password (string): Confirm new password
Authenticated
/profile/update-emailPOSTUpdate email address
  • email (string): New email
  • password (string): Current password
Authenticated

3. Users API

EndpointMethodDescriptionParametersPermissions
/users/registerPOSTRegister new user
  • username (string): Username
  • email (string): Email address
  • password (string): Password
  • first_name (string): First name
  • last_name (string): Last name
Public
/users/loginPOSTUser login
  • username (string): Username or email
  • password (string): Password
  • remember (boolean): Remember me
Public
/users/forgot-passwordPOSTRequest password reset
  • email (string): Email address
Public
/users/reset-passwordPOSTReset password
  • key (string): Reset key
  • password (string): New password
Public

4. Orders API

EndpointMethodDescriptionParametersPermissions
/orders/verify-paymentPOSTVerify payment status


  • order_id (integer): Order ID

  • payment_method (string): Payment method

  • transaction_id (string): Transaction ID
Authenticated
/orders/cancelPOSTCancel an order
  • order_id (integer): Order ID
  • reason (string): Cancellation reason
Authenticated

5. Material API

EndpointMethodDescriptionParametersPermissions
/material/uploadPOSTUpload course material
  • course_id (integer): Course ID
  • file (file): Material file
  • title (string): Material title
  • description (string): Material description
Admin/Instructor
/material/downloadGETDownload course material
  • material_id (integer): Material ID
Authenticated
/material/deleteDELETEDelete course material
  • material_id (integer): Material ID
Admin/Instructor

6. Admin API

EndpointMethodDescriptionParametersPermissions
/admin/coursesGETGet all courses for admin
  • page (integer): Page number
  • per_page (integer): Items per page
  • status (string): Course status
  • search (string): Search keyword
Admin
/admin/usersGETGet all users for admin
  • page (integer): Page number
  • per_page (integer): Items per page
  • role (string): User role
  • search (string): Search keyword
Admin
/admin/ordersGETGet all orders for admin
  • page (integer): Page number
  • per_page (integer): Items per page
  • status (string): Order status
  • search (string): Search keyword
Admin
/admin/settingsGET/PUTGet/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.