Introduction
Welcome to the Professor Nittany API! You can use our API to access PN API endpoints.
We have language bindings in NodeJS! You can view code examples in the dark area to the right.
Users
Local SignIn
HTTP Request
POST /users/signin
To locally sign in a user, use this code:
fetch("/users/signin", {
method: 'post',
headers: {
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8"
},
body: 'email={email}&password={password}',
credentials: 'include'
}).then(response=>{return response.json()})
.then(json=> {
// response message will be in json
});
The sign in API requires 2 parameters
| Parameter | Description |
|---|---|
| The email of the account | |
| password | The password of account |
Example response of error:
{
"err": {
"name": "IncorrectPasswordError",
"message": "Password or username are incorrect"
}
}
| Property | Eesponse | Description |
|---|---|---|
| err.name | IncorrectPasswordError | Incorrect password input |
| err.message | Password or username are incorrect | Either username or password is not correct |
Example response of successful signin:
{
"status": "Login successful!",
"success": true,
"token": "eyJhbGciOiJIU..."
}
| Property | Description |
|---|---|
| status | Show login status |
| success | Boolen flag |
| token | Access token |
Local Signup
HTTP Request
POST /users/signup
To locally sign up a user, use this code:
fetch("/users/signup", {
method: 'post',
headers: {
"Content-type": "application/json"
},
body: JSON.stringify({
'email': '',
'password' : '',
'first_name':'',
'last_name':'',
'account_role':'',
'major':[] //allow double or triple majors. An array of major document id such as ["59868428a9a69f4d0028cd58"]
})
}).then(response=>{return response.json()})
.then(json=> {
//json contains responses
})
The local sign up API requires 5 parameters
| Parameter | Description |
|---|---|
| first_name | The first_name of the user |
| last_name | The last_name of the user |
| account_role | the role of the account |
| The email of the account | |
| password | The password of account |
| major | An array of majors' document id |
{
"err": {
"name": "UserExistsError",
"message": "A user with the given username is already registered"
}
}
{
"err": {
"name": "InvalidPasswordFormat",
"message": "Invalid password format, check the rule of making password."
}
}
{
"err": {
"name": "MissRequiredInformation",
"message": "Miss requireed signup infomation."
}
}
Example response of error:
| Property | Response | Description |
|---|---|---|
| err.name | UserExistsError InvalidPasswordFormat MissRequiredInformation |
Signup email address existed Signup password is not valid Signup required information is missing |
| err.message | A user with the given username is already registered Invalid password format, check the rule of making password Miss requireed signup infomation |
{
"status": "Successfully registered, check actvition email."
}
Example response of successful singup:
| Property | Response | Description |
|---|---|---|
| status | Successfully registered, check actvition email | Successfully create the account, server has sent out an activation email to the email beening registered |
Get Password Rules
HTTP Request
POST /users/get-password-rules
To locally sign in a user, use this code:
fetch("/users/get-password-rules", {
method: 'get'
}).then(response=>{return response.json()})
.then(json=> {
// response message will be in json
});
There should not be any error response.
Example response of successful signin:
{
"min_lowercase_letter": 1,
"min_uppercase_letter": 1,
"min_number": 1,
"min_length": 8,
"max_special_character": 0
}
| Property | Description |
|---|---|
| min_lowercase_letter | the minimum number of lowercase letter required |
| min_uppercase_letter | the minimum number of uppercase letter required |
| min_number | the minimum number of digit character required |
| min_length | the minimum length of the password |
| max_special_character | the maximum number of special character |
Get Major List
HTTP Request
POST /users/signup
To locally sign up a user, use this code:
fetch("/major-list", {
method: 'get',
headers: {
"Content-type": "application/json"
}
}).then(response=>{return response.json()})
.then(json=> {
//json contains responses
})
Example successful response:
| Property | Description |
|---|---|
| degree_name | The name of degree |
| degree_level | Undergraduate only by now |
| id | Id of major documents should be send back to server when user register |
{
[
{
"_id": "59868428a9a69f4d0028cd56",
"degree_name": "Accounting",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd57",
"degree_name": "Advertising/Public Relations-Strategic Communications",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd58",
"degree_name": "Agribusiness Management",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd59",
"degree_name": "Biobehavioral Health",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd5a",
"degree_name": "Business",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd5b",
"degree_name": "Criminal Justice",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd5d",
"degree_name": "Economics",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd5c",
"degree_name": "Digital Multimedia Design",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd5e",
"degree_name": "Energy and Sustainability Policy",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd5f",
"degree_name": "Finance",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd60",
"degree_name": "Health Policy and Administration",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd61",
"degree_name": "Human Development and Family Studies",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd62",
"degree_name": "Information Sciences and Technology",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd63",
"degree_name": "Integrated Social Sciences",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd64",
"degree_name": "International Politics",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd66",
"degree_name": "Law and Society",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd68",
"degree_name": "Marketing",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd6b",
"degree_name": "Political Science",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868429a9a69f4d0028cd6d",
"degree_name": "Security and Risk Analysis",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd67",
"degree_name": "Letters, Arts, and Sciences",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd6c",
"degree_name": "Psychology",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd65",
"degree_name": "Labor and Employment Relations",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd6a",
"degree_name": "Organizational Leadership",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868428a9a69f4d0028cd69",
"degree_name": "Nursing",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868429a9a69f4d0028cd6e",
"degree_name": "Software Engineering",
"degree_level": "undergraduate",
"__v": 0
},
{
"_id": "59868429a9a69f4d0028cd6f",
"degree_name": "Turfgrass Science",
"degree_level": "undergraduate",
"__v": 0
}
]
}
Example response of successful singup:
| Property | Response | Description |
|---|---|---|
| status | Successfully registered, check actvition email | Successfully create the account, server has sent out an activation email to the email beening registered |
Local Account Activation
HTTP Request
GET /users/active-account/{token}
Request Account Password Change
HTTP Request
POST /users/request-reset-password
To submit a password reset request:
fetch("/users/request-reset-password", {
method: 'post',
headers: {
"Content-type": "application/json"
},
body: JSON.stringify({
'email': ''
})
}).then(response=>{return response.json()})
.then(json=> {
//json contains responses
})
Example Response
An email will send to user with a link (/users/update-password/{token}) to reset their password
{
"status": "success",
"message": "An e-mail has been sent to harryhappy111@gmail.com with further instructions.",
"token": "6076253795a31fade21b1c6b106cd0bf1df08334"
}
Get Email by Password Request Token (The link will be in the user's email)
HTTP Request
GET /users/update-password/{token}
Sever will send back user's email and token, which are used to update password.
Example of response information:
{
"email":"harryhappy111@gmail.com",
"token":"6076253795a31fade21b1c6b106cd0bf1df08334"
}
Update Account Password
HTTP Request
POST /users/update-password
To rest password:
fetch("/users/update-password", {
method: 'post',
headers: {
"Content-type": "application/json"
},
body: JSON.stringify({
'email': '',
'token': '',
'password': ''
})
}).then(response=>{return response.json()})
.then(json=> {
//json contains responses
})
Example callback response of successful reset:
{
"status": "Password reset successful",
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1OTdmODQzNzlkYjczMzZiNjhiZDZhMGEiLCJzdGF0dXMiOiJhY3RpdmUiLCJhY2NvdW50X3JvbGUiOiJzdHVkZW50IiwiaWF0IjoxNTAxNTMyNDM4LCJleHAiOjE1MDE1MzYwMzh9.9Dwj-iM9AcL3UN6As8GoYikd1HS-9YLYo8bBiKryhW0"
}
| Property | Description |
|---|---|
| status | Show login status |
| success | Boolen flag |
| token | Access token |
Facebook SignIn
HTTP Request
Get /users/signup-facebook
Example callback response of successful signin at /users/signin/callback?xxx=xxx:
{
"status": "Login successful!",
"success": true,
"token": "eyJhbGciOiJIUzI1NiIs..."
}
| Property | Description |
|---|---|
| status | Show login status |
| success | Boolen flag |
| token | Access token |
Google SignIn
HTTP Request
Get /users/signup-google
Example callback response of successful signin at /users/signin/callback?xxx=xxx:
{
"status": "Login successful!",
"success": true,
"token": "eyJhbGciOiJIUzI1NiIs..."
}
| Property | Description |
|---|---|
| status | Show login status |
| success | Boolen flag |
| token | Access token |
Linkedin SignIn
HTTP Request
Get /users/signup-linkedin
Example callback response of successful signin at /users/signin/callback?xxx=xxx:
{
"status": "Login successful!",
"success": true,
"token": "eyJhbGciOiJIUzI1NiIs..."
}
| Property | Description |
|---|---|
| status | Show login status |
| success | Boolen flag |
| token | Access token |
Twitter SignIn (Currently Disabled)
HTTP Request
Get /users/signup-twitter
Example callback response of successful signin at /users/signin/callback?xxx=xxx:
{
"status": "Login successful!",
"success": true,
"token": "eyJhbGciOiJIUzI1NiIs..."
}
| Property | Description |
|---|---|
| status | Show login status |
| success | Boolen flag |
| token | Access token |
Sign Out
To sign out a user, simply discard the token on client side since server will not store any token.
Questions
We implement Watson Conversation System with Retrivement and Rank to get a smooth conversation.
Send a Question in Lite Version
HTTP Request
post /questions/send-lite
To get an answer to a question or start a conversation, use this code:
fetch("/questions/send-lite", {
method: 'post',
headers: {
"Content-type": "application/json"
},
body: JSON.stringify({
'question': '',
'context' : {}
})
}).then(response=>{return response.json()})
.then(json=> {
//json contains responses
})
The "send-lite" API requires 2 parameter in the request body
| Parameter | Description |
|---|---|
| question | A question should be in the request body |
| context | A context is an object generated by server to track a conversation. |
Example response of successful response from Retrive and Rank:
// retrieve_and_rank response
{
"context":{},
"responseHeader": {
"status": 0,
"QTime": 45
},
"response": {
"numFound": 518,
"start": 0,
"maxScore": 10,
"docs": [
{
"id": "9241ae96-add9-4746-bda1-84960b7a105b",
"title": "Help me explain the difference between studying Computer Engineering and Electrical Engineering.",
"body": "An electrical engineer is someone who designs and develops new electrical equipment, solves problems and tests equipment. They work with all kinds of electronic devices, from the smallest pocket devices to large supercomputers. Electrical engineering deals with electricity, electro-magnetism and electronics.[\\n] Computer engineering is the branch of engineering that integrates electronic engineering with computer sciences. Computer engineers design and develop computer systems and other technological devices[\\n] Electrical Engineering encompasses Computer Engineering. An Electrical Engineer can do a Computer Engineers work, but in some cases Computer Engineer can’t work with core electrical stuff. There are even available courses with can help Electrical engineers to get jobs in IT industry but you hardly find any courses which helps Computer Engineers to get jobs in the electrical field.",
"score": 10,
"ranker.confidence": 0.5462427822233803
},
...
{
"id": "a327393a-a7cc-4c71-8383-8525b58bbc88",
"title": "no-title",
"body": "Computer engineering majors complete several courses to fulfill various categories while pursuing a bachelor’s degree. In addition to general education courses, students also must successfully complete electrical engineering, computer engineering, general computer and mathematical, and computer engineering elective courses.[\\n] [extend]In many programs, the core computer engineering curriculum includes calculus, engineering analysis, and physics. Electrical engineering courses include electronic circuits, signals and systems, electrical engineering design, and logic design. Computer engineering courses often include computer architecture, digital system design, microcomputer systems, and C++. Other computer-based coursework could include probability, random processes, and computer programming with engineering. The range of electives varies greatly by program and institution, but common courses include operating systems, Unix, network security, and software engineering.[\\n][/extend]  ",
"score": 1,
"ranker.confidence": 0
}
]
}
}
| Property | Description |
|---|---|
| res.context | A Conversation track needed to send back |
| res.response.docs | An array of responses |
| res.response.numFound | Total number of found responses |
| res.response.maxScore | The maximum score of a response |
Example response 1 from Conversaton:
// conversation response for asking personal information
{
"context": {
"conversation_id": "2c1b0e4c-9ffd-4713-9172-b3bbde8d799d",
"system": {
"dialog_stack": [
"slot_34_1500798544935"
],
"dialog_turn_counter": 1,
"dialog_request_counter": 1,
"_node_output_map": {}
},
"Semester": "next semester"
},
"response": {
"docs": [
{
"title": "Conversation continue",
"body": "Could you provide me with your PSU ID to look up your schedule?"
}
]
}
}
| Property | Description |
|---|---|
| res.response.docs | An array of responses |
| res.context | An object track the conversation need to be sent back to server |
Example response 2 from Conversaton:
// conversation response to show query result
{
"context": {},
"response": {
"docs": [
{
"title": "personal question information",
"body": "-schedule -semester next semester -psu_id 960625319"
}
]
}
}
| Property | Description |
|---|---|
| res.response.docs | An array of responses |
| res.context | An object track the conversation need to be sent back to server |
Example response for unsolved question:
// response to show question is unsolved
{
"response": {
"docs": [
{
"title": "No answer found",
"body": "Sorry I can't find any answer for this question, please ask a different question."
}
]
},
"context": {}
}
| Property | Description |
|---|---|
| res.response.docs | An array of responses |
| res.context | An object track the conversation need to be sent back to server |
Send a Question in Full Version
HTTP Request
post /questions/send
To get an answer to a question or start a conversation, use this code:
fetch("/questions/send", {
method: 'post',
headers: {
"Content-type": "application/json",
"x-access-token":"{user's token}"
},
body: JSON.stringify({
'question': ''(question),
'context' : {} (context obejct)
}),
credentials: 'include'
}).then(response=>{return response.json()})
.then(json=> {
//json contains responses
})
The "send" API requires 2 parameter in the request body
| Parameter | Description |
|---|---|
| question | A question should be in the request body |
| context | A context is an object generated by server to track a conversation. |
The "send" API requires 1 parameter in the request header
| Parameter | Description |
|---|---|
| x-access-token | Token gained after successfully signin |
Example response of successful response from Retrive and Rank:
// retrieve_and_rank response
{
"context":{},
"responseHeader": {
"status": 0,
"QTime": 45
},
"response": {
"numFound": 518,
"start": 0,
"maxScore": 10,
"docs": [
{
"id": "9241ae96-add9-4746-bda1-84960b7a105b",
"title": "Help me explain the difference between studying Computer Engineering and Electrical Engineering.",
"body": "An electrical engineer is someone who designs and develops new electrical equipment, solves problems and tests equipment. They work with all kinds of electronic devices, from the smallest pocket devices to large supercomputers. Electrical engineering deals with electricity, electro-magnetism and electronics.[\\n] Computer engineering is the branch of engineering that integrates electronic engineering with computer sciences. Computer engineers design and develop computer systems and other technological devices[\\n] Electrical Engineering encompasses Computer Engineering. An Electrical Engineer can do a Computer Engineers work, but in some cases Computer Engineer can’t work with core electrical stuff. There are even available courses with can help Electrical engineers to get jobs in IT industry but you hardly find any courses which helps Computer Engineers to get jobs in the electrical field.",
"score": 10,
"ranker.confidence": 0.5462427822233803
},
...
{
"id": "a327393a-a7cc-4c71-8383-8525b58bbc88",
"title": "no-title",
"body": "Computer engineering majors complete several courses to fulfill various categories while pursuing a bachelor’s degree. In addition to general education courses, students also must successfully complete electrical engineering, computer engineering, general computer and mathematical, and computer engineering elective courses.[\\n] [extend]In many programs, the core computer engineering curriculum includes calculus, engineering analysis, and physics. Electrical engineering courses include electronic circuits, signals and systems, electrical engineering design, and logic design. Computer engineering courses often include computer architecture, digital system design, microcomputer systems, and C++. Other computer-based coursework could include probability, random processes, and computer programming with engineering. The range of electives varies greatly by program and institution, but common courses include operating systems, Unix, network security, and software engineering.[\\n][/extend]  ",
"score": 1,
"ranker.confidence": 0
}
]
}
}
| Property | Description |
|---|---|
| res.context | A Conversation track |
| res.response.docs | An array of responses |
| res.response.numFound | Total number of found responses |
| res.response.maxScore | The maximum score of a response |
Example response 1 from Conversaton:
// conversation response for asking personal information
{
"context": {
"conversation_id": "2c1b0e4c-9ffd-4713-9172-b3bbde8d799d",
"system": {
"dialog_stack": [
"slot_34_1500798544935"
],
"dialog_turn_counter": 1,
"dialog_request_counter": 1,
"_node_output_map": {}
},
"Semester": "next semester"
},
"response": {
"docs": [
{
"title": "Conversation continue",
"body":"Could you provide me with your PSU ID to look up your schedule?"
}
]
}
}
| Property | Description |
|---|---|
| res.response.docs | An array of responses |
| res.context | An object track the conversation needed to be sent back to server |
Example response 2 from Conversaton:
// conversation response to show query result
{
"context": {},
"response": {
"docs": [
{
"title": "personal question information",
"body": "-schedule -semester 4 -psu_id 960623452"
}
]
}
}
| Property | Description |
|---|---|
| res.response.docs | An array of responses |
| res.context | An object track the conversation need to be sent back to server |
Example response for unsolved question:
// response to show question is unsolved
{
"response": {
"docs": [
{
"title": "No answer found",
"body": "Sorry I can't find any answer for this question, please ask a different question."
}
]
},
"context": {}
}
| Property | Description |
|---|---|
| res.response.docs | An array of responses |
| res.context | An object track the conversation |
Profiles
Retrieve User Information
GET /users/get-user
To get a user's information, use this code:
fetch("/users/get-user", {
method: 'get',
headers: {
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"x-access-token":"{user's token}"
},
credentials: 'include'
}).then(response=>{return response.json()})
.then(json=> {
// now json contains user manual input interest
});
The API requires 1 parameter in the request header
| Parameter | Description |
|---|---|
| x-access-token | Token gained after successfully signin |
Example response of error:
// error due to incorrect token
{
"message": "You are not authenticated!",
"error": {
"status": 302
}
}
| Property | Response | Description |
|---|---|---|
| message | You are not authenticated! | User signin token is invalid |
| error.status | 302 | Indicate user should be redirected to signin page |
Example response with valid token:
{
"_id": "597f84379db7336b68bd6a0a",
"first_name": "Kun",
"last_name": "Wang",
"email": "harryhappy111@gmail.com",
"question_history": [],
"__v": 0,
"account_role": "student",
"resetPasswordExpires": "2017-07-31T22:26:44.211Z",
"resetPasswordToken": "6076253795a31fade21b1c6b106cd0bf1df08334",
"activation_code": null,
"status": "active",
"assessement": [],
"inbox": [],
"interest_manual": null,
"interest": null,
"major": [],
"psu_id": null
}
Retrieve Input Interest
HTTP Request
GET /profile/interest-manual
To get a user's manual input interest, use this code:
fetch("/profile/interest-manual", {
method: 'get',
headers: {
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"x-access-token":"{user's token}"
},
credentials: 'include'
}).then(response=>{return response.json()})
.then(json=> {
// now json contains user manual input interest
});
The API requires 1 parameter in the request header
| Parameter | Description |
|---|---|
| x-access-token | Token gained after successfully signin |
Example response of error:
// error due to incorrect token
{
"message": "You are not authenticated!",
"error": {
"status": 302
}
}
| Property | Response | Description |
|---|---|---|
| message | You are not authenticated! | User signin token is invalid |
| error.status | 302 | Indicate user should be redirected to signin page |
Example response of successful signin:
// interest response
{
"interest-manual": {
"_id": "596efd0c0074ced1af6d0411",
"__v": 7,
"interest": [
{
"term": "term1",
"value": 1,
"_id": "596f0025a58c8eed278f1cac"
},
{
"term": "term2",
"value": 1,
"_id": "596f0025a58c8eed278f1cab"
},
{
"term": "term3",
"value": 1,
"_id": "596f0025a58c8eed278f1caa"
},
{
"term": "term4",
"value": 1,
"_id": "596f0025a58c8eed278f1ca9"
},
{
"term": "term5",
"value": 1,
"_id": "596f0025a58c8eed278f1ca8"
}
]
}
}
| Property | Description |
|---|---|
| interest-manual.interest | An array of interest object of {term, value} |
Upload Input Interest
HTTP Request
POST /profile/interest-manual
To add or update a user's input interest, use this code:
const payload = {interest_manual:['Interest Term1','Interest Term2',{...}]};
fetch("/profile/interest-manual", {
method: 'post',
headers: {
"Content-type": "application/json; charset=UTF-8",
"x-access-token":"{token}"
},
body:JSON.stringify(payload),
credentials: 'include'
}).then(response=>{return response.json()})
.then(json => {
// now response is in json
});
The API requires 1 token in the header
| header | Description |
|---|---|
| x-access-token | Token gained after successfully signin |
The API requires 1 parameter in the body
| Parameter | Description |
|---|---|
| interest_manual | An array of interest term in string format |
Example response of error:
// error due to incorrect token
{
"message": "You are not authenticated!",
"error": {
"name": "LoginError",
"message": "You are not authenticated!",
"code": 302
}
}
// error due to minimal restriction of interest characters
{
"message": "Minimal interest length is 2",
"error": {
"name": "ContentError",
"message": "Minimal interest length is 2",
"code": 205
}
}
| Property | Response | Description |
|---|---|---|
| status | error | Flag of the response |
| message | You are not authenticated! | User signin token is invalid |
| error.status | 302 205 |
Indicate user should be redirected to signin page Indeciate user should reset content in the request |
Example response of successful post:
// post response
{
"status": "success",
"message": "Done updating"
}
| Property | Response | Description |
|---|---|---|
| status | success | Flag of response |
| message | Done updating | Note |
Retrieve Introduction
HTTP Request
GET /profile/introduction
To add or update a user's introduction, use this code:
fetch("/profile/introduction", {
method: 'get',
headers: {
"Content-type": "application/json; charset=UTF-8",
"x-access-token":"{token}"
}
}).then(response=>{return response.json()})
.then(json => {
// now response is in json
});
The API requires 1 token in the header
| header | Description |
|---|---|
| x-access-token | Token gained after successfully signin |
Example response of error:
// error due to incorrect token
{
"message": "You are not authenticated!",
"error": {
"name": "LoginError",
"message": "You are not authenticated!",
"code": 302
}
}
| Property | Response | Description |
|---|---|---|
| status | error | Flag of the response |
| message | You are not authenticated! | User signin token is invalid |
| error.status | 302 | Indicate user should be redirected to signin page |
Example response of successful get:
// get response
{
"introduction": "Hello everyone.My name is Jim Smith, and I'm a systems analyst. I've been with the company for 5 years now. I started off as a technician and over the years progressed to my current role. When I'm not working, I like to spend time with my son. We do a lot of fishing and camping together. My wife isn't a big fan, but she tags along with us most of the time. It's good to be here and to meet you all in person. We all exchange emails and phone calls, but it's hard to really know someone until you've met face to face. I'm looking forward to talking about our upcoming project with all of you. This is just an example, but it hits on all of the major points that you want to include in a self introduction speech. Keep these kinds of brief speeches ready in your mind for these types of group gatherings. If you know you have one coming up, take some time to practice yours to be prepared before the meeting takes place.\n"
}
| Property | Response | Description |
|---|---|---|
| introduction | {Txt{...} } | Actual introduction text |
Retrieve Personality Assessement
HTTP Request
GET /profile/personality-assessement
To add or update a user's introduction, use this code:
fetch("/profile/personality-assessement", {
method: 'get',
headers: {
"Content-type": "application/json; charset=UTF-8",
"x-access-token":"{token}"
}
}).then(response=>{return response.json()})
.then(json => {
// now response is in json
});
The API requires 1 token in the header
| header | Description |
|---|---|
| x-access-token | Token gained after successfully signin |
Example response of error:
// error due to incorrect token
{
"message": "You are not authenticated!",
"error": {
"name": "LoginError",
"message": "You are not authenticated!",
"code": 302
}
}
| Property | Response | Description |
|---|---|---|
| status | error | Flag of the response |
| message | You are not authenticated! | User signin token is invalid |
| error.status | 302 | Indicate user should be redirected to signin page |
Example response of successful get:
// get response
{
"_id": "59708c3ebf58a3c793a7574d",
"updatedAt": "2017-07-20T10:55:58.788Z",
"createdAt": "2017-07-20T10:55:58.075Z",
"__v": 0,
"evaluation": {
"warnings": [
{
"message": "There were 180 words in the input. We need a minimum of 600, preferably 1,200 or more, to compute statistically significant estimates",
"warning_id": "WORD_COUNT_MESSAGE"
}
],
"values": [
{
"raw_score": 0.6367704049817837,
"percentile": 0.2621898191746721,
"category": "values",
"name": "Conservation",
"trait_id": "value_conservation"
},
{...}
],
"needs": [
{
"raw_score": 0.8109271831148943,
"percentile": 0.9611904707100504,
"category": "needs",
"name": "Challenge",
"trait_id": "need_challenge"
},
{...}
],
"personality": [
{
"children": [
{
"raw_score": 0.5383956268628514,
"percentile": 0.8274409069597289,
"category": "personality",
"name": "Adventurousness",
"trait_id": "facet_adventurousness"
},
{...}
],
"raw_score": 0.8020792454808571,
"percentile": 0.9528793156796703,
"category": "personality",
"name": "Openness",
"trait_id": "big5_openness"
},
{
"children": [
{
"raw_score": 0.7303678775000645,
"percentile": 0.7860256054411036,
"category": "personality",
"name": "Achievement striving",
"trait_id": "facet_achievement_striving"
},
{...}
],
"raw_score": 0.6733653861546127,
"percentile": 0.8343652317084148,
"category": "personality",
"name": "Conscientiousness",
"trait_id": "big5_conscientiousness"
},
{
"children": [
{
"raw_score": 0.6315730495073002,
"percentile": 0.9626426699173913,
"category": "personality",
"name": "Activity level",
"trait_id": "facet_activity_level"
},
{...}
],
"raw_score": 0.6034943331179414,
"percentile": 0.8802511967737836,
"category": "personality",
"name": "Extraversion",
"trait_id": "big5_extraversion"
},
{
"children": [
{
"raw_score": 0.7522105433894992,
"percentile": 0.9103989313381455,
"category": "personality",
"name": "Altruism",
"trait_id": "facet_altruism"
},
{...}
],
"raw_score": 0.7450801110866009,
"percentile": 0.5288927111468087,
"category": "personality",
"name": "Agreeableness",
"trait_id": "big5_agreeableness"
},
{
"children": [
{
"raw_score": 0.5308996793657599,
"percentile": 0.46491279647936234,
"category": "personality",
"name": "Fiery",
"trait_id": "facet_anger"
},
{...}
],
"raw_score": 0.4862254706925009,
"percentile": 0.6310211452973461,
"category": "personality",
"name": "Emotional range",
"trait_id": "big5_neuroticism"
}
],
"processed_language": "en",
"word_count_message": "There were 180 words in the input. We need a minimum of 600, preferably 1,200 or more, to compute statistically significant estimates",
"word_count": 180
}
}
| Property | Response | Description |
|---|---|---|
| updatedAt | ||
| createdAt | ||
| evaluation | ||
| evaluation.warnings | ||
| evaluation.values | ||
| evaluation.needs | ||
| evaluation.personality | ||
| evaluation.word_count |
Update Introduction
HTTP Request
POST /profile/update-introduction
To add or update a user's introduction, use this code:
const payload = {introdcution:"{introduction text{...}}"};
fetch("/profile/update-introduction", {
method: 'post',
headers: {
"Content-type": "application/json; charset=UTF-8",
"x-access-token":"{token}"
},
body:JSON.stringify(payload),
credentials: 'include'
}).then(response=>{return response.json()})
.then(json => {
// now response is in json
});
The API requires 1 token in the header
| header | Description |
|---|---|
| x-access-token | Token gained after successfully signin |
The API requires 1 parameter in the body
| Parameter | Description |
|---|---|
| introdcution | Single string of introduction |
Example response of error:
// error due to incorrect token
{
"message": "You are not authenticated!",
"error": {
"name": "LoginError",
"message": "You are not authenticated!",
"code": 302
}
}
| Property | Response | Description |
|---|---|---|
| status | error | Flag of the response |
| message | You are not authenticated! | User signin token is invalid |
| error.status | 302 | Indicate user should be redirected to signin page |
Example response of successful post:
// post response
{
"status": "success",
"message": "Done updating"
}
| Property | Response | Description |
|---|---|---|
| status | success | Flag of response |
| message | Done updating | Note |
Update Introduction by file
HTTP Request
POST /profile/update-introduction-by-file
To add or update a user's introduction by a text or word file, use this code:
let formData = new FormData();//input file name must be introduction
formData.append("userfile", fileInputElement.files[0]);
fetch("/profile/update-introduction-by-file", {
method: 'post',
headers: {
"x-access-token":"{token}"
},
body: formData,
credentials: 'include'
}).then(response=>{return response.json()})
.then(json => {
// now response is in json
});
The API requires 1 token in the header
| header | Description |
|---|---|
| x-access-token | Token gained after successfully signin |
The API requires 1 parameter in the body
| Parameter | Description |
|---|---|
| formData | Input file from html |
Example response of error:
// error due to incorrect token
{
"message": "You are not authenticated!",
"error": {
"name": "LoginError",
"message": "You are not authenticated!",
"code": 302
}
}
| Property | Response | Description |
|---|---|---|
| status | error | Flag of the response |
| message | You are not authenticated! | User signin token is invalid |
| error.status | 302 | Indicate user should be redirected to signin page |
Example response of successful post:
// post response
{
"status": "success",
"message": "Done updating"
}
| Property | Response | Description |
|---|---|---|
| status | success | Flag of response |
| message | Done updating | Note |
Status
Total Trained Questions
HTTP Request
GET /get-status
To get total trained questions count:
fetch("../status/get-status", {
method: 'get'
})then(response=>{return response.json()})
.then(json=> {
// response message will be in json
});
The API doesn't require any parameter
Example response of successful response:
{
"status": "good",
"trainedQuestionCount": 352
}
| Property | Description |
|---|---|
| status | Show login status |
| trainedQuestionCount | How many questions were trained in the system |
Developer Team Information
HTTP Request
GET /team-member
To get list of developer information:
fetch("../status/team-member", {
method: 'get'
})then(response=>{return response.json()})
.then(json=> {
// response message will be in json
});
The API doesn't require any parameter
Example response of successful response:
[
{
"link":"...",
"description":"...",
"avatar":"...",
"name":"...",
"__v":0,
"main-title":["...","...",...],
"skill":["...","...",...]
},
{...},
...
]
| Property | Description |
|---|---|
| name | Developer's name |
| avatar | Developer's avatar |
| description | Short description text about the developer |
| main-title | Array of roles and team titles of this developer |
| link | Preferred public link of the developer |
| skill | Array of skills that the developer used during development |
HTTP Request
POST /team-member
To post developer information to the server:
fetch("../status/team-member", {
method: 'post',
body:{
"name":"...",
"skill":["...", "...", "...", "...",
"description":"...",
"link":"...",
"avatar":"...",
"main-title":["...","...","...","...","...","...","..."],
"adminCode":"..."
}
})then(response=>{return response.json()})
.then(json=> {
// response message will be in json
});
The API requires 1 parameter
| Parameter | Description |
|---|---|
| body | A json object string of developer's information |
| Property | Description |
|---|---|
| name | Developer's name |
| avatar | Developer's avatar |
| description | Short description text about the developer |
| main-title | Array of roles and team titles of this developer |
| link | Preferred public link of the developer |
| skill | Array of skills that the developer used during development |
| adminCode | Operation token for posting and deleting on server |
Example response of successful response:
Updated new developer record:
[
{
"_id": "...",
"link":"...",
"description":"...",
"avatar":"...",
"name":"...",
"__v":0,
"main-title":["...","...",...],
"skill":["...","...",...]
}
]
| Property | Description |
|---|---|
| name | Developer's name |
| avatar | Developer's avatar |
| description | Short description text about the developer |
| main-title | Array of roles and team titles of this developer |
| link | Preferred public link of the developer |
| skill | Array of skills that the developer used during development |
HTTP Request
DELETE /team-member
To post developer information to the server:
fetch("../status/team-member", {
method: 'delete',
body:{
"name":"...",
"adminCode":"..."
}
})then(response=>{return response.json()})
.then(json=> {
// response message will be in json
});
The API requires 1 parameter
| Parameter | Description |
|---|---|
| body | A json object string of developer's information |
| Property | Description |
|---|---|
| name | Developer's name |
| adminCode | Operation token for posting and deleting on server |
Example response of successful response:
Updated new developer record:
{
"status": "Successfully delete record"
}
| Property | Description |
|---|---|
| status | Operation result |
Errors
The IAA API uses the following error codes:
| Error Code | Meaning |
|---|---|
| 205 | Reset content -- The content user made in request is invalid |
| 302 | Redirect -- The response is a redirection |
| 400 | Bad Request -- Your request sucks |
| 401 | Unauthorized -- Your token is wrong |
| 403 | Forbidden -- The API requested is hidden for administrators only |
| 404 | Not Found -- The specified API could not be found |
| 405 | Method Not Allowed -- You tried to access a API with an invalid method |
| 406 | Not Acceptable -- You requested a format that isn't json |
| 410 | Gone -- The API requested has been removed from our servers |
| 418 | I'm a teapot |
| 429 | Too Many Requests -- You're requesting too many APIs! Slow down! |
| 500 | Internal Server Error -- We had a problem with our server. Try again later. |
| 503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. |