Welcome to the Classe365 API documentation!

Classe365 API is organized around REST. Our API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. We use built-in HTTP features, like HTTP authentication and HTTP verbs, which are understood by off-the-shelf HTTP clients. We support cross-origin resource sharing, allowing you to interact securely with our API from a client-side web application (though you should never expose your secret API key in any public website's client-side code). JSON is returned by all API responses, including errors, although our API libraries convert responses to appropriate language-specific objects.

This documentation describes all about Adding Teacher, Reading Teacher record, Updating Teacher records, via third party external application via GET or POST method.

Actions should be passed to the below mentioned URLs:

  • Add / Update Teacher Record - https://<your_subdomain>.classe365.com/rest/teacher
  • Read Teacher Records - https://<your_subdomain>.classe365.com/rest/teachersData

Use the below button to download the project which is readily available and working.

Note: Change your subDomain and API Key in the sample project's credentials.php

Tips on Passing Data via API

Data(Teacher Attributes)

  • JSON encoded string of teacher fields/attributes and related values - all your data will be converted to JSON objects
  • For update, Teacher's ID or Teacher's DB ID should be passed in json encoded data string. If Teacher's ID is not sent via thrid party application then "a new teacher record will be inserted" - To get Teacher ID use the API which is to read(get) teacher's records.
  • For profile_image field, base64 encoded string of related image should be passed - images needs to be encrypted with base64 encode and the result string can be passed. Here is a platform which encrypts image online.
  • All date values should be passed in Y-m-d format - teacher attributes which are validated as Date type should be passed in Y-m-d format, yyyy-mm-dd. Example: 2011-12-16

To insert teacher record via third party API you, need to pass the JSON Objects to the URL - https://<your_subdomain>.classe365.com/rest/teacher, with your API Key and subDomain in the request headers.

Follow the below steps to add Teacher Record via third party application:

Step-1: Know your Parameters

Before sending data calling API you first need to know the parameters to which you will be passing the data.

Login to Classe365 account as an admin and check all the validated fields which are often validated to be required with red coloured asterisk(*), those fields are mandatory.

Keep a note on date type fields as well, since you need to send in Y-m-d format.

Step-2: Access the API Key from Classe365 Account

Please refer the below attached documentation link to know how to generate API key

Step-3: Pass data

Pass teacher's data calling API, please refer the below sample code on how to send data via PHP

Accessing Teacher Records

To Get teacher records, you can use GET or POST Methods, and pass the data to the below URL: 

https://<your_subDomain>.classe365.com/rest/teachersData

Parameters to fetch Teacher Records

Third-party application can also pass the below parameters while fetching teacher records

1) Filter

  • json encoded string of Teachers fields/attributes and related values, for the fields you want to filter by - Example filter by Teacher ID
  • All date values should be passed in Y-m-d format and with range structure for e.g. value for 1st Dec 2018 - "2018-12-01 to 2014-12-01" and value for 1st Dec 2018 to 10th Dec 2018 = "2018-12-01 to 2018-12-10"
  • e.g:
    [filter] =>{"id":6,"first_name":"Classe","last_name":"Developer","teacher_dob":"1992-06-07","teacher_email":"","gender":"","teacher_contact":""}

2) Order

  • Pass field name and order type; Ascending - ASC and Descending - DESC
  • e.g:
     [order] => [{"sortField":"first_name","sortType":"DESC"},{"sortField":"last_name","sortType":"DESC"}]

3) Page

  • Pass records per page value and page number
  • e.g:
    [page] => {"recordsPerPage":"3","pageNo":"1"}


readTeachers.php

<?php 
$teacherData = ['id'=>6, 'first_name' => 'Classe', 'last_name' => '', 'teacher_dob'=>'1992-06-07', 'teacher_email' => '', 'gender'=>'','teacher_contact' => ''];
$order = [['sortField' => 'first_name', 'sortType'=>'DESC'], ['sortField' => 'last_name', 'sortType'=>'DESC']];
$page = ['recordsPerPage'=>'3', 'pageNo'=>'1'];
$requestData = ['filter' => json_encode($teacherData), 'order'=>json_encode($order), 'page'=>json_encode($page)];
print_r($requestData);
$httpCodeFor = [204 => 'NO_CONTENT', 401 => 'UNAUTHORIZED', 403 => 'FORBIDDEN', 400 => 'BAD_REQUEST'];      

$api_url = 'http://subDomain.classe365.com/classe365/rest/teachersData';
$domainName = "YOUR_SUB_DOMAIN"; // tenent name
$api_key = 'Your_API_KEY';
 
try{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $domainName.":".$api_key);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestData);
$output = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);  
if($httpCode != 200){
echo $httpCodeFor[$httpCode];
}
echo '<pre>'; print_r($output);
echo '<pre>'; print_r(json_decode($output, true)); exit;
}
catch (Exception $ex) {
echo $ex->getMessage(); exit;
}
//{"success":1, "data":[{"id":"6", "first_name":"Classe", "last_name":"Teacher", "teacher_id":"2016_2_api", "address":null, "teacher_contact":"123456789", "teacher_email":"teacher@gmail.com", "image":"64Base Code Image", "designation":null, "qualification":null, "teacher_dob":"1992-06-07", "gender":"Male", "father_name":null, "mother_name":null, "blood_group":null, "health_date":null, "height":null, "weight":null, "is_academic":"1", "text_20":"Test", "teacher_name":"Classe Teacher", "country":"Country Name"}]}
?>

Responses:

Case 1: Data retrieved successfully

{
"success": 1
"data": [{"id":"6","first_name":"Classe","last_name":"Teacher","teacher_id":"2016_2_api","address":null,"zipcode":null,"state":null,"aadhar_uid":null,"teacher_contact":"123456789","teacher_email":"teacher@gmail.com","image":"64Bit Image Code","designation":null,"qualification":null,"teacher_dob":"1992-06-07","age":null,"gender":"Male","father_name":null,"mother_name":null,"blood_group":null,"health_date":null,"height":null,"weight":null,"body_mass_index":null,"profile_summary":null,"fb_profile_link":null,"linkedin_profile_link":null,"is_academic":"1","text_20":"Test","teacher_name":"Classe Teacher","country":""}]
}

Case 2: Invalid parameters

{
"success": 0,
"error": "invalid_parameters",
}

Adding Teacher Record

E.g. php code to call this api through curl   

insertTeacher.php

<?php 
/* image convert into base64_encode string and passed in api */
$image_data = '64BIT ENCODED IMAGE STRING';
$teacherData = ['teacher_id' => '2017_1_api', 'first_name' => 'Classe', 'last_name' => 'Teacher', 'teacher_dob'=>'1992-06-07', 'teacher_email' => 'teacher@classe365.com', 'gender'=>'Male','teacher_contact' => '1234567890', 'is_academic'=>1, 'image' => $image_data, 'text_20'=>'Test'];
$data = [];
$data['data'] = json_encode($teacherData);
$httpCodeFor = [204 => 'NO_CONTENT', 401 => 'UNAUTHORIZED', 403 => 'FORBIDDEN', 400 => 'BAD_REQUEST'];      
// For local Key
$api_url = 'https://<your_sub_domain>.classe365.com/rest/teacher';
$domainName = "YOUR_SUB_DOMAIN"; // tenent name
$api_key = 'Your_API_Key';
try{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $domainName.":".$api_key);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
$output = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);  
if($httpCode != 200){
echo $httpCodeFor[$httpCode];
}
echo '<pre>'; print_r($output); exit;
}
catch (Exception $ex) {
echo $ex->getMessage(); exit;
}
?>

Note: We're using 'teacher_id' to insert the teacher record! Teacher has another ID value which teacher Database ID used to update teacher record.

Response Body:

Case 1: Teachers added/updated successfully

{
"success": 1
}

Case 2: Invalid Teacher id

{
"success": 0,
"error": "invalid_id",
}

Case 3: Data validation error

{
"success": 0,
"error": "field_validations",
"field_validations":  {
        "field_id": required,
        "field_id": email,
        "field_id": date,
        "field_id": unique,
        }
}

Case 4: Invalid value for Profile image

{
"success": 0,
"error": "binary_to_image_convert",
}

Edit Teacher Record

To edit teacher Record you need to pass - Teacher Database ID(Teacher DB ID), you'll get this ID on accessing teacher records using Acess record API

<?php 
/* image convert into base64_encode string and passed in api */
$image_data = '64BIT ENCODED IMAGE STRING';
$teacherData = ['id' => '1', 'teacher_id' => '2018_TCH_001', 'first_name' => 'Classe', 'last_name' => 'Teacher', 'teacher_dob'=>'1992-06-07', 'teacher_email' => 'teacher@classe365.com', 'gender'=>'Male','teacher_contact' => '1234567890', 'is_academic'=>1, 'image' => $image_data, 'text_20'=>'Test'];

/* Note: teacher_id is the unique ID but "id" is the database ID */

$data = [];
$data['data'] = json_encode($teacherData);
$httpCodeFor = [204 => 'NO_CONTENT', 401 => 'UNAUTHORIZED', 403 => 'FORBIDDEN', 400 => 'BAD_REQUEST'];      
// For local Key
$api_url = 'https://<your_sub_domain>.classe365.com/rest/teacher';
$domainName = "YOUR_SUB_DOMAIN"; // tenent name
$api_key = 'Your_API_Key';
try{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $domainName.":".$api_key);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
$output = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);  
if($httpCode != 200){
echo $httpCodeFor[$httpCode];
}
echo '<pre>'; print_r($output); exit;
}
catch (Exception $ex) {
echo $ex->getMessage(); exit;
}
?>


Responses

Invalid Teacher DB ID

{
"success": 0,
"error": "invalid_id",
}

If you need any help write us to support@classe365.com :-)

Did this answer your question?