Skip to content
twitch.apiv2.0

Reference / API groups

twitch.bits

Bits: leaderboard, Cheermotes, custom Power-ups and extension transactions.

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

twitch.bits.leaderboard(params?, options?): Promise<BitsLeaderboard>

Gets the Bits leaderboard of the channel of the user making the call, over its whole life or over a given day, week, month or year.

Token: user, scope bits:read.

NameTypeDescription
countnumberNumber of entries to return, 1 to 100. Twitch defaults to 10.
period"day" | "week" | "month" | "year" | "all"Length of the period to rank, counted in Pacific time. Twitch defaults to "all", the whole life of the channel.
started_atstring | DateA moment inside the period to rank. Needed for every period except "all". Twitch converts it to Pacific time before picking the day, week, month or year it falls in.
user_idstringCenters the result on this user, with the ranks just above and below when count allows.

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

Promise<BitsLeaderboard>

Fields of BitsLeaderboard
NameTypeDescription
dataBitsLeaderboardEntry[]Ranked users, biggest cheerer first. Empty when nobody cheered.
date_range{ started_at: string; ended_at: string; }The period the ranking covers. Both fields are empty strings when started_at was not given.
totalnumberNumber of entries in data.
const top = await twitch.bits.leaderboard({ count: 5 });
for (const entry of top.data) console.log(entry.rank, entry.user_name, entry.score);
const week = await twitch.bits.leaderboard({ period: "week", started_at: new Date() });

Twitch reference

twitch.bits.cheermotes(params?, options?): Promise<Cheermote[]>

Lists the Cheermotes usable in every channel, plus the custom ones of a broadcaster when you name one.

Token: app or user.

NameTypeDescription
broadcaster_idstringAlso include the custom Cheermotes of this broadcaster. Without it only the global ones are returned.

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

Promise<Cheermote[]>

Fields of Cheermote
NameTypeDescription
prefixstringText typed before the amount. Cheer gives Cheer100.
tiersCheermoteTier[]Levels of the Cheermote, each with its own images.
type"global_first_party" | "global_third_party" | "channel_custom" | "display_only" | "sponsored"Where the Cheermote comes from: Twitch (global_first_party in the Bits card, global_third_party outside of it), a broadcaster (channel_custom) or a sponsor who adds Bits on top (sponsored). display_only is internal to Twitch.
ordernumberPosition in the Bits card. Unique within one type only, and not always consecutive.
last_updatedstringWhen the Cheermote was last changed, as an RFC 3339 timestamp.
is_charitablebooleanWhether cheering with it is matched by a contribution during charity campaigns.
const cheermotes = await twitch.bits.cheermotes({ broadcaster_id: "141981764" });

Twitch reference

twitch.bits.customPowerUps(params?, options?): Promise<CustomPowerUp[]>

Lists the custom Power-ups a broadcaster created, enabled or not. Asking for IDs of which none exists fails with a 404.

Token: user, scope bits:read.

NameTypeDescription
broadcaster_idstringBroadcaster who created the Power-ups. Defaults to the user making the call.
idstring | readonly string[]Only these Power-ups. Any number: long lists are split for you.

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

Promise<CustomPowerUp[]>

Fields of CustomPowerUp
NameTypeDescription
broadcaster_idstringID of the broadcaster.
broadcaster_loginstringLogin name of the broadcaster.
broadcaster_namestringDisplay name of the broadcaster.
idstringID of the Power-up.
titlestringTitle of the Power-up.
promptstringQuestion shown to the viewer when is_user_input_required is true.
bitsnumberPrice in Bits.
imageCustomPowerUpImage | nullImages uploaded by the broadcaster, or null when there are none.
default_imageCustomPowerUpImageImages Twitch falls back to.
background_colorstringBackground color as a hex code, such as #00E5CB.
is_enabledbooleanWhether the Power-up is enabled. Disabled ones are hidden from viewers.
is_user_input_requiredbooleanWhether the viewer has to type something when redeeming.
max_per_stream_setting{ is_enabled: boolean; max_per_stream: number; }Cap on redemptions per live stream.
max_per_user_per_stream_setting{ is_enabled: boolean; max_per_user_per_stream: number; }Cap on redemptions per viewer per live stream.
global_cooldown_setting{ is_enabled: boolean; global_cooldown_seconds: number; }Pause imposed between two redemptions.
is_pausedbooleanWhether the Power-up is paused. Paused ones cannot be redeemed.
is_in_stockbooleanWhether the Power-up is in stock. Out of stock ones cannot be redeemed.
redemptions_redeemed_current_streamnumber | nullRedemptions counted against the per stream cap so far, or null when the channel is offline or the cap is off.
cooldown_expires_atstring | nullWhen the cooldown ends, as an RFC 3339 timestamp, or null when none is running.
const powerUps = await twitch.bits.customPowerUps();

Twitch reference

twitch.bits.extensionTransactions(params, options?): Paginator<ExtensionTransaction>

Lists the purchases made with Bits inside an extension. Only works with the app token of the extension itself.

Token: app.

NameTypeDescription
extension_id requiredstringID of the extension. It must be the client ID the app token was issued for.
idstring | readonly string[]Only these transactions. Up to 100 IDs.
firstnumberItems per page, 1 to 100. Twitch defaults to 20.
afterstringCursor of the next page.

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

Paginator<ExtensionTransaction>

Fields of ExtensionTransaction
NameTypeDescription
idstringID of the transaction.
timestampstringWhen the purchase was made, as an RFC 3339 timestamp.
broadcaster_idstringID of the broadcaster on whose channel the purchase was made.
broadcaster_loginstringLogin name of that broadcaster.
broadcaster_namestringDisplay name of that broadcaster.
user_idstringID of the buyer.
user_loginstringLogin name of the buyer.
user_namestringDisplay name of the buyer.
product_type"BITS_IN_EXTENSION"Kind of transaction.
product_data{ sku: string; domain: string; cost: { amount: number; type: "bits"; }; inDevelopment: boolean; displayName: string; expiration: string; broadcast: boolean; }The product that was bought.
for await (const transaction of twitch.bits.extensionTransactions({ extension_id: "uo6dggojyb8d6soh92zknwmi5ej1q2" })) {
console.log(transaction.user_name, transaction.product_data.sku);
}

Twitch reference