TwurpleAuthenticationGetting dataExamplesFAQMigration

Main classes

HelixPredictionApi

The Helix API methods that deal with predictions.

Overview

Can be accessed using client.predictions on an ApiClient instance.

Example

const api = new ApiClient({ authProvider });
const { data: predictions } = await api.helix.predictions.getPredictions('61369223');

Methods

cancelPrediction(broadcaster, id)

async

Cancels a prediction.

ParameterTypeRequiredDefaultDescription
broadcaster
UserIdResolvable

A user ID or a user or channel object.

This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name.

Aliased type: string | number | UserIdResolvableType

none

The broadcaster to cancel the prediction for.

idstringnone

The ID of the prediction to cancel.

Return type: HelixPrediction

createPrediction(broadcaster, data)

async

Creates a new prediction.

ParameterTypeRequiredDefaultDescription
broadcaster
UserIdResolvable

A user ID or a user or channel object.

This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name.

Aliased type: string | number | UserIdResolvableType

none

The broadcaster to create the prediction for.

dataHelixCreatePredictionDatanonesee below
data.autoLockAfternumbernone

The time after which the prediction will be automatically locked, in seconds from creation.

data.outcomesstring[]none

The possible outcomes for the prediction.

data.titlestringnone

The title of the prediction.

Return type: HelixPrediction

getPredictionById(broadcaster, id)

async

Gets a prediction by ID.

ParameterTypeRequiredDefaultDescription
broadcaster
UserIdResolvable

A user ID or a user or channel object.

This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name.

Aliased type: string | number | UserIdResolvableType

none

The broadcaster to get the prediction for.

idstringnone

The ID of the prediction.

Return type: HelixPrediction | null

getPredictions(broadcaster, pagination)

async

Gets a list of predictions for the given broadcaster.

ParameterTypeRequiredDefaultDescription
broadcaster
UserIdResolvable

A user ID or a user or channel object.

This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name.

Aliased type: string | number | UserIdResolvableType

none

The broadcaster to get predictions for.

paginationHelixForwardPaginationnonesee below
pagination.afterstringnone

A cursor to get the following page of.

pagination.limitnumbernone

The number of results per page.

getPredictionsByIds(broadcaster, ids)

async

Gets predictions by IDs.

ParameterTypeRequiredDefaultDescription
broadcaster
UserIdResolvable

A user ID or a user or channel object.

This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name.

Aliased type: string | number | UserIdResolvableType

none

The broadcaster to get the predictions for.

idsstring[]none

The IDs of the predictions.

Return type: HelixPrediction[]

getPredictionsPaginated(broadcaster)

Creates a paginator for predictions for the given broadcaster.

ParameterTypeRequiredDefaultDescription
broadcaster
UserIdResolvable

A user ID or a user or channel object.

This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name.

Aliased type: string | number | UserIdResolvableType

none

The broadcaster to get predictions for.

Return type: HelixPaginatedRequest<HelixPredictionData, HelixPrediction>

lockPrediction(broadcaster, id)

async

Locks a prediction.

ParameterTypeRequiredDefaultDescription
broadcaster
UserIdResolvable

A user ID or a user or channel object.

This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name.

Aliased type: string | number | UserIdResolvableType

none

The broadcaster to lock the prediction for.

idstringnone

The ID of the prediction to lock.

Return type: HelixPrediction

resolvePrediction(broadcaster, id, outcomeId)

async

Resolves a prediction.

ParameterTypeRequiredDefaultDescription
broadcaster
UserIdResolvable

A user ID or a user or channel object.

This is not a user name. Please use HelixUserApi#getUserByName to fetch a user object by name.

Aliased type: string | number | UserIdResolvableType

none

The broadcaster to resolve the prediction for.

idstringnone

The ID of the prediction to resolve.

outcomeIdstringnone

The ID of the winning outcome.

Return type: HelixPrediction