# kahoot.js-latest V1.x.x Documentation

[JSDoc](https://limitfinity.github.io/kahoot.js-latest)umentation

- [Examples](#examples)
- [Methods](#methods)
- [Events](#events)
- [Properties](#properties)

## Documentation

<a name="examples"></a>
## Examples
<a name="basic"></a>
### Basic Usage
```js
const Kahoot = require("kahoot.js-latest");
const client = new Kahoot;
client.join(PIN).catch(err=>{
  console.log("Failed to join: " + err.description || err.status);
});
client.on("Joined",()=>{console.log("Joined!")});
client.on("Disconnect",(reason)=>{console.log("Disconnected: " + reason)});
client.on("QuizStart",(question)=>{question.answer(0)});
```

<a name="custom-modules"></a>
### Custom Modules
```js
const disabled = new Kahoot({
  modules: {
  	extraData: false,
    feedback: false,
    teamAccept: false
  }
});
disabled.join(PIN);
disabled.on("QuestionStart",(question)=>{
  try{
    question.answer(0);
  }catch(err){ // question.answer is not a function
               // (enabled in extraDark, which was disabled)
    disabled.answer(0); // works!
  }
});
disabled.on("TeamAccept",(info)=>{
  console.log(info); // This should not run (teamAccept is disabled)
});
```

<a name="methods"></a>
### Methods

<a name="methods.static.defaults"></a>
**`static` `defaults(options)`** - Creates a new Client class using new default options.
| Parameter | Returns |
| - | - |
| [options](https://limitfinity.github.io/kahoot.js-latest/Client_defaults.html) | Client |

<a name="methods.static.join"></a>
**`static` `join(pin,name,team)`** - Creates a new client and joins the game.
#### Parameters:
| name | description |
|-|-|
|pin|The game pin of the Kahoot! game/challenge|
|*name*|The name of the client.|
|*team*|The team members (used in team mode). If left empty, defaults to `"Player 1","Player 2","Player 3","Player 4"`|
#### Returns `Object`

|property|description|
|-|-|
|client|The newly created client|
|event|The [join](#methods.join) promise|

Equivalent of doing:
```
var client = new Kahoot;
client.join(pin,name,team);
```

<a name="methods.join"></a>
**join(pin,name,team)** - Join a Kahoot! game or challenge.
#### Parameters:
|name|description|
|-|-|
|pin|The game pin of the Kahoot! game/challenge|
|*name*|The name of the player|
|*team*|The team members of the player. Defaults to `"Player 1","Player 2","Player 3","Player 4"`|
#### Returns `Promise`
- Resolves when the player joins the game (including team members)
  - If two step join is enabled, this does not mean that the client is fully connected yet.
- Rejects with an [error object](https://kahoot.js.org/#/enum/LiveEventJoinResponse) if joining fails.
  - If the game is `LOCKED`, it will reject with a [status object](https://kahoot.js.org/#/enum/LiveEventStatus) instead
  - There is a chance that this may neither resolve nor reject if Kahoot! for some reason decides to ignore your login request (usually due to a suspicious name).
  - If the error is not due to a duplicate name, the client will disconnect from the socket.

<a name="methods.answer"></a>
**answer(choice)** - Answers the question
#### Parameters:
- `choice` - A `Number`, `String`, or `Array<Number>` representing the client's answer to a question.
  - The answer is automatically reformatted if invalid input is provided based on the question type.
#### Returns: `Promise`
- Resolves when the answer is received by Kahoot!
- Rejects if the message fails to be received within 10 seconds. <sup>[4](#footnote-4)</sup>

<a name="methods.answerTwoFactorAuth"></a>
**answerTwoFactorAuth(steps)** - Answers the two-step code.
#### Parameters:
- `code` - A list of the following numbers: `0,1,2,3` (red,blue,yellow,green). The numbers represent the code order on the host's screen.
#### Returns `Promise`
- Resolves when the message is received by Kahoot!
- Rejects if the message times out <sup>[4](#footnote-4)</sup>

<a name="methods.joinTeam"></a>
**joinTeam(team)** - Send the team members
- This should be used if you specify `false` for *`team`* in [join](#methods.join).
  - specifying `false` for the team disables sending the team immediately.
#### Parameters:
- *`team`* - A list of strings representing the names of team members. Defaults to `"Player 1","Player 2","Player 3","Player 4"`
#### Returns `Promise`
- Resolves when received by Kahoot!
- Rejects if the message times out <sup>[4](#footnote-4)</sup>

<a name="methods.leave"></a>
**leave()** - Leaves the game.
- Disconnects from the game and closes the socket.

<a name="methods.next"></a>
**next()**<sup>[5](#footnote-5)</sup> - Continues to the next event.
- This is run automatically if `defaults.options.ChallengeAutoContinue` is `true` (which it is by default)

<a name="methods.reconnect"></a>
**reconnect(cid)** - Reconnect to a game
#### Parameters:
- *`cid`* - If creating a new client to reconnect, you can specify a cid to rejoin the game.
  - You can call this without `cid` if the socket disconnected for an unknown reason.
#### Returns `Promise`
- Resolves when the client reconnects to the game
- Rejects if the client fails to reconnect

<a name="methods.sendFeedback"></a>
**sendFeedback(fun,learn,recommend,overall)** - Sends feedback to the host.
#### Parameters
- `fun` - A number from 1 to 5, rating the quiz
- `learn` - A number from 0 to 1, specifying if you learnt anything
- `recommend` - A number from 0 to 1, specifying if you would recommend the quiz
- `overall` - A number from -1 to 1, rating the overall feeling of the game.
#### Returns `Promise`
- Resolves when the feedback is received by Kahoot!
- Rejects if the message times out <sup>[4](#footnote-4)</sup>

### Events
<a name="events.Disconnect"></a>
`Disconnect` => `String`
- Emitted when the client is disconnected
  - Returns a String with the reason why the client was disconnected.

<a name="events.Feedback"></a>
`Feedback`
- Emitted when the host asks for feedback

<a name="events.GameReset"></a>
`GameReset`
- Emitted when the game resets back to the lobby

<a name="events.Joined"></a>
`Joined` => `Object`
- Emitted when the client joins the game
  - Returns an object with the [settings](https://limitfinity.github.io/kahoot.js-latest/Client.html#event:Joined) of the game
  - May not necessarily mean that the client is fully connected.
    - If two-step join is enabled, the client will have to answer the two-step challenge before being fully connected.

<a name="events.NameAccept"></a>
`NameAccept` => `Object`
- Emitted when Kahoot! has validated the client's name.
  - Returns an object including the player's name (may be changed if deemed inappropriate)
    - `playerName` - The player name
    - `quizType` - String (`quiz`)
    - `playerV2` - Boolean (`true`)
    - `hostPrimaryUsage` - The host account's primary usage

<a name="events.Podium"></a>
`Podium` => `Object`
- Emitted when the quiz has ended. (After [`QuizEnd`](#events.QuizEnd))
  - Returns an object containing the medal.
    - `podiumMedalType` - The medal.

<a name="events.QuestionEnd"></a>
`QuestionEnd` => `Object`
- Emitted when the question ends.
  - Returns an [object](https://limitfinity.github.io/kahoot.js-latest/Client.html#event:QuestionEnd) with information about the client's score and answer.

<a name="events.QuestionReady"></a>
`QuestionReady` => `Object`
- Emitted when the question is about to start
  - Returns an [object](https://limitfinity.github.io/kahoot.js-latest/Client.html#event:QuestionReady) with information about the upcoming question and the time remaining before it starts.

<a name="events.QuestionStart"></a>
`QuestionStart` => `Object`
- Emitted when the question starts.
  - Returns an [object](https://limitfinity.github.io/kahoot.js-latest/Client.html#event:QuestionStart) with information about the question and the time remaining in the question.
  - The client may now answer the question.
  - The object also contains an [`answer`](#methods.answer) method, which can be used to answer the question. <sup>[1](#footnote-1)</sup>

<a name="events.QuizEnd"></a>
`QuizEnd` => `Object`
- Emitted when the quiz ends.
  - Returns an [object](https://limitfinity.github.io/kahoot.js-latest/Client.html#event:QuizEnd) about the ranking and scores of the client.

<a name="events.QuizStart"></a>
`QuizStart` => `Object`
- Emitted when the quiz starts.
  - Returns an object that contains some information about the quiz.
    - `quizType` - String (`quiz`)
    - `quizQuestionAnswers` - A list of numbers signifying the number of choices in each question.

<a name="events.RecoveryData"></a>
`RecoveryData` => `Object`
- Emitted when the "recovery data" is sent from the server to the client.
  - This event is not particularly useful. The function running this event also calls other events based on the recovery data content.
    - These events are useful when joining a game late.
    - See [LiveEventRecoveryData](https://kahoot.js.org/#/enum/LiveEventRecoveryData).

<a name="events.TeamAccept"></a>
`TeamAccept` => `Object`
- Emitted when the team member's names have been validated by Kahoot!
  - Returns an object containing recovery data and the validated team members.
    - `memberNames` - A list of the team names. May be modified if the names included an inappropriate word.
    - `recoveryData` - [Recovery data](https://kahoot.js.org/#/enum/LiveEventRecoveryData )

<a name="events.TeamTalk"></a>
`TeamTalk` => `Object`
- Emitted when the team talk starts in team mode.
  - Returns an [object](https://limitfinity.github.io/kahoot.js-latest/Client.html#event:TeamTalk) describing the time remaining and the upcoming question.
  - Unintended ability? You can answer the question during team talk (if the host is using the official host website)

<a name="events.TimeOver"></a>
`TimeOver` => `Object`
- Emitted when the question ends (before [QuestionEnd](#events.QuestionEnd)).
  - Returns an object.
    - `questionIndex` - The question index of the recently ended question.

<a name="events.TwoFactorCorrect"></a>
`TwoFactorCorrect`
- Emitted when the two-step challenge was completed successfully.
  - TwoFactor events will stop being emitted after this.

<a name="events.TwoFactorReset"></a>
`TwoFactorReset`
- Emitted when the two-step challenge code resets.

<a name="events.TwoFactorWrong"></a>
`TwoFactorWrong`
- Emitted when the two-step challenge was answered incorrectly.

---

© LimitFinity 2026

---

**Disclaimer:**

Kahoot.JS-Latest is not affiliated, associated, authorized, endorsed by, or in any way officially connected with Kahoot! AS.
