Skip to content

REST API Documentation

sonsoleslp edited this page Aug 19, 2020 · 4 revisions

Authentication

This endpoint allows you to authenticate in escapp and verify whether you are allowed to participate in an escape room at a given time

Request

Method Endpoint
POST https://escapp.dit.upm.es/api/escapeRooms/1/auth
Key Description
email User e-mail
password User password
token Instead of the password you can provide the user token

Instead of the password you can provide the user token

Sample request

fetch("https://escapp.dit.upm.es/api/escapeRooms/1/auth", {
    "method": "POST",
    "body": JSON.stringify({
        "email": "[email protected]",
        "password" : "******"
    }),
    "headers": {
        "Content-type": "application/json",
        "Accept-Language": "es-ES"
    }
})
.then(res => res.json())
.then(res => console.log(res));      

Response

Key Possible values Description
code OK The answer provided for the puzzle is correct
code NOK The answer provided for the puzzle is incorrect
authentication Boolean Whether the authentication parameters are correct or not
participation PARTICIPANT You are a participant of this escape room and the shift you signed up for is active
participation TOO_LATE You are a participant of this escape room but the shift you signed up for is finished or you have run out of time
participation NOT_ACTIVE You are a participant of this escape room but the shift you signed up for has not started yet
participation NOT_STARTED You are a participant of this escape room but you have not hit the start button on the escapp platform or started via API
participation NOT_A_PARTICIPANT You are not a participant of this escape room
participation AUTHOR You are the author of this escape room
token String The authentication token you can use for the API
`erState {"puzzlesSolved":[...],"hintsAllowed": Boolean, "progress": Number, "score": Number } Object indicating the current state of the escape room for the team. It has two properties: puzzlesSolved, which contains an array indicating which puzzles have been completed by the team (including the puzzle's name, number, solution, and success message); hintsAllowed, a boolean indicating whether the team can request any more hints; progress, the percentage of puzzles solved, and score, the total score of the participant according to the grading rubric set up by the teacher.

Sample response

{
    "code": "OK",
    "authentication": true,
    "token": "E2hXH9AfgQerUDUcWGae3h",
    "participation": "PARTICIPANT",
    "msg": "You are a participant of this escape room",
    "erState": {
        "puzzlesSolved": [{
            "order": 1,
            "name": "Arrancar app",
            "msg": "OK",
            "solution": "Screen1",
        },
        ...
        ],
        "hintsAllowed": true,
        "progress": 20,
        "score": 50,
    }
}

Participation

This endpoint allows you to start participating in an escape room without a need to hit the start button in escapp

Request

Method Endpoint
POST https://escapp.dit.upm.es/api/escapeRooms/1/start
Key Description
email User e-mail
password User password
token Instead of the password you can provide the user token

Instead of the password you can provide the user token

Sample request

fetch("https://escapp.dit.upm.es/api/escapeRooms/1/start", {
    "method": "POST",
    "body": JSON.stringify({
        "email": "[email protected]",
        "password" : "******"
    }),
    "headers": {
        "Content-type": "application/json",
        "Accept-Language": "es-ES"
    }
})
.then(res => res.json())
.then(res => console.log(res));      

Response

Key Possible values Description
code OK The answer provided for the puzzle is correct
code NOK The answer provided for the puzzle is incorrect
authentication Boolean Whether the authentication parameters are correct or not
participation PARTICIPANT You have successfully started the escape room
participation TOO_LATE The shift you signed up for is finished or you have run out of time
participation NOT_ACTIVE The shift you signed up for has not started yet
participation NOT_STARTED You have not hit the start button on the escapp platform
participation NOT_A_PARTICIPANT You are not a participant of this escape room
participation AUTHOR You are the author of this escape room
token String The authentication token you can use for the API
erState {"puzzlesSolved":[...],"hintsAllowed": Boolean, "progress": Number, "score": Number } Object indicating the current state of the escape room for the team. It has two properties: puzzlesSolved, which contains an array indicating which puzzles have been completed by the team (including the puzzle's name, number, solution, and success message); hintsAllowed, a boolean indicating whether the team can request any more hints; progress, the percentage of puzzles solved, and score, the total score of the participant according to the grading rubric set up by the teacher.

Sample response

{
    "code": "OK",
    "authentication": true,
    "token": "E2hXH9AfgQerUDUcWGae3h",
    "participation": "PARTICIPANT",
    "msg": "You are a participant of this escape room",
    "erState": {
        "puzzlesSolved": [...],
        "hintsAllowed": true,
        "progress": 0,
        "score": 0
    }
}

Puzzles

This endpoint allows you to solve puzzles remotely without a need to access escapp's team interface

Request

Name Method Endpoint Solution
Puzzle 1 POST https://escapp.dit.upm.es/api/escapeRooms/1/puzzles/1/submit 1234
Puzzle 2 POST https://escapp.dit.upm.es/api/escapeRooms/1/puzzles/2/submit 5678
Puzzle 3 POST https://escapp.dit.upm.es/api/escapeRooms/1/puzzles/3/submit abcd
Key Description
email User e-mail
password User password
token Instead of the password you can provide the user token

Instead of the password you can provide the user token

Sample request
fetch("https://escapp.dit.upm.es/api/escapeRooms/1/puzzles/1/submit", {
    "method": "POST",
    "body": JSON.stringify({
        "email": "[email protected]",
        "password" : "*******",
        "solution": "1234"
    }),
    "headers": {
        "Content-type": "application/json"
    }
})
.then(res => res.json())
.then(res => console.log(res));

Response

Key Possible values Description
code OK The answer provided for the puzzle is correct
code NOK The answer provided for the puzzle is incorrect
authentication Boolean Whether the authentication parameters are correct or not
participation PARTICIPANT You have successfully started the escape room
participation TOO_LATE The shift you signed up for is finished or you have run out of time
participation NOT_ACTIVE The shift you signed up for has not started yet
participation NOT_STARTED You have not hit the start button on the escapp platform
participation NOT_A_PARTICIPANT You are not a participant of this escape room
participation AUTHOR You are the author of this escape room
token String The authentication token you can use for the API
correctAnswer Boolean Boolean whose value is true if the answer provided for the puzzle is correct and false otherwise.
erState {"puzzlesSolved":[...], "hintsAllowed": Boolean, "progress": Number, "score": Number } Object indicating the current state of the escape room for the team. It has two properties: puzzlesSolved, which contains an array indicating which puzzles have been completed by the team (including the puzzle's name, number, solution, and success message); hintsAllowed, a boolean indicating whether the team can request any more hints; progress, the percentage of puzzles solved, and score, the total score of the participant according to the grading rubric set up by the teacher.

Sample response

{
    "code": "OK",
    "correctAnswer": true,
    "authentication": true,
    "token": "E2hXH9AfgQerUDUcWGae3h",
    "participation": "PARTICIPANT",
    "msg": "You are a participant of this escape room",
    "erState": {
        "puzzlesSolved": [{
        "order": 1,
        "name": "Arrancar app",
        "msg": "OK",
        "solution": "Screen1",
    },
    ...
    ],
        "hintsAllowed": true,
        "progress": 20,
        "score": 50
    }
}