Git Product home page Git Product logo

kahootapi's Introduction

KahootAPI

About

As the title suggests, this api is capable of communicating with the kahoot servers to simulate a kahoot client.

Version

The current version is 1.0

Features

Included

  • Functionality to join classic games
  • Receiving all events sent by the server
  • Answering classic and true or false questions
  • Obtain pretty much all information possible about the current gameplay

Scheduled

  • Giving feedback to the creator

Missing

  • Sending answers to questions that are exclusive to pro creators
  • Participating in team games

Disclaimer

This project is only intended for educational purpose.

Usage

Getting the API

There are two main ways for getting the api:

Dependency Manager

If you want to manage it with a dependency manager like Gradle or maven, you can get it from jitpack: https://jitpack.io/#virtcode/kahootapi/1.0

Without Dependency Management

If you want to include the libary the old fashioned way, you can download it as an jar with or without dependencies in the release section of this repository.

In Code

If you want to check whether a game with a certain pin is hosted, you can check this like that:

Kahoot.gameExists("[game-code]", exists -> {
  if (exists) //exists
  else //does not exist
});

If you now want to join a existent game, you can do this like that:

Kahoot.joinGame("[player-name]", "[game-id]", [your-game-wrapper]);

As you see, you first need to create a game wrapper. To create one, you should create a class extening:

  • Game, if you want to process the game relatively low level
  • AdvancedGame, if you want to process the game with methods for each event and methods to send answers to the server

With subclass of Game

Now you should override all needed methods. You get:

  • playerMessageReceived - Tells you when and what message from the player channel has been recieved
  • controllerMessageReceived - Tells you when and what message from the status channel has been recieved
  • statusMessageReceived - Tells you when and what message from the status channel has been recieved
  • connectionFailure - Tells you whether and why the connection failed
  • connectionSuccess - Tells you that the connection succeeded For more indepth knowledge, you can look into the provided JavaDoc

With subclass of AdvancedGame

Now you should override all needed methods here too. You get:

  • the connection confirmation methods from above
  • methods for when an unrecognized packet has been received: unknownPlayerEvent, unkownStatusEvent, unkownControllerEvent. Those methods work as the message methods from above
  • methods for every recognized event from the server. You also can call the methods:
  • sendAnswer - This method sends an answer package back to the server with its given credentials
  • sendFeedback - This method does currently not work though I think all here listed methods are pretty self explainatory but if you want to know more, you can have a look at the JavaDoc too.
Example

To get you started right away, here is a small example: In your main class call:

Kahoot.joinGame("[player-name]", "[game-id]", new [your-class-to-process-the-game]());

Now in your "class to process the game" class extend AdvancedGame and override all needed methods. You should create following variables:

private Integer[] questions;

In your quizStart method you should write:

this.questions = questions.toArray(new Integer[0]);

And finally in your questionActive method:

sendAnswer(index, (int) Math.floor(Math.random() * questions[index]));

As you might have already guessed, you have created a client that sends a random answer to each question. Of course you can now replaye the choice with an input got from the user and create like so a kahoot client.

Licence

This project is licenced under the MIT Licence. Please consider reading the LICENCE file for more information.

kahootapi's People

Contributors

virtcode avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

kahootapi's Issues

Creating questions incl. answers?

Hello,
is it also possible to create questions with this API?

Why? I would like to create a "math quiz"... Simple calculations like 3+45+3 = .... or 34-50-1 and so on and the terms and solutions are created with an program and I would like to use this output to feed the API

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.