Skip to content
twitch.apiv2.0

Reference / API groups

twitch.predictions

Predictions: create, read, lock and resolve them.

Every method of twitch.predictions, with its parameters, what it returns and the token it needs.

twitch.predictions.get(params?, options?): Paginator<Prediction>

Lists the predictions of a channel, most recent first.

Token: user, scope channel:read:predictions or channel:manage:predictions.

NameTypeDescription
broadcaster_idstringBroadcaster whose predictions to list. Defaults to the user making the call.
idstring | readonly string[]Only these predictions. Up to 25 IDs.
firstnumberItems per page, 1 to 25. Twitch defaults to 20.
afterstringCursor of the next page.

options: Request options for this call: as, token, signal, timeout, retries.

Paginator<Prediction>

Fields of Prediction
NameTypeDescription
idstringID of the prediction.
broadcaster_idstringID of the broadcaster who ran the prediction.
broadcaster_namestringDisplay name of the broadcaster.
broadcaster_loginstringLogin name of the broadcaster.
titlestringQuestion the viewers bet on.
winning_outcome_idstring | nullID of the outcome that won. null until the prediction is resolved.
outcomesPredictionOutcome[]Outcomes viewers can pick.
prediction_windownumberHow long viewers can bet, in seconds.
statusPredictionStatusState of the prediction: ACTIVE while bets are open, LOCKED once they are closed, RESOLVED when a winner was picked and points paid out, CANCELED when everyone was refunded.
created_atstringWhen the prediction started, as an RFC 3339 timestamp.
ended_atstring | nullWhen the prediction ended, as an RFC 3339 timestamp. null while it is active.
locked_atstring | nullWhen bets were closed, as an RFC 3339 timestamp. null when the prediction is not locked.
const latest = await twitch.predictions.get().first();

Twitch reference

twitch.predictions.create(params, options?): Promise<Prediction>

Starts a prediction in a channel. Bets open at once, and a channel can only run one prediction at a time.

Token: user, scope channel:manage:predictions.

NameTypeDescription
broadcaster_idstringBroadcaster who runs the prediction. Defaults to the user making the call.
title requiredstringQuestion the viewers bet on, 45 characters at most.
outcomes requiredreadonly (string | { title: string; })[]Two to ten outcomes, each 25 characters at most. Plain strings work too.
prediction_window requirednumberHow long viewers can bet, in seconds, 30 to 1800.

options: Request options for this call: as, token, signal, timeout, retries.

Promise<Prediction>

Fields of Prediction
NameTypeDescription
idstringID of the prediction.
broadcaster_idstringID of the broadcaster who ran the prediction.
broadcaster_namestringDisplay name of the broadcaster.
broadcaster_loginstringLogin name of the broadcaster.
titlestringQuestion the viewers bet on.
winning_outcome_idstring | nullID of the outcome that won. null until the prediction is resolved.
outcomesPredictionOutcome[]Outcomes viewers can pick.
prediction_windownumberHow long viewers can bet, in seconds.
statusPredictionStatusState of the prediction: ACTIVE while bets are open, LOCKED once they are closed, RESOLVED when a winner was picked and points paid out, CANCELED when everyone was refunded.
created_atstringWhen the prediction started, as an RFC 3339 timestamp.
ended_atstring | nullWhen the prediction ended, as an RFC 3339 timestamp. null while it is active.
locked_atstring | nullWhen bets were closed, as an RFC 3339 timestamp. null when the prediction is not locked.
const prediction = await twitch.predictions.create({
title: "Will the boss go down first try?",
outcomes: ["Yes", "No"],
prediction_window: 120,
});

Twitch reference

twitch.predictions.end(params, options?): Promise<Prediction>

Locks, resolves or cancels a prediction. One left unresolved for 24 hours after its window closed is canceled by Twitch and the points are refunded.

Token: user, scope channel:manage:predictions.

NameTypeDescription
broadcaster_idstringBroadcaster who runs the prediction. Defaults to the user making the call.
id requiredstringID of the prediction to update.
status required"CANCELED" | "LOCKED" | "RESOLVED""LOCKED" closes the bets, "RESOLVED" pays out the winners, "CANCELED" refunds everyone. A locked prediction can still be resolved or canceled.
winning_outcome_idstringID of the outcome that won. Required when status is "RESOLVED".

options: Request options for this call: as, token, signal, timeout, retries.

Promise<Prediction>

Fields of Prediction
NameTypeDescription
idstringID of the prediction.
broadcaster_idstringID of the broadcaster who ran the prediction.
broadcaster_namestringDisplay name of the broadcaster.
broadcaster_loginstringLogin name of the broadcaster.
titlestringQuestion the viewers bet on.
winning_outcome_idstring | nullID of the outcome that won. null until the prediction is resolved.
outcomesPredictionOutcome[]Outcomes viewers can pick.
prediction_windownumberHow long viewers can bet, in seconds.
statusPredictionStatusState of the prediction: ACTIVE while bets are open, LOCKED once they are closed, RESOLVED when a winner was picked and points paid out, CANCELED when everyone was refunded.
created_atstringWhen the prediction started, as an RFC 3339 timestamp.
ended_atstring | nullWhen the prediction ended, as an RFC 3339 timestamp. null while it is active.
locked_atstring | nullWhen bets were closed, as an RFC 3339 timestamp. null when the prediction is not locked.
await twitch.predictions.end({ id: predictionId, status: "LOCKED" });
await twitch.predictions.end({ id: predictionId, status: "RESOLVED", winning_outcome_id: outcomeId });

Twitch reference