eTraining API Documentation

The eTrain API is organized around REST. All the available APIs for getting course tracking, course progress and student information are listed below with the example code and example response for each API. JSON is returned by all API responses, including errors.

Following are the APIs we provide

List Courses

This API can be used to get the list of courses which you have access to view. You need to authorize yourself via API username and password. Details URL and required parameters given below

URL = https://etraintoday.com/wp-json/etrain/v1/course/list

Method = Get

Parameters : All parameters are required and detail of all parameters given below

usernameWeb API username. This will provided by the eTraintoday.
passwordWeb API password. This will provided by the eTraintoday.

Below is the working example of this API integration in PHP.

<?php
$fields = array(
    'username' => 'Put your username value here',
    'password' => 'Put your password value here'
);
$fields_string = '?';

foreach( $fields as $key => $value ) { $fields_string .= $key.'='.$value.'&'; }
rtrim( $fields_string, '&' );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'https://etraintoday.com/wp-json/etrain/v1/course/list' . $fields_string );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'GET' );
$result = curl_exec( $ch );
curl_close( $ch );
?>

Response

The response of the list course API will consists of status code, number of count and data. Data is an array of JSON objects which contains name of course, course id, course status and date of access given. The whole response will be in JSON format.

The example response data given below

{
    "status": 200,
    "count": 2,
    "data": [
      {
        "course_id": "1103",
        "course_name": "Aerial And Lifts",
        "status": "active",
        "access_given": "2018-10-10"
      },
      {
        "course_id": "1101",
        "course_name": "Confined Space",
        "status": "active",
        "access_given": "2018-09-25"
     }
   ]
}

Get User Sessions

This API can be used to get the user course sessions or course tracking from eTraintoday. This API will give you the complete detail of courses taken or assigned to specific user based on user ID (unique ID given by third party at the time of course view, not from eTraintoday. View course integration guide).

URL = https://etraintoday.com/wp-json/etrain/v1/course/usersession

Method = Get

Parameters : All parameters are required and detail of all parameters given below

usernameWeb API username. This will provided by the eTraintoday.
passwordWeb API password . This will provided by the eTraintoday.
user_idUnique user id from third party (not from eTraintoday) given at the time of view course request

Below is the working example of this API integration in PHP.

<?php
$fields = array(
    'username' => 'Put your username value here',
    'password' => 'Put your password value here',
    'user_id'  => 'Unique user id given at the time of course view'
);
$fields_string = '?';

foreach( $fields as $key => $value ) { $fields_string .= $key.'='.$value.'&'; }
rtrim( $fields_string, '&' );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'https://etraintoday.com/wp-json/etrain/v1/course/usersession' . $fields_string );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'GET' );
$result = curl_exec( $ch );
curl_close( $ch );
?>

Response

The response of get user session API will consists of status code, count of total sessions of a student and data. Data is an array of JSON objects which contains information of each course session of given user. Each course session contains vital course tracking information like course start date, end date, course status, exam start and end data and exam status.

JSON object also includes the course percentage which is the percentage of course viewing excluding of exam and certificate number which is the number of certificate generated at the end of successfully passed course. The whole response will be in JSON format.

Below is the example response of get user session API.

Course Status ( CP = Course Completed, IN = In Progress )

Exam Status ( NA = Not Attempted, CP = Course Passed, IN = In Progress, FA = Failed )

{
    "status": 200,
    "session_count": 2,
    "data": [
      {
        "course_id": "1102",
        "course_name": "Electrical Safety Awareness",
        "student_id": "552",
        "student_name": "Jane Doe",
        "course_started": "1539773382",
        "course_finished": "0",
        "course_percent": "0",
        "course_status": "IN",
        "exam_started": "0",
        "exam_finished": "0",
        "exam_status": "NA",
        "cert_number": "N/A"
      },
      {
        "course_id": "1103",
        "course_name": "Aerial And Lifts",
        "student_id": "552",
        "student_name": "Jane Doe",
        "course_started": "1539688642",
        "course_finished": "1539688795",
        "course_percent": "100",
        "course_status": "CP",
        "exam_started": "1539690152",
        "exam_finished": "1539691799",
        "exam_status": "CP",
        "cert_number": "N/A"
      }
    ]
}

Get All Courses Sessions

This API can be used to get all the courses to which credentials bearer (eTraintoday Customer) have access to and list all the course progress sessions by all the users from each of the courses. Details are given below.

URL = https://etraintoday.com/wp-json/etrain/v1/course/sessions

Method = Get

Parameters : All parameters are required and detail of all parameters given below

usernameWeb API username. This will provided by the eTraintoday.
passwordWeb API password. This will provided by the eTraintoday.

Below is the working example of this API integration in PHP.

<?php
$fields = array(
    'username' => 'Put your username value here',
    'password' => 'Put your password value here'
);
$fields_string = '?';

foreach( $fields as $key => $value ) { $fields_string .= $key.'='.$value.'&'; }
rtrim( $fields_string, '&' );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'https://etraintoday.com/wp-json/etrain/v1/course/sessions' . $fields_string );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'GET' );
$result = curl_exec( $ch );
curl_close( $ch );
?>

Response

The response of get all course session will consists of status code and data array. Data array will consists of list of accessible courses and list of course sessions by students for each individual course. Response will be in JSON format.

The example response data given below

{
    "status": 200,
    "data": [
      {
        "course_id": "1103",
        "course_name": "Aerial And Lifts",
        "student_session": [
          {
            "student_id": "412",
            "student_name": "Jake Sully",
            "course_started": "2018-11-07"
          },
          {
            "student_id": "236",
            "student_name": "Jane Doe",
            "course_started": "2018-10-30"
          }
        ]
      },
      {
        "course_id": "1101",
        "course_name": "Confined Space",
        "student_session": [
          {
            "student_id": "786",
            "student_name": "Arthur Richie",
            "course_started": "2018-10-08"
          },
          {
            "student_id": "54654",
            "student_name": "Samantha Hall",
            "course_started": "2018-10-02"
           }
        ]
      },
      {
        "course_id": "1102",
        "course_name": "Electrical Safety Awareness",
        "student_session": [
          {
            "student_id": "412",
            "student_name": "Jake Sully",
            "course_started": "2018-11-19"
          }
        ]
      }
    ]
}

Students List

This API can be used to get the list of students a customer have on eTraintoday. This API will return the ID and name of each of the student come on eTraintoday via course display URL generated for customer using Auth Token.

URL = https://etraintoday.com/wp-json/etrain/v1/course/students

Method = Get

Parameters : All parameters are required and detail of all parameters given below

usernameWeb API username. This will provided by the eTraintoday.
passwordWeb API password. This will provided by the eTraintoday.

Below is the working example of this API integration in PHP.

<?php
$fields = array(
    'username' => 'Put your username value here',
    'password' => 'Put your password value here'
);
$fields_string = '?';

foreach( $fields as $key => $value ) { $fields_string .= $key.'='.$value.'&'; }
rtrim( $fields_string, '&' );
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, 'https://etraintoday.com/wp-json/etrain/v1/course/students' . $fields_string );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, 'GET' );
$result = curl_exec( $ch );
curl_close( $ch );
?>

Response

The response of students list API will consists of status code, count of records returned and data array. Data array contains the list of JSON objects with properties of ID (student id) and student (student name). Response will be in JSON format.

{
    "status": 200,
    "count": 2,
    "data": [
      {
        "ID": "652",
        "student": "Kelly Duff"
      },
      {
        "ID": "854",
        "student": "Jane Doe"
      }
    ]
}

Send us a Message

major credit cards accepted