The kahoot client that interacts with kahoot's quiz api.
- Emitted when the client joins the game.
on('quizStart', Quiz)
and on('quiz', Quiz)
- Emitted when the quiz starts for the client.
- Passes a
Quiz
class.
- Emitted when the client receives a new question.
- This is NOT the same as the
questionStart
event, which is emitted after the question has started. - Passes a
Question
class.
- Emitted when a question starts.
- Questions can be answered using
Question.answer(data)
- Questions can be answered using
- Passes a
Question
class.
on('questionSubmit', QuestionSubmitEvent)
- Emitted when your answer has been submitted.
- Passes a
QuestionSubmitEvent
class.
on('questionEnd', QuestionEndEvent)
- Emitted when a question ends.
- Passes a
QuestionEndEvent
class.
- Emitted when the quiz ends.
- Passes a
QuizFinishEvent
class.
on('finishText', FinishTextEvent)
- Emitted when the quiz finish text is sent.
- Passes a
FinishTextEvent
class.
on('quizEnd')
and on('disconnect')
- Emitted when the quiz closes, and the client is disconnected.
- Emitted when the 2 Step Auth is recieved
- Emitted when the 2 Step Auth is refreshed
- Emitted when the 2 Step Auth is incorrect
- Emitted when the 2 Step Auth is correct
- Emitted when the host requests to see feedback.
- Emitted when the join name is a duplicate.
- Emitted when the the websocket connection failed/was blocked.
join(sessionID, playerName, teamNames)
- Joins the game.
- Parameters:
- sessionID (Number) - The Kahoot session ID to join.
- playerName (String) - The name of the user.
- teamNames (Array) [String] - The names of the team members to be used in team game modes (optional).
- Returns:
Promise
- Reconnects the bot.
- Should be used if connection is lost (network issue).
- Returns:
undefined
- Answers the current question.
- Parameters:
- id (Number|Array|String)
- for type "quiz," use a number (0-3) to specify the choice.
- for type "open_ended" and "word_cloud," use a string to specify the answer.
- for type "jumble," use an array of numbers (0-3) to specify the order of items.
- Returns:
Promise
- id (Number|Array|String)
- Answers the 2 Step Auth.
- Parameters:
- steps (Array)
- An array of the steps for the 2 step authentification. (numbers 0-3)
- Returns:
Promise
- steps (Array)
- Leaves the game.
- Returns:
Promise
sendFeedback(fun, learning, recommend, overall)
- Sends feedback to the host.
- Parameters:
- fun (Number)
- A number to rate how much fun you had (1-5)
- learning (Number)
- A number to rate if you learned anything (1 or 0)
- recommend (Number)
- A number to rate if you would recommend (1 or 0)
- overall (Number)
- A Number to rate how you felt (-1 - 1)
- 1 = good
- -1 = bad
- A Number to rate how you felt (-1 - 1)
- fun (Number)
- Returns:
Promise
- Whether or not the client is currently sending an answer.
- The client token of the user.
- The session ID of the quiz.
- The user's name.
- The current quiz of the client.
- The client's nemesis. (Will be
null
if the client does not have a nemesis.)
- An array of all the client's past nemeses.
- The client's accumulated score.
- The client's client id.
- The team member names.
- The game mode of the kahoot.
classic
- normal kahoot game.team
- kahoot game with teams.
- Whether to log the messages from and to the server. Defaults to false.
- Whether the kahoot is using the namerator.
- Whether the kahoot is using two factor authentification.
- The client the quiz is attached.
- The name of the quiz.
- Note: this value may be
null
if you joined the quiz after it started
- Note: this value may be
- The quiz type.
- The current question the quiz is on.
- An array of every single question in the quiz. New questions get added as they come in.
- The number of questions in the quiz.
- An array that shows the # of choices per question in the quiz.
- Parameters:
- number (Number)
- The question number to answer. (0 is the first answer, 1 is the second answer, etc.)
- number (Number)
- The client attached to the question.
- The quiz that the question for.
- The index of the question.
- The time left before the question starts.
- The question type.
- "quiz" is the basic multiple choice quesiton.
- "survey" is a poll, there aren't any points.
- "content" is a slideshow, you don't need to answer this one.
- "jumble" is a puzzle question, send an array of numbers to order the answers.
- "open_ended" is a free response question; send text.
- "word_cloud" is a free response poll; send text.
- Whether or not the question uses 'Story Blocks'.
- I still don't know what this means.
- Whether or not the question has ended.
- The number of the question.
- The game mode of the session. It can be either "classic" or "team."
- The client attached to the event.
- The quiz that the event is attached to.
- The question that the event is attached to.
- A list of the correct answers.
- The correct answer. (if there are multiple correct answers, this will be the first correct answer.)
- The text sent by Kahoot after a question has finished.
- Whether or not the client got the question right.
- The client's nemesis. (Will be
null
if the client does not have a nemesis.)
- The points earned from this question.
- The current correct streak.
- The rank of the client
- The total score of the client
- The client attached to the event.
- The quiz attached to the event.
- The question attached to the event.
- The name of the nemesis user.
- The score of the nemesis user.
- Whether or not the nemesis user is a ghost player or not.
- Whether or not the nemesis exists (All other values will be
undefined
if this isfalse
)
- The medal recieved after the quiz.
- The client attached to the event.
- The quiz attached to the event.
- The number of players on the quiz.
- The ID of the quiz.
- This is ONLY sent at the end of the quiz.
- The client's ranking on the quiz.
- The number of questions that were scored correct.
- The number of questions that were scored incorrect.
This package (V1.2.12+) now has support for use of proxies. This will request the session information using the proxy, but the websocket will still be directly connected. Proxies can either be a String or an Object like so:
const proxy1 = "http://cors-server.example.com/";
const proxy2 = {
proxy: "http://other-server.example.com/path/",
options: {
headers: {
"X-Requested-With": "foobar"
},
method: "POST"
},
nopath: true
};
const kahootJS = require("kahoot.js-updated");
const bots = [];
for(let i = 0; i < 10; ++i){
let client;
if(Math.round(Math.random())){
client = new kahootJS(proxy1);
}else{
client = new kahootJS(proxy2);
}
client.join(pin);
bots.push(client);
}
Proxies must be in this format in order to work:
https://sub.domain.top/<path>/<query>
- The information is requested by appending the proxy to the start of the url:
"https://sub.domain.top/path/" + "https://kahoot.it/reserve/session/12345/?12418"
- This can be prevented by using the nopath option.
The options is the HTTP Request Options, which should only be used if the proxy service requires special headers to work. You can also set the method used.
Proxies are only used to specify HTTP requests for the tokens and for challenge games. If the websocket connection is blocked, you need to use a proxy/vpn for your server.