# API - Listing ## Deployment https://api-elabskiit.herokuapp.com/ ## APIs - <strong>POST `/course/new` - Add new Course<br></strong> <strong>Schema</strong><br> ```javascript { name : __NAME_OF_THE_COURSE__, desc : __DESCRIPTION_ABOUT_THE_COURSE__, totalSeats : __SEATS_IN_TOTAL__, year : __YEAR_FOR_THE_COURSE__ } ``` <strong>Status codes and errors</strong> - 201 - Data saved - 500 - Database unresponsive <br> ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` - 406 - Data invalid/incorrect ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, } ``` <strong>Special Notes</strong><br> - `year` should be greater than present year - `totalSeats` should be greater than 0 (zero) - There should not be any empty field <strong>Example</strong><br> Request ```json { "name": "Cloud", "desc": "Cloud Computing", "totalSeats": 100, "year": 2021 } ``` Return ```json { "data": { "totalSeats": 100, "presentSeats": 100, "year": "2021", "classes": [], "_id": "60d33d0e577a0e46141e5276", "name": "Cloud", "desc": "Cloud Computing", "__v": 0 } } ``` - <strong>GET `/course` - Get all courses<br></strong> <strong>Special Notes</strong><br> - Query can be added too - `/course?year=__YEAR__` - to retrive all the courses of a particular year <strong>Status codes and errors</strong> - 200 - OK (Data recieved) ```javascript { courses:[{ { __course1_details__ }, { __course2_details__ } }] } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` <strong>Example</strong><br> Request GET `/course?year=2021` Result ```json { "courses": [ { "totalSeats": 100, "presentSeats": 97, "year": "2021", "classes": [ "60d2d56f7b88912ae46d51db" ], "_id": "60d2d0727b88912ae46d51af", "name": "AR", "desc": "Argumentive Reality", "__v": 0 }, { __COURSE_2_DETAILS__ } ... ] } ``` - <strong>GET `/course/:courseid` - Get the particular courses<br></strong> <strong>Special Notes</strong><br> - `courseid` param should be a valid courseId <strong>Status codes and errors</strong> - 200 - OK (data recieved) ```javascript { course: { __COURSE_DETAILS__ } } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` <strong>Example</strong><br> Request GET `/course/60d2d0727b88912ae46d51af` Return ```json { "course": { "totalSeats": 100, "presentSeats": 97, "year": "2021", "classes": ["60d2d56f7b88912ae46d51db"], "_id": "60d2d0727b88912ae46d51af", "name": "AR", "desc": "Argumentive Reality", "__v": 0 } } ``` - <strong>POST `/team/new` - Add new Member<br></strong> <strong>Schema</strong><br> ```javascript { name : __MEMBER_NAME__, domain : __MEMBER_DOMAIN__, isActive : __ACTIVE_OR_ALUMNI__, photo : __PHOTO_URL__, email : __EMAIL_ID__, github : __GITHUB_PROFILE_LINK__, linkedin : __LINKEDIN_PROFILE_LINK__, testimonial : __ALUMNI_EXPERIENCE__ } ``` <strong>Special Notes</strong><br> - `name, domain, isActive, photo ,email` are mandatory fields - `github, linkedin, testimonial` are optional - `email` should be a kiit email - `photo` is an URL from firebase <strong>Status codes and errors</strong> - 201 - Data saved successfully ```javascript { data: { __DETAILS_SAVED__ } } ``` - 406 - Invalid/incorrect data and/or email not kiit email ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` <strong>Example</strong><br> Request POST `/team/new` ```json { "name": "Avi Mishra", "domain": "App Development", "isActive": true, "photo": "https://firebasestorage.googleapis.com/v0/b/e-labs-550aa.appspot.com/o/team%2F01_avi.jpg?alt=media&token=2e8b6851-373f-46f0-9dd6-ba8e6aa7d79d", "email": "1828058@kiit.ac.in", "linkedin": "https://in.linkedin.com/in/avimishra18" } ``` Return ```json { "data": { "_id": "60d42544e3dd241f3c2637cf", "name": "Avi Mishra", "domain": "App Development", "photo": "https://firebasestorage.googleapis.com/v0/b/e-labs-550aa.appspot.com/o/team%2F01_avi.jpg?alt=media&token=2e8b6851-373f-46f0-9dd6-ba8e6aa7d79d", "email": "1828058@kiit.ac.in", "isActive": true, "linkedin": "https://in.linkedin.com/in/avimishra18", "__v": 0 } } ``` - <strong>GET `/team` - Get all members<br></strong> <strong>Special Notes</strong><br> - Queries can be added - `/team?domain=__DOMAIN_NAME__` - to get all the members of a particular domain (Regular expression is allowed) - `/team?name=__MEMBER_NAME__` - to get the particular member (Regular expression is allowed) - `/team?roll=__MEMBER_ROLL__` - to get the particular member (only the roll number and Regular expression is allowed) <strong>Status codes and errors</strong> - 200 - OK (Data recieved) ```javascript { data: [ { __MEMBER_1__ }, { __MEMBER_2__ }, ... ] } ``` - 404 - Member not found ```javascript { error: 'no members found', errorOccured: 'memebers', } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` <strong>Example</strong><br> Request GET `/team` Return ```json { "data": [ { "_id": "60d42544e3dd241f3c2637cf", "name": "Avi Mishra", "domain": "App Development", "photo": "https://firebasestorage.googleapis.com/v0/b/e-labs-550aa.appspot.com/o/team%2F01_avi.jpg?alt=media&token=2e8b6851-373f-46f0-9dd6-ba8e6aa7d79d", "email": "1828058@kiit.ac.in", "isActive": true, "linkedin": "https://in.linkedin.com/in/avimishra18", "__v": 0 }, ... ] } ``` - <strong>PATCH `/team/:memberid` - Update a team member details<br></strong> <strong>Schema</strong><br> ```javascript { name : __MEMBER_NAME__, domain : __MEMBER_DOMAIN__, isActive : __ACTIVE_OR_ALUMNI__, photo : __PHOTO_URL__, email : __EMAIL_ID__, github : __GITHUB_PROFILE_LINK__, linkedin : __LINKEDIN_PROFILE_LINK__, testimonial : __ALUMNI_EXPERIENCE__ } ``` <strong>Special Notes</strong><br> - can contain all the above mentioned fields or just the required fields <strong>Status codes and errors</strong> - 201 - Updated successfully ```javascript { isUpdated: true } ``` - 406 - email not valid, not a kiit email id ```javascript { error: `email invalid, not a kiit email`, errorOccured: `email`, } ``` - 404 - Member not found ```javascript { error: 'member not found', errorOccured: 'member', } ``` - Member could not be updated ```javascript { error: 'member could not be updated', errorOccured: 'error', } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` - <strong>POST `/login` - Check the deviceId and roll<br></strong> <strong>Schema</strong><br> ```javascript { roll: __ROLL_NUMBER__, deviceId : __DEVICEID__ } ``` <strong>Status codes and errors</strong> - 200 - OK (Login successful) ```javascript { data: true } ``` - 406 - Roll number is invalid (Not kiit roll number) ```javascript { error: `roll invalid`, errorOccured: `roll`, } ``` - 404 - Roll number not found or DeviceId not registered ```javascript { error: `roll not found`, errorOccured: `roll`, } ``` ```javascript { error: 'device not registered', errorOccured: 'device', } ``` - 401 - DeviceId not a match ```javascript { data: false, error: 'deviceid not a match', errorOccured: 'deviceid' } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` - <strong>GET `/login/:deviceid` - to check whether</strong><br> <strong>Special Notes</strong><br> - `deviceid` is the parameter - 200 status returns data in the form of array of objects <strong>Status codes and errors</strong> - 200 - (OK) ```javascript { data: [__DETAILS_OF_THE_USER_WITH_THAT_ROLL__] } ``` - 404 - deviceId not registered/ deviceId not found ```javascript { error: 'device not registered', errorOccured: 'device', } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` - <strong>POST `/device` - Register the deviceId and roll<br></strong> <strong>Schema</strong><br> ```javascript { roll: __ROLL_NUMBER__, deviceId : __DEVICEID__ } ``` <strong>Status codes and errors</strong> - 201 -OK (Data saved successfully) ```javascript { data: [__DETAILS_OF_THE_USER_WITH_THAT_ROLL__] } ``` - 406 - Roll number not correct or Kiit roll number not added ```javascript { error: `roll not correct`, errorOccured: `roll`, } ``` - Roll number or deviceId not entered (undefined) ```javascript { error: `__ROLL/DEVICID__ invalid`, errorOccured: `__ROLL/DEVICID__ `, } ``` - Device already registered ```javascript { error: 'device already registered', errorOccured: 'device', } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` - <strong>GET `/user/roll/:roll` - Get the user with roll<br></strong> <strong>Special Notes</strong><br> - `:roll` - roll number parameter to enter a valid kiit roll number - Query can be added - `semester` can be added Example : `/user/roll/1928056?semester=3rd` <strong>Status codes and errors</strong> - 200 - User found ```javascript { data: { _USER_DATA__ } } ``` - 404 - User account not found ```javascript { error: 'account not found', errorOccured: 'account', } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` <strong>Example</strong><br> Request GET `/user/roll/1928087` Return ```json { "data": [ { "presentClasses": [], "_id": "60d2d35c7b88912ae46d51cd", "roll": "1928087", "name": "Stefan Salvatore", "semester": "3rd", "contact": "6690340023", "gender": "Male", "branch": "CSSE", "course": "60d2d1127b88912ae46d51b1", "__v": 0 } ] } ``` - <strong>GET `/user/id/:userId` - Get the student with that userId<br></strong> <strong>Special Notes</strong><br> - `:userId` is a parameter for UserId <strong>Status codes and errors</strong> - 200 - User found ```javascript { data: { _USER_DATA__ } } ``` - 404 - User account not found ```javascript { error: 'account not found', errorOccured: 'account', } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` <strong>Example</strong><br> Request GET `/user/id/60d2d35c7b88912ae46d51cd` Return ```json { "data": [ { "presentClasses": [], "_id": "60d2d35c7b88912ae46d51cd", "roll": "1928087", "name": "Stefan Salvatore", "semester": "3rd", "contact": "6690340023", "gender": "Male", "branch": "CSSE", "course": "60d2d1127b88912ae46d51b1", "__v": 0 } ] } ``` - <strong>POST `/class/create` - Create a new class<br></strong> <strong>Schema</strong><br> ```javascript { courseId: __COURSE_ID__ } ``` <strong>Special Notes</strong><br> - `courseId` must be defined in the body <strong>Status codes and errors</strong> - 200 - OK (class created) ```javascript { data: { __SAVED_DATA__ } } ``` - 406 - CourseId not entered ```javascript { error: 'courseId not entered', errorOccured: 'courseId', } ``` - 404 - Course not found ```javascript { error: 'course not found', errorOccured: 'course', } ``` - No users under that course ```javascript { error: 'no users found', errorOccured: 'users', } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` - <strong>DELETE `/class/:classid` - Delete class<br></strong> <strong>Special Notes</strong><br> - `:classid` : classid must be valid <strong>Status codes and errors</strong> - 200 - OK (class deleted) ```javascript { data: 'deleted', studentUpdate: __OUTCOME__, } ``` - 404 - Class not found ```javascript { error: 'Class not found', errorOccured: 'class', } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` - <strong>POST `/register` - registration<br></strong> <strong>Schema</strong><br> ```javascript { roll: __ROLL__, name: __NAME__, semester: __SEMESTER__, contact: __CONTACT___, gender: __GENDER__, branch: __BRANCH__, course: __COURSEID__, } ``` <strong>Special Notes</strong><br> - `roll` should be valid kiit roll number - valid `semesters` are `1st, 2nd, 3rd, 4th, 5th, 6th, 7th, 8th` (case sensitive) - valid `gender` are `Male, Female, Others` (case sensitive) - `contact` number is 10-digit mobile number - valid `branch` are `ETC, EEE, EE, ECS, EI, MECHANICAL, CIVIL, CS, IT, CSSE, CSCE,` - `course` is courseID and should be obtained from get request for courses - No need for precheck for seats left. This endpoint returns an error (discussed below) if there is no seat left for the selected course <strong>Status codes and errors</strong> - 201 - Data added succesfully (user added) ```javascript { data: { __DATA_SAVED__ } } ``` - 406 - Data invalid or not entered ```javascript { error: '__ERROR__ invalid' errorOccured: '__ERROR__' } ``` - Data not entered according to validation ```javascript { error: '__ERROR__ not correct' errorOccured: '__ERROR__' } ``` - 409 - Account already present ```javascript { error: 'account already registered', errorOccured: 'account', } ``` - 402 - Seat are full for that course ```javascript { error: 'seats full for selected course', errorOccured: 'seats', } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ``` - <strong>POST `/attendance` - Mark Attendance<br></strong> <strong>Schema</strong><br> ```javascript { attendance: [ { classId: __CLASS_ID__, studentId: __STUDENT_ID__, }, { classId: __CLASS_ID, studentId : __STUDENT_ID__ }, ... ] } ``` <strong>Special Notes</strong><br> - `attendance` is an array of object containing classId and studentId. Even if there is only one attendance to mark it should be passed in an array. <br> Example ```javascript { attendance: [ { classId: __CLASS_ID, studentId: __STUDENT_ID__, }, ] } ``` <strong>Status codes and errors</strong> - 201 - Marked (details of each student can be of any form discussed below) ```javascript { data: [ { studentId: __USER_ID__, classId: __CLASS_ID__, isAttendanceGiven: false, error: 'class not found', }, { studentId: __USER_ID__ , classId: __CLASS_ID__, isAttendanceGiven: false, error: 'student already marked as present', }, { studentId: __USER_ID__, classId: __CLASS_ID__, isAttendanceGiven: false, error: 'student not found', }, { studentId: __USER_ID__, classId: __CLASS_ID__, isAttendanceGiven: false, error: 'student account error', }, { studentId: __USER_ID__, classId: __CLASS_ID__, isAttendanceGiven: true, }, ... ] } ``` - 500 - Database Unresponsive (No data) ```javascript { error : __ERROR_DESC__, errorOccured: __ERROR_OCCURED_AT__, errorMessage : __DETAILED_ERROR_REPORT__ } ```