Want create site? Find Free WordPress Themes and plugins.

How do APIs work in practice?

An Application Programming Interface (API) helps organisations in seamlessly integrating the LMS with enterprise applications for information sharing and managing various functions with ease.

What’s more, APIs are technology independent – so you can use any programming language or framework to integrate your system or application with Abara.

What is REST API?

As per Wikipedia, Representational State Transfer (REST) is the software architectural style of the World Wide Web. The purpose of REST architecture is to induce Performance, Scalability, Simplicity, Modifiability, Visibility, Portability, and Reliability. It is often preferred over the more heavyweight SOAP (Simple Object Access Protocol) style because REST does not leverage as much bandwidth, which makes it a better fit for use over the Internet. When web services use REST architecture, they are called RESTful APIs (Application Programming Interfaces) or REST APIs.

API Authentication

Abara APIs use the OAuth 2.0 framework in most third-party scenarios, including authentication and authorization for web servers, installed and client-side applications.

OAuth 2.0 client credentials can be obtained on the Abara API and SSO App settings page. Your client application will request an access token from the LMS, extract a token from the response and send it to each REST API that you’d like to access.

Basic steps

1. Obtain OAuth 2.0 credentials from the Abara API Settings page

Create a new OAuth 2.0 application with a Client ID and Client Secret that are known to both Abara LMS and your application. The values vary depending on the type of application. For example, a JavaScript application does not require a Client Secret, but a web server application does.

2. Set up your application

If you have a valid Client ID (and a Client Secret, optional), you can set up your application to use the proper OAuth 2.0 endpoints:
– “Token Endpoint” : http(s):///oauth2/token
Abara supports two OAuth 2.0 authorization grants (resource owner password credentials and client credentials) to enable our APIs in several types of clients and scenarios.

3. Obtain an access token

Before the application can access private LMS data with a Abara API, it must obtain an access token that grants access to that API. A single access token can access multiple APIs — the “scope” parameter controls the set of resources and operations that an access token permits. Your application will send the “API” value in the scope parameter during the access-token request to use the Abara RESTful APIs.

4. Send the access token to an API

After obtaining an access token, an application sends the token to every Abara API in the HTTP Authorization header as follows:

GET /api/ HTTP/1.1
Host:
Authorization: Bearer

5. Refresh the access token, if necessary

Since tokens have limited lifespans, your application can obtain a fresh token using the “Token Endpoint” if it needs to access a Abara API beyond the life of a single access token. A refresh token allows your application to obtain new access tokens.

6. How REST API are implemented in Abara

Abara doesn’t implement a strictly RESTful paradigm, but one that is more “REST-like,” since it supports either stateless connection or stateful (depending on the Abara configuration). In order to call a Abara API you will need to add the method url to the standard platform url, like this:
http:///api//

Users API

Get Custom field list [GET /user/fields]

Get details of all the custom fields for creating or updating a user.

  • Response 200 (application/json)
    • Body
      {
          "data": [
              {
                  "id": "integer",
                  "name": "string",
                  "field_name": "string",
                  "is_mandatory": "boolean",
                  "language": "string"
              }
          ]
      }
      

Get Branch list [GET /user/listBranches]

Get details of all the branches for creating or updating a user.

  • Response 200 (application/json)
    • Body
      {
          "data": [
              {
                  "branch_id": "integer",
                  "name": "string",
                  "logo": "url"
              }
          ],
          "meta": {
              "pagination": {
                  "total": "integer",
                  "count": "integer",
                  "per_page": "integer",
                  "current_page": "integer",
                  "total_pages": "integer",
                  "links": {
                      "previous": "url",
                      "next": "url"
                  }
              }
          }
      }
      

Check Username [POST /user/checkUsername]

Checks if a user exists by its username or email address.

  • Parameters
    • username: (string, required) – Username/Email address of the user
  • Response 200 (application/json)
    • Body
      {
          "user_id": "interger",
          "username": "string",
          "first_name": "string",
          "last_name": "string"
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "User Not Found",
          "status_code": 201
      }
      
  • Response 422 (application/json)
    • Body
      {
          "message": "Unable to check username.",
          "errors": {
              "username": [
                  "Please enter your username."
              ]
          }
      }
      

Create User [POST /user/createUser]

Creates a new user with the provided account information.

  • Parameters
    • username: (string, required) – Username/Email of learner
    • first_name: (string, required) – Learner first name
    • last_name: (string, required) – Learner last name
    • branch_id: (integer, required) – Learner branch
    • phone: (number, optional) – Phone number of learner
    • city: (string, optional) – City of learner
    • state: (string, optional) – State of learner
    • country: (string, optional) – Country of learner
    • user_type: (string, required) – 0 – learner / 1 – Line Manager
    • ext_user_id: (string, optional) – External application user id
    • ext_user_type: (string, optional) – External application name
    • custom_field_name: (string, optional) – Use ‘field_name’ of custom field as parameter name. Depending on the type, a custom field might be mandatory or optional with a defined field type.
  • Response 200 (application/json)
    • Body
      {
          "message": "User created successfully.",
          "status_code": 200
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "Error while creating user.",
          "status_code": 201
      }
      
  • Response 422 (application/json)
    • Body
      {
          "username": [
              "Please enter your username.",
              "Username can contain only a-z, 0-9, _ . @",
              "Length of username should at least be 6.",
              "Someone's already using that username."
          ],
          "first_name": [
              "Please enter your first name.",
              "First Name cannot contain a comma (,)."
          ],
          "last_name": [
              "Please enter your last name.",
              "Last Name cannot contain a comma (,)."
          ],
          "phone": [
              "Please enter a valid phone number. Phone Number can contain only 0-9."
          ],
          "branch_id": [
              "Please enter your branch id.",
              "Please enter valid branch id."
          ],
          "user_type": [
              "Please enter your user type.",
              "Please enter valid user type."
          ],
          "city": [
              "City cannot contain a comma (,)."
          ],
          "state": [
              "State cannot contain a comma (,)."
          ],
          "country": [
              "Country cannot contain a comma (,)."
          ]
      }
      

Update User [POST /user/updateUser]

Updates an existing user with the provided account information.

  • Parameters
    • user_id: (integer, required) – Internal abara user id
    • password: (string, optional) – User new password
    • first_name: (string, optional) – Learner first name
    • last_name: (string, optional) – Learner last name
    • branch_id: (integer, optional) – Learner branch
    • phone: (number, optional) – Phone number of learner
    • city: (string, optional) – City of learner
    • state: (string, optional) – State of learner
    • country: (string, optional) – Country of learner
    • ext_user_id: (string, optional) – External application user id
    • ext_user_type: (string, optional) – External application name
    • custom_field_name: (string, optional) – Use ‘field_name’ of custom field as parameter name. Depending on the type, a custom field might be mandatory or optional with a defined field type.
  • Response 200 (application/json)
    • Body
      {
          "message": "User updated successfully.",
          "status_code": 200
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "Branch cannot be updated as there are pending course requests with the Line Manager.",
          "status_code": 201
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "Error while updating user.",
          "status_code": 201
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "You cannot edit an Admin user.",
          "status_code": 201
      }
      
  • Response 422 (application/json)
    • Body
      {
          "message": "Unable to update user information.",
          "errors": {
              "username": [
                  "Please enter your username.",
                  "Username can contain only a-z, 0-9, _ . @",
                  "Length of username should at least be 6.",
                  "Someone's already using that username."
              ],
              "first_name": [
                  "Please enter your first name.",
                  "First Name cannot contain a comma (,)."
              ],
              "last_name": [
                  "Please enter your last name.",
                  "Last Name cannot contain a comma (,)."
              ],
              "phone": [
                  "Please enter a valid phone number. Phone Number can contain only 0-9."
              ],
              "branch_id": [
                  "Please enter valid branch id."
              ],
              "city": [
                  "City cannot contain a comma (,)."
              ],
              "state": [
                  "State cannot contain a comma (,)."
              ],
              "country": [
                  "Country cannot contain a comma (,)."
              ]
          }
      }
      

List User [POST /user/listUsers]

Retrieves a list of all users in the system.

  • Parameters
    • limit: (integer, optional) – Total number of records per page
      • Default: 10
    • page: (integer, optional) – Page Number
      • Default: 1
  • Response 200 (application/json)
    • Body
      {
          "data": [
              {
                  "user_id": "integer",
                  "username": "string",
                  "first_name": "string",
                  "last_name": "string",
                  "branch": "string",
                  "phone": "string",
                  "country": "string",
                  "state": "string",
                  "city": "string",
                  "profile_pic": "url",
                  "is_active": "boolean",
                  "learnerCustomFields": {
                      "data": [
                          {
                              "field_name": "string"
                          }
                      ]
                  }
              }
          ],
          "meta": {
              "pagination": {
                  "total": "integer",
                  "count": "integer",
                  "per_page": "integer",
                  "current_page": "integer",
                  "total_pages": "integer",
                  "links": {
                      "previous": "url",
                      "next": "url"
                  }
              }
          }
      }
      

Delete User [POST /user/deleteUser]

Deletes an user.

  • Parameters
    • user_id: (integer, required) – Internal abara user id
  • Response 200 (application/json)
    • Body
      {
          "message": "User deleted successfully.",
          "status_code": 200
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "User Not Found",
          "status_code": 201
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "You cannot delete an Admin user.",
          "status_code": 201
      }
      
  • Response 422 (application/json)
    • Body
      {
          "message": "Unable to delete user.",
          "errors": {
              "user_id": [
                  "Please enter your user id."
              ]
          }
      }
      

Course API

List Courses [POST /course/listCourses]

Retrieves a list of all courses in the system.

  • Parameters
    • limit: (integer, optional) – Total number of records per page
      • Default: 10
    • page: (integer, optional) – Page Number
      • Default: 1
  • Response 200 (application/json)
    • Body
      {
          "data": [
              {
                  "course_id": "integer",
                  "name": "string",
                  "description": "string",
                  "course_code": "string",
                  "course_type": "integer",
                  "course_category_id": "integer",
                  "course_category": "string",
                  "course_thumb": "url",
                  "demo_material": "url",
                  "sellable": "boolean",
                  "price": "float",
                  "enrollment_policy": "integer",
                  "subscription_start_date": "date",
                  "subscription_end_date": "date",
                  "course_start_date": "date",
                  "course_end_date": "date",
                  "course_duration": "integer",
                  "is_active": "boolean",
                  "course_links": {
                      "iframe": "string",
                      "link": "string"
                  },
                  "classroomSessions": {
                      "data": [
                          {
                              "session_id": "integer",
                              "name": "string",
                              "description": "string",
                              "subscription_start_date": "date",
                              "subscription_end_date": "date",
                              "timezone": "string",
                              "location": {
                                  "location_id": "integer",
                                  "name": "string",
                                  "address": "string",
                                  "country": "string",
                                  "latitude": "string",
                                  "longitude": "string"
                              },
                              "classroom": "string",
                              "instructor": "string",
                              "sessionSchedules": {
                                  "data": [
                                      {
                                          "session_date": "date",
                                          "session_time_from": "time",
                                          "break_time_from": "time",
                                          "break_time_to": "time",
                                          "session_time_to": "time"
                                      }
                                  ]
                              }
                          }
                      ]
                  }
              }
          ],
          "meta": {
              "pagination": {
                  "total": "integer",
                  "count": "integer",
                  "per_page": "integer",
                  "current_page": "integer",
                  "total_pages": "integer",
                  "links": {
                      "previous": "url",
                      "next": "url"
                  }
              }
          }
      }
      

Check Course Assignment [POST /course/checkCourseAssignment]

Verify course is already assign to user or not.

  • Parameters
    • user_id: (integer, required) – Internal abara user id
    • course_id: (integer, required) – Internal abara course id
    • session_id: (integer, optional) – Internal abara classroom session id. It only required if course type is ‘Classroom’
  • Response 200 (application/json)
    • Body
      {
          "assigned": true,
          "status_code": 200
      }
      
  • Response 200 (application/json)
    • Body
      {
          "assigned": false,
          "status_code": 200
      }
      
  • Response 422 (application/json)
    • Body
      {
          "message": "Error while checking course assignment.",
          "errors": {
              "user_id": [
                  "Please enter your user id."
              ],
              "course_id": [
                  "Please enter your course id."
              ]
          }
      }
      

Assign Course [POST /course/assignCourse]

Assign an user to a course.

  • Parameters
    • user_id: (integer, required) – Internal abara user id
    • course_id: (integer, required) – Internal abara course id
    • session_id: (integer, optional) – Internal abara classroom session id. It only required if course type is ‘Classroom’
    • re_enroll: (integer, optional) – 1 – For re-enroll existing assign course
    • send_email: (integer, optional) – 0/1 – Send mail/message to learner upon course assignment
      • Default: 0
  • Response 200 (application/json)
    • Body
      {
          "message": "Course successfully assigned to learner!",
          "status_code": 200
      }
      
  • Response 200 (application/json)
    • Body
      {
          "message": "Learner have been added to the waiting list for the classroom session.",
          "status_code": 200
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "User Not Found",
          "status_code": 201
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "Insufficient subscription quota for the session.",
          "status_code": 201
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "Session not found.",
          "status_code": 201
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "Please enter valid session id.",
          "status_code": 201
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "Course not found.",
          "status_code": 201
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "User Not Found",
          "status_code": 201
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "Course already assigned to learner.",
          "status_code": 201
      }
      
  • Response 422 (application/json)
    • Body
      {
          "message": "Could not assign course to user.",
          "errors": {
              "user_id": [
                  "Please enter your user id."
              ],
              "course_id": [
                  "Please enter your course id."
              ]
          }
      }
      

List Course Assets [POST /course/listCourseAssets]

Retrieves a list of all the learning assets in the course.

  • Parameters
    • course_id: (integer, required) – Internal abara course id
    • limit: (integer, optional) – Total number of records per page
      • Default: 10
    • page: (integer, optional) – Page Number
      • Default: 1
  • Response 200 (application/json)
    • Body
      {
          "data": [
              {
                  "module_id": "integer",
                  "name": "string",
                  "description": "string",
                  "thumbnail": "url",
                  "asset_type": "integer (0-Scorm, 1-Reference Material, 2-Video, 3-Assessment)",
                  "is_mandatory": "boolean (1-Mandatory, 0-Optional)"
              }
          ],
          "meta": {
              "pagination": {
                  "total": "integer",
                  "count": "integer",
                  "per_page": "integer",
                  "current_page": "integer",
                  "total_pages": "integer",
                  "links": {
                      "previous": "url",
                      "next": "url"
                  }
              }
          }
      }
      
  • Response 201 (application/json)
    • Body
      {
          "message": "Course not found.",
          "status_code": 201
      }
      
  • Response 422 (application/json)
    • Body
      {
          "message": "Unable to fetch assets.",
          "errors": {
              "course_id": [
                  "Please enter your course id."
              ]
          }
      }
      
Did you find apk for android? You can find new Free Android Games and apps.