Module: API

API module.
Source:

Members

(inner) CORS Parsing Middleware

If the incoming request is a CORS request, the body is parsed to a JSON object.
Source:

(inner) ID Checking Middleware

This middleware is set at the beginning of the API, after the / endpoint, to check if the user has a valid id.
If there is no id information, or the id is from an expired user, an error is returned. If the id stored in the cookies is valid, then the request can continue, (next()).
Source:

Methods

(inner) /()

ENDPOINT.
The root (/) endpoint allows us to create a user session.
Tot groups each set of detectors (and hence results) under an user object (see Users), univocally identified with an id (generated with uniqid) stored as a cookie, so the users have to send their id along with their request in order to perform any operation. The users cannot communicate with any other endpoint if they haven't been given an id. When a new request for this endpoint arrives, the request's cookies are checked:
  • If there is no id, then a new user is created, and its unique id is stored in the response's cookies.
  • If there is an user id in the cookies, then that user's session is refreshed. If said id is from an expired user, then a new user (and id) is created.
Source:

(inner) /analyse()

ENDPOINT.
The /analyse endpoint allows us to request for the analysis of some media file. The request will recieve up to 3 parameters:
  • mediaType: Kind of media which will be sent. Options can be "image", "video", "sound" and "text".
  • lookingFor: Feature we want to analyse. Options can be "face", "voice", "signal" and "body".
  • mediaPath: Absolute path to the file which contains the media. This can be a local path or an Internet address.
Source:

(inner) /init()

ENDPOINT.
The /init endpoint allows us to initialize the whole system.
The setting information can be received through the request itself (settings parameter), or through a file, in which case the path to said file must be indicated in the request (settingsPath). Please keep in mind that the route to the file starts at the root of the project (tot-system/...).
Source:

(inner) /results(channelsToMergeopt, localStrategy, globalStrategy)

ENDPOINT.
The /results endpoint returns a single triplet as a result of aggregating all the previous results from emotion detectors in the PAD format. The aggregation process has three levels:
  1. Each detector aggregates its results applying the localStrategy strategy, turning a PAD results array into a single PAD triplet. At this point, we have a PAD triplet per detector.
  2. These triplets are aggregated again, using the localStrategy strategy, but grouping them by channel. At this point, we have a PAD triplet per emotion channel.
  3. Finally, these channels' triplets are aggregated using the globalStrategy strategy, producing the final PAD triplet which is returned to the user.
Parameters:
Name Type Attributes Description
channelsToMerge String | Array <optional>
Array of emotion channels to merge.
localStrategy string Name of the strategy to use to aggregate the results of each individual detector and each channel.
globalStrategy string Name of the strategy to use to aggregate the locally aggregated results.
Source:

(inner) /setup()

ENDPOINT.
The /setup endpoint allows us to customize a little bit your set of detectores. The request will recieve up to 3 parameters, all of them optional:
  • type: Array of the detector categories you want to keep. Detector categories which are not in this array will be deteled. An empty array deteles every category.
  • realTime: Boolean which states if you want detectors which work in real time or not.
  • delay: Upper threshold of the delay attribute. The delay attribute is set in the /initialize endpoint and represents the average time that a certain detector needs to fulfil a request. Detectors whose delay attribute is bigger than the delay parameter will be deleted.
Source: