Developer API

How to make a request

CURL Example:

curl -d '{"startTime": 1545318000, "title": "Test lesson title", "duration": 90, "exitLink": "https://google.com", "shareLink": "https://google.com"}' -H "Content-Type: application/json" -H "x-api-key: 123" -X POST https://tutrex.com/api/v1/lessons
  • Every request should contain two headers:
    • Content-Type: application/json
    • x-api-key: YOUR_API_KEY
  • Request information should be sent in JSON format.
  • Responses are also sent in JSON format.

Create Lesson

Method: POST

API Endpoint: /api/v1/lessons

JSON Request Parameters:

Parameter Required Type Description Example
startTime Yes integer Unix timestamp of lesson start time. 1545318000
title Yes string Lesson title. Test lesson title
duration Yes integer Lesson duration in minutes. 90
exitLink No string URL for redirection after leaving the lesson. https://google.com
shareLink No string URL for sharing via social networks. https://google.com

Success Response Example:

{
    "status": "success",
    "body": {
        "id": 123,
        "title": "Test lesson title",
        "duration": 90,
        "recordUrl": null,
        "startTime": 1545318000,
        "status": "coming",
        "teacherUrl": "https://tutrex.com/board/?token=abcdefgh1234567890",
        "studentUrl": "https://tutrex.com/lessons/abcdef1234567"
    }
}

Error Response Example:

{
    "status": "error",
    "body": {
        "message": "Invalid data.",
        "errors": {
            "startTime": "Start time should not be in the past.",
            "title": "Title should not be empty.",
            "duration": "Duration should be a valid integer greater than 0."
        }
    }
}

Get Lessons

Method: GET

API Endpoint: /api/v1/lessons

JSON Request Parameters:

Parameter Required Type Description Example
sortBy No string Options: id, startTime, title. Default: startTime. title
sortDirection No string Options: ASC, DESC. Default: DESC. ASC
limit No integer Maximum results per request. Default: 20. 2
offset No integer Index of first result. Default: 0. 0

Success Response Example:

{
    "status": "success",
    "body": [
        {
            "id": 2,
            "title": "a",
            "duration": 60,
            "recordUrl": null,
            "startTime": "1544198400",
            "status": "expired",
            "teacherUrl": "https://tutrex.com/board/?token=abcdefgh1234567890",
            "studentUrl": "https://tutrex.com/lessons/abcdef1234567"
        },
        {
            "id": 1,
            "title": "b",
            "duration": 90,
            "recordUrl": null,
            "startTime": "1544198400",
            "status": "expired",
            "teacherUrl": "https://tutrex.com/board/?token=abcdefgh1234567891",
            "studentUrl": "https://tutrex.com/lessons/abcdef1234568"
        }
    ]
}

Error Response Example:

{
    "status": "error",
    "body": {
        "message": "Invalid data.",
        "errors": {
            "sortBy": "Invalid sort field.",
            "sortDirection": "Invalid sort direction.",
            "limit": "Invalid limit value.",
            "offset": "Invalid offset value."
        }
    }
}

Get Lesson

Method: GET

API Endpoint: /api/v1/lessons/{lessonId}

Success Response Example:

{
    "status": "success",
    "body": {
        "id": 123,
        "title": "Test lesson title",
        "duration": 90,
        "recordUrl": null,
        "startTime": 1545318000,
        "status": "coming",
        "teacherUrl": "https://tutrex.com/board/?token=abcdefgh1234567890",
        "studentUrl": "https://tutrex.com/lessons/abcdef1234567"
    }
}

Error Response Example:

{
    "status": "error",
    "body": {
        "message": "Lesson not found."
    }
}

Update Lesson

Method: POST

API Endpoint: /api/v1/lessons/{lessonId}

JSON Request Parameters:

Parameter Required Type Description Example
startTime No integer Unix timestamp of lesson start time. 1545318000
title No string Lesson title. Test lesson title
duration No integer Lesson duration in minutes. 90
exitLink No string URL for redirection after leaving the lesson. https://google.com
shareLink No string URL for sharing via social networks. https://google.com

Success Response Example:

{
    "status": "success",
    "body": {
        "id": 123,
        "title": "Test lesson title",
        "duration": 90,
        "recordUrl": null,
        "startTime": 1545318000,
        "status": "coming",
        "teacherUrl": "https://tutrex.com/board/?token=abcdefgh1234567890",
        "studentUrl": "https://tutrex.com/lessons/abcdef1234567"
    }
}

Error Response Example:

{
    "status": "error",
    "body": {
        "message": "Invalid data.",
        "errors": {
            "startTime": "Start time should not be in the past.",
            "title": "Title should not be empty.",
            "duration": "Duration should be a valid integer greater than 0."
        }
    }
}

Delete Lesson

Method: DELETE

API Endpoint: /api/v1/lessons/{lessonId}

Success Response Example:

{
    "status": "success",
    "body": null
}

Error Response Example:

{
    "status": "error",
    "body": {
        "message": "Lesson not found."
    }
}