Skip to main content

Polls

FunctionReturns
getPollsPromise<PaginatedResult<Poll>>
getPollsByIdsPromise<Array<Poll>>
getPollByIdPromise<Poll | null>
createPollPromise<Poll>
endPollPromise<Poll>

Functions​

getPolls​

twitch.poll.getPolls(pagination?: ForwardPagination): Promise<PaginatedResult<Poll>>

getPollsByIds​

twitch.poll.getPollsByIds(pollIds: Array<string>): Promise<Array<Poll>>

getPollById​

twitch.poll.getPollById(pollId: string): Promise<Poll | null>

createPoll​

twitch.poll.createPoll(data: CreatePoll): Promise<Poll>

endPoll​

twitch.poll.endPoll(pollId: string, showResult?: boolean): Promise<Poll>

Types​

CreatePoll​

type CreatePoll = {
title: string
choices: Array<string>
duration: number
channelPointsPerVote?: number
}

ForwardPagination​

type ForwardPagination = {
limit?: number
after?: string
}

PaginatedResult​

type PaginatedResult<T> = {
data: Array<T>
cursor?: string
}

Poll​

type Poll = {
id: string
broadcasterId: string
broadcasterLogin: string
broadcasterName: string
title: string
choices: Array<PollChoice>
bitsVotingEnabled: boolean
bitsPerVote: number
channelPointsVotingEnabled: boolean
channelPointsPerVote: number
status: PollStatus
duration: number
startedAt: string
}

PollChoice​

type PollChoice = {
id: string
title: string
votes: number
channelPointsVotes: number
bitsVotes: number
}

PollStatus​

type PollStatus = "ACTIVE" | "COMPLETED" | "TERMINATED" | "ARCHIVED" | "MODERATED" | "INVALID"