TwurpleAuthenticationGetting dataExamplesFAQMigration

Main classes

HelixChatApi

The Helix API methods that deal with chat.

Overview

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

Example

const api = new ApiClient({ authProvider });
const rewards = await api.chat.getChannelBadges('125328655');

Methods

getChannelBadges(broadcaster)

async

Gets all badges specific to 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 badges for.

Return type: HelixChatBadgeSet[]

getChannelEmotes(broadcaster)

async

Gets all emotes specific to 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 emotes for.

Return type: HelixChannelEmote[]

getChatters(broadcaster, pagination)

async

Gets the list of users that are connected to the broadcaster’s chat session.

This uses the token of the broadcaster by default. If you want to execute this in the context of another user (who has to be moderator of the channel) you can do so using user context overrides.

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 whose list of chatters you want to get.

paginationHelixForwardPaginationnonesee below
pagination.afterstringnone

A cursor to get the following page of.

pagination.limitnumbernone

The number of results per page.

getChattersPaginated(broadcaster)

Creates a paginator for users that are connected to the broadcaster’s chat session.

This uses the token of the broadcaster by default. If you want to execute this in the context of another user (who has to be moderator of the channel) you can do so using user context overrides.

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 whose list of chatters you want to get.

Return type: HelixPaginatedRequestWithTotal<HelixChatChatterData, HelixChatChatter>

getColorForUser(user)

async

Gets the chat color for a user.

Returns the color as hex code, null if the user did not set a color, or undefined if the user is unknown.

ParameterTypeRequiredDefaultDescription
user
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 user to get the chat color of.

Return type: string | null | undefined

getColorsForUsers(users)

async

Gets the chat colors for a list of users.

Returns a Map with user IDs as keys and their colors as values. The value is a color hex code, or null if the user did not set a color, and unknown users will not be present in the map.

ParameterTypeRequiredDefaultDescription
users
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 users to get the chat colors of.

Return type: Map<string, string | null>

getEmotesFromSets(setIds)

async

Gets all emotes from a list of emote sets.

ParameterTypeRequiredDefaultDescription
setIdsstring[]none

The IDs of the emote sets to get emotes from.

Return type: HelixEmoteFromSet[]

getGlobalBadges()

async

Gets all global badges.

Return type: HelixChatBadgeSet[]

getGlobalEmotes()

async

Gets all global emotes.

Return type: HelixEmote[]

getSettings(broadcaster)

async

Gets the settings of a broadcaster's chat.

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 the chat belongs to.

Return type: HelixChatSettings

getSettingsPrivileged(broadcaster)

async

Gets the settings of a broadcaster's chat, including the delay settings.

This uses the token of the broadcaster by default. If you want to execute this in the context of another user (who has to be moderator of the channel) you can do so using user context overrides.

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 the chat belongs to.

sendAnnouncement(broadcaster, announcement)

async

Sends an announcement to a broadcaster's chat.

This uses the token of the broadcaster by default. If you want to execute this in the context of another user (who has to be moderator of the channel) you can do so using user context overrides.

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 the chat belongs to.

announcementHelixSendChatAnnouncementParamsnone

The announcement to send.

Return type: void

sendChatMessage(broadcaster, message, params)

async

Sends a chat message to a broadcaster's chat.

This uses the token of the broadcaster by default. If you want to execute this in the context of another user you can do so using user context overrides.

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 the chat belongs to.

messagestringnone

The message to send.

paramsHelixSendChatMessageParamsnonesee below
params.replyParentMessageIdstringnone

The ID of the chat message being replied to. If this is not set, message will not be sent as a reply.

sendChatMessageAsApp(user, broadcaster, message, params)

async

Sends a chat message to a broadcaster's chat, using an app token.

This requires the scopes user:write:chat and user:bot for the user and channel:bot for the broadcaster. channel:bot is not required if the user has moderator privileges in the broadcaster's channel.

These scope requirements can not be checked by the library, so they are just assumed. Make sure to catch authorization errors yourself.

ParameterTypeRequiredDefaultDescription
user
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 user to send the chat message from.

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 the chat belongs to.

messagestringnone

The message to send.

paramsHelixSendChatMessageParamsnonesee below
params.replyParentMessageIdstringnone

The ID of the chat message being replied to. If this is not set, message will not be sent as a reply.

setColorForUser(user, color)

async

Changes the chat color for a user.

ParameterTypeRequiredDefaultDescription
user
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 user to change the color of.

color
HelixChatUserColor

Colors that can be used by users in chat.

Note that hex codes can only be used by users that have a Prime or Turbo subscription.

Aliased type: "blue" | "blue_violet" | "cadet_blue" | "chocolate" | "coral" | "dodger_blue" | "firebrick" | "golden_rod" | "green" | "hot_pink" | "orange_red" | "red" | "sea_green" | "spring_green" | "yellow_green" | `#${string}`

none

The color to set.

Note that hex codes can only be used by users that have a Prime or Turbo subscription.

Return type: void

shoutoutUser(from, to)

async

Sends a shoutout to the specified broadcaster. The broadcaster may send a shoutout once every 2 minutes. They may send the same broadcaster a shoutout once every 60 minutes.

This uses the token of the broadcaster by default. If you want to execute this in the context of another user (who has to be moderator of the channel) you can do so using user context overrides.

ParameterTypeRequiredDefaultDescription
from
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 ID of the broadcaster that’s sending the shoutout.

to
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 ID of the broadcaster that’s receiving the shoutout.

Return type: void

updateSettings(broadcaster, settings)

async

Updates the settings of a broadcaster's chat.

This uses the token of the broadcaster by default. If you want to execute this in the context of another user (who has to be moderator of the channel) you can do so using user context overrides.

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 the chat belongs to.

settingsHelixUpdateChatSettingsParamsnone

The settings to change.

settings.emoteOnlyModeEnabledbooleannone

Whether emote only mode should be enabled.

settings.followerOnlyModeDelaynumbernone

The time after which users should be able to send messages after following, in minutes.

settings.followerOnlyModeEnabledbooleannone

Whether follower only mode should be enabled.

settings.nonModeratorChatDelaynumbernone

The delay of non-moderator messages, in seconds.

settings.nonModeratorChatDelayEnabledbooleannone

Whether non-moderator messages should be delayed.

settings.slowModeDelaynumbernone

The time to wait between messages in slow mode, in seconds.

settings.slowModeEnabledbooleannone

Whether slow mode should be enabled.

settings.subscriberOnlyModeEnabledbooleannone

Whether subscriber only mode should be enabled.

settings.uniqueChatModeEnabledbooleannone

Whether unique chat mode should be enabled.