Tutor LMS is fully integrated with the WordPress REST API. This allows Tutor LMS data to be created, read, updated, and deleted using JSON requests. It supports standard HTTP verbs and WordPress REST API Authentication methods.
To use the latest version of REST API, you must be using:
- Tutor LMS v2.6.0 or higher
- Tutor LMS Pro v2.6.0 or higher
You can access the API over both HTTP and HTTPS connections. But HTTPS is recommended.
Request / Response Format
The default response format of Tutor LMS REST API is JSON. So, you have to use plain JSON to set or update resource attributes. Every successful request will return a ‘200 OK’ status.
Here is some general information about the responses:
- Dates will be returned in ISO 8601 format: YYYY-MM-DD HH:MM:SS
- Resource IDs will be returned as integers.
- Decimal monetary amounts (course prices or totals) will be returned as strings with two decimal places.
Setting Up Authentication for Tutor LMS Rest API
Step 1: From your Tutor LMS WordPress dashboard, navigate to Settings > Tools > Rest API.
Step 2: Click on Add New and then Generate button to generate a new API key and secret key pair.
Make sure to keep this page open, as you will need these keys in the next steps.
Step 3: Set Authorization. If you’re using Postman, open the Authorization tab for your desired request. Choose Basic Auth as the Type.
Step 4: Copy the generated API key from the Tutor LMS Rest API page and paste it into the Username field of the Authorization tab in Postman. Similarly, copy the secret key and paste it into the Password field.
Step 5: Now, you are ready to send the GET request to retrieve the desired data from the Tutor LMS Rest API. Make sure the request is properly configured with the correct endpoint and any required parameters.
Step 6: Click on the Send button to initiate the request. If the authentication is successful, you will receive the response containing the requested data.
That’s it! You have successfully set up authentication for Tutor LMS Rest API. You can now explore different endpoints and retrieve data securely.
Occasionally, you may encounter errors when accessing the REST API. There are some possible errors:
|HTTP Status Code
|400 Bad Request
|Invalid or missing parameters in the request.
|The user lacks the necessary authentication credentials.
|500 Internal Server Error
|The server encountered an unexpected condition.
|Users don’t have access to that specific resource.
|404 Not Found
|The requested resource could not be found.
|405 Method Not Allowed
|The HTTP method used is not allowed for this resource.
|408 Request Timeout
|The server timed out while waiting to execute the request.
|502 Bad Gateway
|Invalid response received from an upstream server.
|504 Gateway Timeout
|The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server.
|505 HTTP Version Not Supported
|The server does not support the HTTP protocol version used in the request.
|507 Insufficient Storage
|The server is unable to store the representation needed to complete the request.
|508 Loop Detected
|The server detected an infinite loop while processing a request.
Note: Only errors with status codes 400, 401, and 500 originate from Tutor LMS. WordPress handles all other errors.