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 a student via third party external application via GET or POST method, and action should be sent to the URL-https://{subdomainName}.classe365.com/rest/student

Note: subDomainName is the unique reference to access your organization, example: https://demo.classe365.com/rest/student

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

Tips on Passing Data via API

Data(Student Attributes)

  • JSON encoded string of student fields/attributes and related values -  all your data will be converted to JSON objects
  • For class_id and section_id fields, class name and section name should be passed - class name and section name must be passed and should be of the exact match, sometimes if your class name has space please double check if the system predicts that as  
  • 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 - student attributes which are validated as Date type should be passed in Y-m-d format, yyyy-mm-dd. Example: 2011-12-16

Attachments (optional)

  • JSON encoded string of attachment files
  • Each attachment should have following attributes
    -
    title - Attachment Name/Title
    - description (optional) - Short description of the attachment
    - file_type - Extension of attachment file
    - file - base64 encoded string of attachment file

Elective_subject_ids (optional)

  • Pass the ids of elective subjects in comma separated string format.

How to get Academics Data or Subject ID?

Method-1: Use API with GET Method to access the Academics Structure

<?php 
$api_url= 'https://{subdomainName}.classe365.com/rest/getAcademicDataForParticular?type={type}&id={id}';
//example : https://demo.classe365.com/rest/getAcademicDataForParticular?type=subject&id=617;
$httpCodeFor=[204=>'NO_CONTENT',401=>'UNAUTHORIZED',403=>'FORBIDDEN',400=>'BAD_REQUEST'];      
$domainName= "{subdomainName}";
$api_key ='{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);
}
catch (Exception $ex) {
echo $ex->getMessage(); exit;
}

?>

Method-2: Use Browser's Inspect 

To get Elective subject ID's go to the portal and using Browser Inspector, Inspect on Elective Subject Name


There you will get data-id which is the elective subject ID

Follow the below steps to add Students 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 students data calling API, please refer the below sample code on how to send data via PHP

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

<?php

if(isset($_POST))
{
$fname = "Classe";// $_POST['fname'];
$lname = "Developer";//$_POST['lname'];
$admns = "2018_1_api";//$_POST['admsn'];
$classs = "Grade-1"; //$_POST['classs'];
$section ="Semester 1";// $_POST['section'];

$applicationData=['class_id'=> $classs,'section_id'=>$section, 'first_name' => $fname, 'last_name' => $lname, 'admission_number'=> $admns];  

/*
Example
$applicationData= ["class_id"=>"Grade 1","section_id"=>"Division A","admission_number"=>"2016_1_api","first_name"=>"Classe","last_name"=>"Developer","student_dob"=>"2000-05-08","student_email"=>"ggpatel77@gmail.com","contact"=>"123123123","image"=> base64_encoded_string,
[attachments] => [{"title"=>"Attachment 1","description"=>"Test Attachment Upload using API","file_type"=>"pdf","file"=>base64_encoded_string}],
[elective_subject_ids] => '6,8,12,26' ]]

*/

$data=[];
$data['data']=json_encode($applicationData);
$apiUrl='https://demo.classe365.com/rest/student/';
$domainName="demo";
$apiKey='<YOUR_API_KEY>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $domainName.":".$apiKey);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
$output = curl_exec($ch);
curl_close($ch);
        echo '<pre>'; print_r($output);

}

else {
echo "Error";
}



?>

Responses:

Case 1: Student added successfully

{
"success": 1
}

Case 2: Data validation error

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

Case 3: Invalid elective subjects

{
"success": 0,
"error": "invalid_elective_subject_ids",
"field_validations":  {
        "elective_subject_ids": invalid,
        }
}

Subject Type not Elective

{
"success": 0,
"error": "invalid_elective_subject_ids",
"field_validations":  {
        "elective_subject_ids": is_not_elective,
}
}

Elective Subject Student Limit Reached

{
"success": 0,
"error": "invalid_elective_subject_ids",
"field_validations":  {
        "elective_subject_ids": student_limit_reach,
}
}

Case 4: Student limit crosses for class/section/system

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

Case 5: Invalid value for Profile image

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

Case 6: Invalid value for Attachments

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

If you need any help on this please write us to support@classe365.com

Did this answer your question?