npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kahoot.js

v1.0.0

Published

A library for interacting with Kahoot API.

Downloads

25

Readme

About

Kahoot.js is a library to interact with the Kahoot API. Currently, kahoot.js supports joining and interacting with quizes. Installation requires Node.js 6.0.0 or higher.

Basic Example

var Kahoot = require('kahoot.js');
var client = new Kahoot;
console.log("Joining kahoot...");
client.join(9802345 /* Or any other kahoot token */, "kahoot.js");
client.on("joined", () => {
    console.log("I joined the Kahoot!");
});
client.on("quizStart", quiz => {
    console.log("The quiz has started! The quiz's name is:", quiz.name);
});
client.on("questionStart", question => {
    console.log("A new question has started, answering the first answer.");
    question.answer(0);
});
client.on("quizEnd", () => {
    console.log("The quiz has ended.");
});

Documentation

Classes

Kahoot

Kahoot client that can interact with quizes.

Events on('ready'), on('join') - Emitted when the client joins the game. on('quizStart', Quiz), on('quiz', Quiz) - Emitted when the quiz starts for the client. Passes a Quiz class. on('question', Question) - Emitted when the client recieves new question. This is NOT the same as the questionStart event, which is emitted after the question has started. Passes a Question class. on('questionStart', Question) - Emitted when a question starts. 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. on('finish', QuizFinishEvent) - 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'), on('disconnect') - Emitted when the quiz closes, and the client is disconnected. Methods join(sessionID, playerName) Parameters: sessionID (number) - The Kahoot session ID to join. playerName (string) - The name of the user. Returns: Promise answerQuestion(id) Parameters: id (number) - The ID of the question to answer. (0 is the first answer, 1 is the second answer, etc.) Returns: Promise leave() Returns: Promise Properties sendingAnswer (boolean) - Whether or not the client is currently sending an answer. token (String) - The client token of the user. sessionID (Number) - The the session ID of the quiz. name (String) - The user's name. quiz (Quiz) - The current quiz of the client. nemesis (Nemesis) - The client's nemesis. (Will be null if the client does not have a nemesis.) nemeses (Nemesis Array) - An array of all the client's past nemeses.

Quiz

Properties client (Kahoot) - The client the quiz is attached. name (String) - The name of the quiz. type (String) - The quiz type. currentQuestion (Question) - The current question the quiz is on. questions (Question Array) - An array of every single question in the quiz. New questions get added as they come in.

Question

Methods answer(number) Parameters: number (Number) - The question number to answer. (0 is the first answer, 1 is the second answer, etc.)

Properties client (Kahoot) - The client attached to the question. quiz (Quiz) - The quiz that the question for. index (Number) - The index of the question. timeLeft (Number) - The time left in the question. type (String) - The question type. usesStoryBlocks (Boolean) - Whether or not the question uses 'Story Blocks'. ended (Boolean) - Whether or not the question has ended. number (Number) - The number of the question.

QuestionEndEvent

Properties client (Kahoot) - The client attached to the event. quiz (Quiz) - The quiz that the event is attached to. question (Question) - The question that the event is attached to. correctAnswers (String Array) - A list of the correct answers. correctAnswer (String) - The correct answer. (if there are multiple correct answers, this will be the first in the array.) text (String) - The text sent by Kahoot after a question has finished. correct (Boolean) - Whether or not the client got the question right. nemesis (Nemesis) - The client's nemesis. (Will be null if the client does not have a nemesis.)

QuestionSubmitEvent

Properties message (String) - The message sent by Kahoot after you sent in an answer. client (Kahoot) - The client attached to the event. quiz (Quiz) - The quiz attached to the event. question (Question) - The question attached to the event.

Nemesis

Properties name (String) - The name of the nemesis user. id (Number / String) - The client ID of the user score (Number) - The score of the nemesis user. isKicked (Boolean) - Whether or not the nemesis user is kicked or not. exists (Boolean) - Whether or not the nemesis exists (All other values will be undefined if this is false)

FinishTextEvent

Properties firstMessage (String) - The first finishing message sent by Kahoot. secondMessage (String) - The second message sent by Kahoot. (this property will be undefined if a second message was not sent.) messages (String Array) - An array of the messages sent. metal (String) - The medal recieved after the quiz.

QuizFinishEvent

Properties client (Kahoot) - The client attached to the event. quiz (Quiz) - The quiz attached to the event. players (Number) - The number of players on the quiz. quizID (String) - The ID of the quiz. rank (Number) - The client's ranking on the quiz. correct (Number) - The number of questions that were scored correct. incorrect (Number) - The number of questions that were scored incorrect.