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 Admin, Reading Admin record, Updating Admin records, via third party external application via GET or POST method.

Actions should be passed to the below mentioned URLs:

  • Add / Update Admin Record - https://<your_sub_domain>.classe365.com/rest/admin
  • Read Teacher Records - https://<your_subdomain>.classe365.com/rest/adminsData

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(Admin Attributes)

  • JSON encoded string of Admin fields/attributes and related values - all your data will be converted to JSON objects
  • For update, Admin's ID or Admin's DB ID should be passed in json encoded data string. If Admin's ID is not sent via thrid party application then "a new admin record will be inserted" - To get Admin ID use the API which is to read(get) admin'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.

Follow the below steps to add Admin 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.

These are the mandatory fields in Classe365 to add admin record:
 - Name, Email, Contact, Address

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 Admin's data calling API, please refer the below sample code on how to send data via PHP

Accessing Admin Record

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

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

Parameters to fetch Admin Records

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

1) Filter

  • json encoded string of admin's fields/attributes and related values, for the fields you want to filter by - Example filter by Name
  • e.g:
    [filter] => {"name":"Admin", "email_address":"" ,"contact":"", "main_admin":"0", "address":""}

2) Order

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

3) Page

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

readAdmin.php

<?php 
$adminData = ['name' => 'ClasseAdmin', 'email_address' => '', 'contact' => '' , 'main_admin' => '0', 'address'=>''];
$order = [['sortField' => 'name', 'sortType'=>'ASC']];
$page = ['recordsPerPage'=>'10', 'pageNo'=>'1'];
$requestData = ['filter' => json_encode($adminData), 'order'=>json_encode($order), 'page'=>json_encode($page)];
$httpCodeFor = [204 => 'NO_CONTENT', 401 => 'UNAUTHORIZED', 403 => 'FORBIDDEN', 400 => 'BAD_REQUEST'];      

$api_url = 'https://<your_sub_domain>.classe365.com/rest/adminsData';
$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(json_decode($output, true)); exit;
}
catch (Exception $ex) {
echo $ex->getMessage(); exit;
}
?>

Response Body:

Case 1: Data retrieved successfully

{
"success": 1
"data": [{"id":"2","name":"ClasseAdmin(Sub)","email_address":"admin@classe.com","contact":"9876543210","image":"https://imagelink/image_name.png","main_admin":"0","address":"Address"}]
}

Case 2: Invalid parameters

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


Adding Admin Record

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


addAdmin.php

<?php 
$adminData = ['name' => 'ClasseAdmin', 'email_address' => 'mail@mail.com', 'contact' => '3862', 'address'=>'ad'];
$data['data'] = json_encode($adminData);
$httpCodeFor = [204 => 'NO_CONTENT', 401 => 'UNAUTHORIZED', 403 => 'FORBIDDEN', 400 => 'BAD_REQUEST'];      
$api_url = 'https://<your-sub-domain>.classe365.com/rest/admin';
$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(json_decode($output, true)); exit;
}
catch (Exception $ex) {
echo $ex->getMessage(); exit;
}
?>

Response Body:

Case 1: Admin added/updated successfully

{
"success": 1
}

Case 2: Data validation error

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

Case 3: Invalid value for Profile image

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

Edit Admin Record

To edit/update Admin Record you need to pass - Admin ID, you can get ID using access admin API.

  • e.g: Update admin:[[data] => {"id":"1","name":"classe365","email_address":"mail@mail.com","contact":"3862","address":"ad","image": base64_encoded_string}]

<?php 
$adminData = ["id":"1",'name' => 'Admin', 'email_address' => 'mail@mail.com', 'contact' => '3453862', 'address'=>'adress'];
$data['data'] = json_encode($adminData);
$httpCodeFor = [204 => 'NO_CONTENT', 401 => 'UNAUTHORIZED', 403 => 'FORBIDDEN', 400 => 'BAD_REQUEST'];      
$api_url = 'https://<your_sub_domain>.classe365.com/rest/admin';
$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(json_decode($output, true)); exit;
}
catch (Exception $ex) {
echo $ex->getMessage(); exit;
}
?>


Edit admin records has same response body as Adding Admin Record.

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

Did this answer your question?