Introduction to REST API

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.

Requirements

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:

  1. Dates will be returned in ISO 8601 format: YYYY-MM-DD HH:MM:SS
  2. Resource IDs will be returned as integers.
  3. 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.

 Settings > Tools > Rest API

Step 2: Click on Add New and then Generate button to generate a new API key and secret key pair.

Generating API Key

Make sure to keep this page open, as you will need these keys in the next steps.

Copy API and Secret

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.

Postman API authorization

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.

Errors

Occasionally, you may encounter errors when accessing the REST API. There are some possible errors:

HTTP Status CodeError CodeDescription
400 Bad RequestINVALID_PARAMInvalid or missing parameters in the request.
401 UnauthorizedUNAUTHORIZEDThe user lacks the necessary authentication credentials.
500 Internal Server ErrorINTERNAL_SERVER_ERRORThe server encountered an unexpected condition.
403 ForbiddenFORBIDDENUsers don’t have access to that specific resource.
404 Not FoundNOT_FOUNDThe requested resource could not be found.
405 Method Not AllowedMETHOD_NOT_ALLOWEDThe HTTP method used is not allowed for this resource.
408 Request TimeoutREQUEST_TIMEOUTThe server timed out while waiting to execute the request.
502 Bad GatewayBAD_GATEWAYInvalid response received from an upstream server.
504 Gateway TimeoutGATEWAY_TIMEOUTThe server, while acting as a gateway or proxy, did not receive a timely response from an upstream server.
505 HTTP Version Not SupportedHTTP_VERSION_NOT_SUPPORTEDThe server does not support the HTTP protocol version used in the request.
507 Insufficient StorageINSUFFICIENT_STORAGEThe server is unable to store the representation needed to complete the request.
508 Loop DetectedLOOP_DETECTEDThe 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.

Was this helpful?