Skip to content

Sending Requests

Yash Aryan edited this page May 24, 2020 · 2 revisions

Guide to making requests to the API

Types of Requests

There are 4 types of requests you can make to this API. These are as follows:

  • /getattendance: This is to get the attendance of the current semester in JSON format.
  • /getscores: This is to get the scores of the theory subjects of the current semester in JSON format. We are still working on getting lab scores. It's proving to be quite challenging.
  • /getprofile: This to get the data from the admission profile of SLcM in JSON format.
  • /validateuser: If you want to check if given credentials are valid or not, this option is for you. Now, this option can be combined with other requests, but make sure, it makes your request slower, and unresponsive if the credentials are wrong.

Request Format

You can send requests to the API either using GET or POST.

Using GET

The general format of this method is as follows:
http://localhost:3000/REQUEST_TYPE?username=YOUR_USERNAME&password=YOUR_PASSWORD&novalidate=YOUR_OPTION

Using POST

You can send this request using anything, including but not limited to HTML Forms, AJAX, fetch, or Axios. Format is:

<form action="/REQUEST_TYPE" method="POST">  
  <input type="text" name="username" placeholder="Username"><br>
  <input type="password" name="password" placeholder="Password"><br>
  <input type="hidden" name="novalidate" value="true">
  <input type="submit" value="Submit">
</form>

Legend

REQUEST_TYPE: Your selection of one of the four types of requests available. YOUR_USERNAME: Your registration number with which you log in to SLcM.
YOUR_PASSWORD: Your password with which you log in to SLcM.
YOUR_OPTION: Use false if you want the API to check if the credentials are correct. Use true if you want to skip this step. The default option is false.

Clone this wiki locally