Skip to content

Class: PredictionService ​

Service for Kappapps native predictions: viewers bet the channel's internal currency on an outcome (chat or in-app), winners share the pot proportionally when the prediction is resolved. Optional native on-screen display.

Remarks ​

Accessible everywhere via k.prediction. You never have to instantiate this service yourself — it is created by the SDK when the app/widget starts. Only one prediction can be running at a time on a channel. Bets are optional: with betting_enabled: false, viewers simply predict and winners can receive a fixed_reward.

The backend keeps collecting native votes after this execution ends. Live events and controls target the current pilot execution; the owner installation can take over with resume(id). The streamer retains dashboard control.

Example ​

ts
const prediction = await k.prediction.start({
    title: 'Victory?',
    outcomes: ['Yes', 'No'],
    prediction_window: 180,
    min_bet: 10
});
// ... later, once the result is known:
await prediction.resolve(1);

See ​

PollService for simple polls.

Implements ​

Constructors ​

Constructor ​

ts
new PredictionService(): PredictionService;

Returns ​

PredictionService

Methods ​

get() ​

ts
get(id): Promise<Prediction>;

Read an existing prediction, including final state, without transferring control.

Parameters ​

id ​

number

Returns ​

Promise<Prediction>


getRunning() ​

ts
getRunning(): Promise<PredictionData>;

Retrieves the channel's currently running prediction (open or locked), if any.

Returns ​

Promise<PredictionData>

The running prediction data (PredictionData), or null when no prediction is running.

Remarks ​

Read-only snapshot. Events and control target the current pilot execution. After restart, the owner installation can explicitly resume(id). The streamer retains dashboard control.


resume() ​

ts
resume(id): Promise<Prediction>;

Resume this installation's running prediction; keeps all participations and deadlines.

Parameters ​

id ​

number

Returns ​

Promise<Prediction>


start() ​

ts
start(prediction): Promise<Prediction>;

Creates and starts a prediction on the channel.

Parameters ​

prediction ​

PredictionCreateData

The prediction creation data (PredictionCreateData).

Returns ​

Promise<Prediction>

The created Prediction, already open to participations; lock it, resolve it or cancel it via its own methods.