Contents

TwitchAPI

The main class

GetAuthState()

Query the current authentication state.

This call always returns immediately.

Syntax

AuthState TwitchSDK::TwitchApi::GetAuthState 	( 		) 	

GetAuthState() 2

Query the current authentication state.

This call always returns immediately.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::GetAuthState 	( 	ResolveFn< const AuthState & >  	resolve,
		RejectFn  	reject 
	) 		

GetStreamInfoById()

Gets information about a specific stream.

Syntax

void TwitchSDK::TwitchApi::GetStreamInfoById 	( 	string_view  	id,
		ResolveFn< const StreamInfo & >  	resolve,
		RejectFn  	reject 
	) 			

Parameters

Parameter Type Description
id string_view The channel ID to query for.

Returns

An object describing the stream, or an empty object if the channel is offline or does not exist.

Initialize()

Initialize the Twitch API.

This is the entry point to the library. This immediately starts several background tasks, e.g., loading credentials from disk, connecting to EventSub, etc.

To stop the library, you need to drop all shared_ptr instances. Then, you also need to transition your platform abstraction layer implementation into a state where it rejects all incoming calls. This is necessary to ensure that all background tasks are terminted and the shared_ptr references inside these callbacks are released.

Syntax

static std::shared_ptr< TwitchApi > TwitchSDK::TwitchApi::Initialize 	( 	std::shared_ptr< PAL::PlatformAbstractionLayer >  	pal,
		string_view  	clientId,
		string_view  	clientSecret,
		bool  	useEventSubProxy = false 
	) 				

Parameters

Parameter Type Description
pal std::shared_ptr< PAL::PlatformAbstractionLayer > The platform abstraction layer implementation to use.
clientId string_view OAuth Client Id
clientSecret string_view OAuth Secret
useEventSubProxy bool Do not enable this in releases. This option instructs the plugin to connect to a local EventSubProxy instead of directly to Twitch.

Returns

An object describing the stream, or an empty object if the channel is offline or does not exist.

RefreshOAuthToken()

Fetch a frech OAuth token that can be used for the Enhanced Experiences SDK.

This call will block indefinitely if the player is not logged in.

Syntax

virtual void TwitchSDK::TwitchApi::RefreshOAuthToken 	( 	ResolveFn< string_view >  	resolve	) 	

SubscribeToChannelCheerEvents()

A user cheers on the specified channel.

Syntax

TwitchEventStream< ChannelCheerEvent > TwitchSDK::TwitchApi::SubscribeToChannelCheerEvents 	( 		) 	

SubscribeToChannelFollowEvents()

A specified channel receives a follow.

Syntax

TwitchEventStream< ChannelFollowEvent > TwitchSDK::TwitchApi::SubscribeToChannelFollowEvents 	( 		) 	

SubscribeToChannelRaidEvents()

A broadcaster raids another broadcaster’s channel.

Syntax

TwitchEventStream< ChannelRaidEvent > TwitchSDK::TwitchApi::SubscribeToChannelRaidEvents 	( 		) 	

SubscribeToChannelSubscribeEvents()

A notification when a specified channel receives a subscriber. This does not include resubscribes.

Syntax

TwitchEventStream< ChannelSubscribeEvent > TwitchSDK::TwitchApi::SubscribeToChannelSubscribeEvents 	( 		) 	

SubscribeToCustomRewardEvents()

A viewer has redeemed a custom channel points reward on the specified channel or the redemption has been updated (i.e., fulfilled or cancelled).

Syntax

TwitchEventStream< CustomRewardEvent > TwitchSDK::TwitchApi::SubscribeToCustomRewardEvents 	( 		) 	

SubscribeToHypeTrainEvents()

A Hype Train makes progress on the user’s channel. Requires the channel:read:hype_train scope.

Syntax

TwitchEventStream< HypeTrainEvent > TwitchSDK::TwitchApi::SubscribeToHypeTrainEvents 	( 		) 	

UnsubscribeFromPoll()

Unsubscribe from updates for a specific poll.

You must not invoke this function multiple times for the same poll. Unsubscribing from polls is optional. Failing to do so results in unnecessary traffic, but will not cause any malfunction or memory leak.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::UnsubscribeFromPoll 	( 	string_view  	id,
		ResolveFn< void >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
id string_view Id of the poll to unsubscribe from.

Implements

TwitchSDK::ITwitchApiCommon

UnsubscribeFromPoll() 2

Unsubscribe from updates for a specific poll.

You must not invoke this function multiple times for the same poll. Unsubscribing from polls is optional. Failing to do so results in unnecessary traffic, but will not cause any malfunction or memory leak.

Syntax

void TwitchSDK::TwitchApi::UnsubscribeFromPoll 	( 	string_view  	id	) 	

Parameters

Parameter Type Description
id string_view Id of the poll to unsubscribe from.

UnsubscribeFromPrediction()

Unsubscribe from updates for a specific prediction.

You must not invoke this function multiple times for the same prediction. Unsubscribing from predictions is optional. Failing to do so results in unnecessary traffic, but will not cause any malfunction or memory leak.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::UnsubscribeFromPrediction 	( 	string_view  	id,
		ResolveFn< void >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
id string_view Id of the prediction to unsubscribe from.

Implements

TwitchSDK::ITwitchApiCommon

UnsubscribeFromPrediction() 2

Unsubscribe from updates for a specific prediction.

You must not invoke this function multiple times for the same prediction. Unsubscribing from predictions is optional. Failing to do so results in unnecessary traffic, but will not cause any malfunction or memory leak

Syntax

void TwitchSDK::TwitchApi::UnsubscribeFromPrediction 	( 	string_view  	id	) 	

Parameters

Parameter Type Description
id string_view Id of the prediction to unsubscribe from.

UpdateOAuthCredentials()

Update the OAuth credentials we are currently using. Do not use in production.

This function should only be used to switch to different credentials during development.

Syntax

virtual void R66::R66Api::UpdateOAuthCredentials 	( 	string_view  	clientId,
		string_view  	clientSecret 
	) 	

TwitchApiCommon

The interface containing the API surface that is common across all environments.

AddStreamTag()

Adds a specified tag to the user’s stream.

Required scope: channel:manage:broadcast

Tags expire 72 hours after they are applied, unless the stream is live within that time period. If the stream is live within the 72-hour window, the 72-hour clock restarts when the stream goes offline. The expiration period is subject to change.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::AddStreamTag 	( 	string_view  	id,
		ResolveFn< void >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
id string_view ID of the tag to be added to the stream.

CheckUserSubscription()

Checks if the currently logged-in user is subscribed to a specific channel.

Required scope: user:read:subscriptions

Syntax

virtual void TwitchSDK::ITwitchApiCommon::CheckUserSubscription 	( 	string_view  	broadcaster,
		ResolveFn< const UserSubscriptionCheckResult & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
broadcaster string_view ID of the broadcaster to check for.

CloseEventStream()

Close a Twitch EventSub subscription.

After the subscription is closed, trying to receive events from it is an error.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::CloseEventStream 	( 	const EventStreamDesc &  	desc,
		ResolveFn< void >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
desc EventStreamDesc& An object describing the subscription.

CreateClip()

Creates a clip programmatically. This returns both an ID and an edit URL for the new clip.

Required scope: clips:edit

Creating a clip can take up to 15 seconds.

If hasDelay is false, the clip is captured from the live stream when the API is called; otherwise, a delay is added before the clip is captured (to account for the brief delay between the broadcaster’s stream and the viewer’s experience of that stream).

Syntax

virtual void TwitchSDK::ITwitchApiCommon::CreateClip 	( 	bool  	hasDelay,
		ResolveFn< const ClipInfo & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
hasDelay bool Whether stream delay should be added before capturing the clip.

Returns

An object describing the new clip.

CreatePoll()

Create a poll on the user’s Twitch channel.

Required scope: channel:manage:polls

Creating a poll automatically subscribes to updates for this poll. Avoid unnecessary traffic by invoking UnsubscribeFromPoll at some point for every poll you create.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::CreatePoll 	( 	const PollDefinition &  	p,
		ResolveFn< const PollInfo & >  	resolve,
		RejectFn  	reject 
	) 	

Returns

An object describing the new poll.

CreatePrediction()

Create a Channel Points Prediction on the user’s Twitch channel.

Required scope: channel:manage:predictions

Creating a prediction automatically subscribes to updates for this prediction. Avoid unnecessary traffic by invoking UnsubscribeFromPrediction at some point for every poll you create

Syntax

virtual void TwitchSDK::ITwitchApiCommon::CreatePrediction 	( 	const PredictionDefinition &  	p,
		ResolveFn< const PredictionInfo & >  	resolve,
		RejectFn  	reject 
	) 	

Returns

An object describing the new prediction.

CreateStreamMarker()

Creates a marker in the stream of a user.

Required scope: channel:manage:broadcast

A marker is an arbitrary point in a stream that the broadcaster wants to mark; e.g., to easily return to later. The marker is created at the current timestamp in the live broadcast when the request is processed. Markers can be created by the stream owner or editors.

Markers cannot be created in some cases (an error will occur):

Syntax

virtual void TwitchSDK::ITwitchApiCommon::CreateStreamMarker 	( 	string_view  	description,
		ResolveFn< const StreamMarkerInfo & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
description string_view Optional. Description of or comments on the marker. Max length is 140 characters.

Returns

An object describing the new stream marker.

EndPoll()

End a poll prematurely.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::EndPoll 	( 	const EndPollRequest &  	req,
		ResolveFn< const PollInfo & >  	resolve,
		RejectFn  	reject 
	) 	

Returns

The updated poll info.

EndPrediction()

Lock, resolve, or cancel a Channel Points Prediction.

Required scope: channel:manage:predictions

Syntax

virtual void TwitchSDK::ITwitchApiCommon::EndPrediction 	( 	const EndPredictionRequest &  	req,
		ResolveFn< const PredictionInfo & >  	resolve,
		RejectFn  	reject 
	) 	

Returns

The updated prediction info.

GetAuthenticationInfo()

Start the authorization code flow. If a user is currently logged in, this does nothing. After a successfull call to GetAuthenticationInfo, subsequent calls will return the same AuthenticationInfo until the login is either completed or timed out.

Credentials are stored persistently, so after loggin in successfully and restarting your application, the library remains in the LoggedIn state.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::GetAuthenticationInfo 	( 	string_view  	scopes,
		ResolveFn< const AuthenticationInfo & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
scopes string_view The set of OAuth scopes you would like to request.

GetAuthState()

Query the current authentication state.

This call always returns immediately.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::GetAuthState 	( 	ResolveFn< const AuthState & >  	resolve,
		RejectFn  	reject 
	) 	

Implemented

TwitchSDK::TwitchApi

GetBitsLeaderboard()

Gets a ranked list of Bits leaderboard information for an authorized broadcaster.

Required scope: bits:read

Syntax

virtual void TwitchSDK::ITwitchApiCommon::GetBitsLeaderboard 	( 	const BitsLeaderboardRequest &  	req,
		ResolveFn< const BitsLeaderboard & >  	resolve,
		RejectFn  	reject 
	) 	

GetMyStreamInfo()

Gets information about the currently logged-in user’s stream.

If the user is not logged in, this also waits for a successful login. Returns null if the user is currently not live.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::GetMyStreamInfo 	( 	ResolveFn< const StreamInfo & >  	resolve,
		RejectFn  	reject 
	) 	

GetMyUserInfo()

Gets information about the currently logged-in user’s account.

If the user is not logged in, this also waits for a successful login.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::GetMyUserInfo 	( 	ResolveFn< const UserInfo & >  	resolve,
		RejectFn  	reject 
	) 	

GetUserInfoById()

Gets information about a specific Twitch user account.

Returns an empty object if no such user could be found.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::GetUserInfoById 	( 	string_view  	id,
		ResolveFn< const UserInfo & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
id string_view The account ID to query for.

GetUserInfoByLoginName()

Gets information about a specific Twitch user account.

Returns an empty object if no such user could be found.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::GetUserInfoByLoginName 	( 	string_view  	login,
		ResolveFn< const UserInfo & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
login string_view The login name to query for.

LogOut()

Log out.

This call always returns immediately.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::LogOut 	( 	ResolveFn< void >  	resolve,
		RejectFn  	reject 
	) 	

ModifyChannelInformation()

Modifies channel information for the currently logged-in user.

Required scope: channel:manage:broadcast

Syntax

virtual void TwitchSDK::ITwitchApiCommon::ModifyChannelInformation 	( 	const ModifyChannelInfoRequest &  	req,
		ResolveFn< void >  	resolve,
		RejectFn  	reject 
	) 	

PrepareShutdown()

Prepare for shutdown.

You should invoke this function and wait for it to return before exiting from your game process. This function resets state associated with your session such as available channel points rewards.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::PrepareShutdown 	( 	ResolveFn< void >  	resolve,
		RejectFn  	reject 
	) 	

QueryStreams()

Gets information about active streams. Streams are returned sorted by number of current viewers, in descending order.

Submitting an empty query is valid and fetches the top streams currently on Twitch. Across multiple pages of results, there may be duplicate or missing streams, as viewers join and leave streams.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::QueryStreams 	( 	const StreamQuery &  	query,
		ResolveFn< const StreamQueryResult & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
query StreamQuery& The query to submit to the API.

Returns

An object containing the matching streams and optionally a pagination token to fetch more results

RemoveStreamTag()

Removes a specified tag from the user’s stream.

Required scope: channel:manage:broadcast

Syntax

virtual void TwitchSDK::ITwitchApiCommon::RemoveStreamTag 	( 	string_view  	id,
		ResolveFn< void >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
id string_view ID of the tag to be removed from the stream.

ReplaceCustomRewards()

Updates the set of available custom channel points rewards on a channel.

Required scope: channel:manage:redemptions

If you enable any custom rewards, please clear them by invoking this function with an empty rewards list when the game terminates.

Note that removing rewards that still have pending redemptions will set those redemptions to CustomRewardRedemptionState.Fulfilled.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::ReplaceCustomRewards 	( 	const CustomRewardList &  	req,
		ResolveFn< void >  	resolve,
		RejectFn  	reject 
	) 	

ResolveCustomReward()

Updates the status of Custom Reward Redemption objects on a channel that are in the CustomRewardRedemptionState.Unfulfilled status.

Required scope: channel:manage:redemptions

Syntax

virtual void TwitchSDK::ITwitchApiCommon::ResolveCustomReward 	( 	const CustomRewardResolveRequest &  	req,
		ResolveFn< void >  	resolve,
		RejectFn  	reject 
	) 	

See Also

SubscribeToEventStream, WaitForCustomRewardEvent

SubscribeToEventStream()

Subscribe to a Twitch EventSub stream.

You must periodically receive events from your event stream. You must call CloseEventStream once you are done.

To avoid leaking memory indefinitely in this case, there is an internal limit of 512 buffered events per event stream subscription, as well as an internal limit of 64 subscription per event type in total. When the internal buffer of a subscription is full, incoming events will be discarded silently. When the subscriptions limit is reached, an arbitrary subscription of the same type will be closed, and a warning message will be logged.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::SubscribeToEventStream 	( 	const EventStreamRequest &  	req,
		ResolveFn< const EventStreamDesc & >  	resolve,
		RejectFn  	reject 
	) 	

See Also

WaitForChannelSubscribeEvent, WaitForChannelFollowEvent, WaitForChannelCheerEvent, WaitForCustomRewardEvent, WaitForHypeTrainEvent, WaitForChannelRaidEvent

Returns

An object describing the subscription.

UnsubscribeFromPoll()

Unsubscribe from updates for a specific poll.

You must not invoke this function multiple times for the same poll. Unsubscribing from polls is optional. Failing to do so results in unnecessary traffic, but will not cause any malfunction or memory leak.

Syntax

virtual void TwitchSDK::ITwitchApiCommon::UnsubscribeFromPoll 	( 	string_view  	id,
		ResolveFn< void >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
id string_view Id of the poll to unsubscribe from.

UnsubscribeFromPrediction()

Unsubscribe from updates for a specific prediction.

You must not invoke this function multiple times for the same prediction. Unsubscribing from predictions is optional. Failing to do so results in unnecessary traffic, but will not cause any malfunction or memory leak.

Syntax

virtual void R66::IR66ApiCommon::UnsubscribeFromPrediction 	( 	string_view  	id,
		ResolveFn< void >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
id string_view Id of the prediction to unsubscribe from.

WaitForChannelCheerEvent()

A user cheers on the specified channel.

You may only call this with a subscription for the correct event type.

Syntax

virtual void R66::IR66ApiCommon::WaitForChannelCheerEvent 	( 	const EventStreamDesc &  	desc,
		ResolveFn< const ChannelCheerEvent & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
desc EventStreamDesc& An object describing the subscription.

See Also

SubscribeToEventStream

Returns

The event.

WaitForChannelFollowEvent()

A specified channel receives a follow.

You may only call this with a subscription for the correct event type.

Syntax

virtual void R66::IR66ApiCommon::WaitForChannelFollowEvent 	( 	const EventStreamDesc &  	desc,
		ResolveFn< const ChannelFollowEvent & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
desc EventStreamDesc& An object describing the subscription.

See Also

SubscribeToEventStream

Returns

The event.

WaitForChannelRaidEvent()

A broadcaster raids another broadcaster’s channel.

You may only call this with a subscription for the correct event type.

Syntax

virtual void R66::IR66ApiCommon::WaitForChannelRaidEvent 	( 	const EventStreamDesc &  	desc,
		ResolveFn< const ChannelRaidEvent & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
desc EventStreamDesc& An object describing the subscription.

See Also

SubscribeToEventStream

Returns

The event.

WaitForChannelSubscribeEvent()

A notification when a specified channel receives a subscriber. This does not include resubscribes.

You may only call this with a subscription for the correct event type.

Syntax

virtual void R66::IR66ApiCommon::WaitForChannelSubscribeEvent 	( 	const EventStreamDesc &  	desc,
		ResolveFn< const ChannelSubscribeEvent & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
desc EventStreamDesc& An object describing the subscription.

See Also

SubscribeToEventStream

Returns

The event.

WaitForCustomRewardEvent()

A viewer has redeemed a custom channel points reward on the specified channel or the redemption has been updated (i.e., fulfilled or cancelled).

You may only call this with a subscription for the correct event type.

Syntax

virtual void R66::IR66ApiCommon::WaitForCustomRewardEvent 	( 	const EventStreamDesc &  	desc,
		ResolveFn< const CustomRewardEvent & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
desc EventStreamDesc& An object describing the subscription.

See Also

SubscribeToEventStream, ReplaceCustomRewards

Returns

The event.

WaitForHypeTrainEvent()

A Hype Train makes progress on the user’s channel. Requires the channel:read:hype_train scope.

You may only call this with a subscription for the correct event type.

Syntax

virtual void R66::IR66ApiCommon::WaitForHypeTrainEvent 	( 	const EventStreamDesc &  	desc,
		ResolveFn< const HypeTrainEvent & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
desc EventStreamDesc& An object describing the subscription.

See Also

SubscribeToEventStream

Returns

The event.

WaitForPollUpdate()

Wait for updates to a specified poll. Updates occur when users submit votes, and finally, when the poll ends.

Avoid calling this function on polls after they have ended, as they will no longer recieve updates at that point.

Syntax

virtual void R66::IR66ApiCommon::WaitForPollUpdate 	( 	string_view  	poll,
		ResolveFn< const PollInfo & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
poll string_view Id of the poll to wait for.

Returns

The updated poll info.

WaitForPredictionUpdate()

Wait for updates to a specified prediction. Updates occur when users submit votes, and finally, when the prediction ends.

Avoid calling this function on predictions after they have ended, as they will no longer recieve updates at that point.

Syntax

virtual void R66::IR66ApiCommon::WaitForPredictionUpdate 	( string_view  	prediction,
		ResolveFn< const PredictionInfo & >  	resolve,
		RejectFn  	reject 
	) 	

Parameters

Parameter Type Description
prediction string_view Id of the prediction to wait for.

Returns

The updated prediction info.

Sub Classes

This describes all self contained classes

AuthenticationInfo

Contains information about the authentication

Public Attributes

Parameter Type Description
Uri string_holder The location to send the user to authenticate
UserCode string_holder The code to authenticate with

AuthState

The library’s user authentication state

If Status is AuthStatus.LoggedIn, this is the set of available OAuth scopes.

This may be smaller than the set of scopes you passed to GetAuthenticationInfo if the user logged in with a previous version of your application.

Public Attributes

Parameter Type Description
Status = AuthStatus(0) AuthStatus The current authentication status.
Scopes std::vector< string_holder > If Status is AuthStatus.LoggedIn, this is the set of available OAuth scopes.

BitsLeaderboard

Contains information about the bits leaderboard

Public Attributes

Parameter Type Description
Data vector< BitsLeaderboardEntry > Entries on the bits leaderboard, in no particular order.
StartedAt string_holder Start of the date range for the returned data.
EndedAt string_holder End of the date range for the returned data.

BitsLeaderboardEntry

Contains information about a given entry in the bits leaderboard

Public Attributes

Parameter Type Description
UserId string_holder ID of the user (viewer) in the leaderboard entry.
UserName string_holder Display name corresponding to BitsLeaderboardEntry.UserId.
Rank = 0 int64_t Leaderboard rank of the user.
Score = 0 int64_t Leaderboard score (number of Bits) of the user.

BitsLeaderboardRequest

A requester to pull information about the bits leaderboard.

Public Attributes

Parameter Type Description
Count = 0 int32_t Number of results to be returned. Maximum: 100. Default: 10.
Period string_holder Time period over which data is aggregated (PST time zone). This parameter interacts with BitsLeaderboardRequest.StartedAt. Default: all.
StartedAt string_holder Timestamp for the period over which the returned data is aggregated. Must be in RFC 3339 format.
UserId string_holder ID of the user whose results are returned; i.e., the person who paid for the Bits.

Period

Time period over which data is aggregated (PST time zone). This parameter interacts with BitsLeaderboardRequest.StartedAt. Default: all.

Valid values:

day – 00:00:00 on the day specified in BitsLeaderboardRequest.StartedAt, through 00:00:00 on the following day.
week – 00:00:00 on Monday of the week specified in BitsLeaderboardRequest.StartedAt, through 00:00:00 on the following Monday.
month – 00:00:00 on the first day of the month specified in BitsLeaderboardRequest.StartedAt, through 00:00:00 on the first day of the following month.
year – 00:00:00 on the first day of the year specified in BitsLeaderboardRequest.StartedAt, through 00:00:00 on the first day of the following year.
all – The lifetime of the broadcaster's channel. If this is specified (or used by default), BitsLeaderboardRequest.StartedAt is ignored.

StartedAt

Timestamp for the period over which the returned data is aggregated. Must be in RFC 3339 format.

If this is not provided, data is aggregated over the current period; e.g., the current day/week/month/year. This value is ignored if BitsLeaderboardRequest.Period is all. Currently, the HH:MM:SS part of this value is used only to identify a given day in PST and otherwise ignored. For example, if the BitsLeaderboardRequest.StartedAt value resolves to 5PM PST yesterday and BitsLeaderboardRequest.Period is day, data is returned for all of yesterday.

UserId

ID of the user whose results are returned; i.e., the person who paid for the Bits.

As long as BitsLeaderboardRequest.Count is greater than 1, the returned data includes additional users, with Bits amounts above and below the user specified by BitsLeaderboardRequest.UserId. If BitsLeaderboardRequest.UserId is not provided, the endpoint returns the Bits leaderboard data across top users (subject to the value of BitsLeaderboardRequest.Count).

ChannelCheerEvent

A user cheers on the specified channel.

Public Attributes

Parameter Type Description
IsAnonymous = false bool Whether the user cheered anonymously or not.
UserId string_holder The user ID for the user who cheered on the specified channel. This is null if ChannelCheerEvent.IsAnonymous is true.
UserDisplayName string_holder The user display name for the user who cheered on the specified channel. This is null if ChannelCheerEvent.IsAnonymous is true.
Message string_holder The message sent with the cheer.
Bits = 0 int64_t The number of bits cheered.

ChannelFollowEvent

A specified channel receives a follow.

Public Attributes

Parameter Type Description
UserId string_holder The user ID for the user now following the specified channel.
UserDisplayName string_holder The user display name for the user now following the specified channel.
FollowedAt string_holder RFC3339 timestamp of when the follow occurred.

ChannelRaidEvent

A broadcaster raids another broadcaster’s channel.

Public Attributes

Parameter Type Description
FromBroadcasterId string_holder The broadcaster ID that created the raid.
FromBroadcasterName string_holder The broadcaster display name that created the raid.
ToBroadcasterId string_holder The broadcaster ID that received the raid.
ToBroadcasterName string_holder The broadcaster display name that received the raid.
Viewers = 0 int64_t The number of viewers in the raid.

ChannelSubscribeEvent

A notification when a specified channel receives a subscriber. This does not include resubscribes

Public Attributes

Parameter Type Description
UserId string_holder The user ID for the user who subscribed to the specified channel.
UserLogin string_holder The user login for the user who subscribed to the specified channel.
UserDisplayName string_holder The user display name for the user who subscribed to the specified channel.
Tier string_holder The tier of the subscription. Valid values are 1000, 2000, and 3000.
IsGift = false bool Whether the subscription is a gift.
CumulativeMonths = 0 int32_t The total number of months the user has been subscribed to the channel. This is nonzero only for resubscriptions.
StreakMonths = 0 int32_t The number of consecutive months the user’s current subscription has been active. This value is -1 if the user has opted out of sharing this information. This is nonzero only for resubscriptions.
DurationMonths = 0 int32_t The month duration of the subscription. This is nonzero only for resubscriptions.

ClipInfo

Describes a Clip.

Public Attributes

Parameter Type Description
Id string_holder ID of the clip being queried.
Url string_holder URL where the clip can be viewed.
EmbedUrl string_holder URL to embed the clip.
CreatedAt string_holder Date when the clip was created.
ThumbnailUrl string_holder URL of the clip thumbnail.
Duration = 0 int32_t Duration of the Clip in seconds.

CustomRewardDefinition

A custom reward.

Public Attributes

Parameter Type Description
Title string_holder The title of the reward.
Cost = 0 int64_t The cost of the reward.
Prompt string_holder Optional. The prompt for the viewer when redeeming the reward.
IsEnabled = false bool Optional. Is the reward currently enabled, if false the reward won’t show up to viewers.
BackgroundColor string_holder Optional. Custom background color for the reward.
IsUserInputRequired = false bool Optional. Does the user need to enter information when redeeming the reward.
IsMaxPerStreamEnabled = false bool Optional. Whether a maximum per stream is enabled.
MaxPerStream = 0 Optional. int32_t The maximum number per stream if enabled.
IsMaxPerUserPerStreamEnabled = false bool Optional. Whether a maximum per user per stream is enabled.
MaxPerUserPerStream = 0 int32_t Optional. The maximum number per user per stream if enabled.
IsGlobalCooldownEnabled = false bool Optional. Whether a cooldown is enabled.
GlobalCooldownSeconds = 0 int32_t Optional. The cooldown in seconds if enabled.
ShouldRedemptionsSkipRequestQueue = false bool Optional. Should redemptions be set to CustomRewardRedemptionState.Fulfilled status immediately when redeemed and skip the request queue instead of the normal CustomRewardRedemptionState.Unfulfilled status.

BackgroundColor

Optional. Custom background color for the reward.

Format: Hex with # prefix. Example: #00E5CB.

CustomRewardEvent

A viewer has redeemed a custom channel points reward on the specified channel or the redemption has been updated (i.e., fulfilled or cancelled).

Public Attributes

Parameter Type Description
RedemptionId string_holder The redemption identifier.
BroadcasterId string_holder The requested broadcaster ID.
RedeemerId string_holder User ID of the user that redeemed the reward.
BroadcasterName string_holder The requested broadcaster display name.
RedeemerName string_holder Display name of the user that redeemed the reward.
UserInput string_holder The user input provided. Empty string if not provided.
Status = CustomRewardRedemptionState(0) CustomRewardRedemptionState Status of the redemption. If you resolve or cancel all redemptions from your code, you should discard all events of this type with a status other than CustomRewardRedemptionState.Unfulfilled.
CustomRewardId string_holder The reward identifier.
CustomRewardTitle string_holder The reward name.
CustomRewardCost = 0 int64_t The reward cost.
CustomRewardPrompt string_holder The reward description.
RedeemedAt string_holder RFC3339 timestamp of when the reward was redeemed.

CustomRewardList

The current reward list

Public Attributes

Parameter Type Description
Rewards vector< CustomRewardDefinition > List of rewards

CustomRewardResolveRequest

The request to resolve a given custom reward.

Public Attributes

Parameter Type Description
RedemptionId string_holder ID of the Custom Reward Redemption to update.
CustomRewardId string_holder ID of the Custom Reward the redemptions to be updated are for.
BroadcasterId string_holder The ID of the broadcaster
Resolution = CustomRewardRedemptionState(0) CustomRewardRedemptionState The new status to set redemptions to.

Resolution

The new status to set redemptions to.

Can be either CustomRewardRedemptionState.Fulfilled or CustomRewardRedemptionState.Canceled. Specifying CustomRewardRedemptionState.Canceled will refund the user their Channel Points.

EndPollRequest

Requests a given poll to end

Public Attributes

Parameter Type Description
BroadcasterId string_holder ID of the broadcaster.
PollId string_holder ID of the poll.
ShowResults = false bool If true, sets the poll status to PollStatus.Terminated so that results are shown. If false, sets the poll status to PollStatus.Archived so that the poll is canceled immediately and no results are shown.

EndPredictionRequest

Requests a given prediction to end.

Public Attributes

Parameter Type Description
BroadcasterId string_holder The broadcaster running prediction events.
PredictionId string_holder ID of the Prediction.
Status = PredictionStatus(0) PredictionStatus The Prediction status to be set.
WinningOutcomeId string_holder ID of the winning outcome for the Prediction, if EndPredictionRequest.Status is being set to PredictionStatus.Resolved.

Status

The Prediction status to be set.

Valid values: PredictionStatus.Locked, PredictionStatus.Resolved, PredictionStatus.Canceled

EventStreamDesc

A description for a given stream.

Public Attributes

Parameter Type Description
Kind = EventStreamKind(0) EventStreamKind The kind of eventstream
Token = 0 int32_t Opaque token identifying the subscription. Do not touch.

EventStreamRequest

Request a given stream.

Public Attributes

EventStreamKind Kind = EventStreamKind(0) The kind of EventStream

HypeTrainContribution

Describes a contribution to a Hype Train.

Public Attributes

Parameter Type Description
UserId string_holder The ID of the user who contributed to the Hype Train.
UserName string_holder The display name of the user who contributed to the Hype Train.
Type = HypeTrainContributionType(0) HypeTrainContributionType Type of contribution.
Total = 0 int64_t The total contributed.

HypeTrainEvent

A Hype Train makes progress on the user’s channel. Requires the channel:read:hype_train scope.

Public Attributes

Parameter Type Description
HypeTrainId string_holder The Hype Train ID.
BroadcasterId string_holder The requested broadcaster ID.
BroadcasterName string_holder The requested broadcaster display name.
Level = 0 int32_t The current level of the Hype Train.
TotalPoints = 0 int64_t Total points contributed to the Hype Train.
Progress = 0 int64_t The number of points contributed to the Hype Train at the current level.
Goal = 0 int64_t The number of points required to reach the next level.
StartedAt string_holder The time when the Hype Train started.
ExpiresAt string_holder The time when the Hype Train expires. The expiration is extended when the Hype Train reaches a new level.
EndedAt string_holder The time when the Hype Train ended.
CooldownEndsAt string_holder The time when the Hype Train cooldown ends so that the next Hype Train can start.
TopContributions vector< HypeTrainContribution > The contributors with the most points contributed.
LastContribution HypeTrainContribution The most recent contribution.

CooldownEndsAt

The time when the Hype Train cooldown ends so that the next Hype Train can start.

Empty if the Hype Train has not ended yet.

EndedAt

The time when the Hype Train ended.

Empty if the Hype Train has not ended yet.

ExpiresAt

The time when the Hype Train expires. The expiration is extended when the Hype Train reaches a new level.

This is empty when the Hype Train is over.

Goal

The number of points required to reach the next level.

Set to -1 when the hype train is over.

LastContribution

The most recent contribution.

This is empty when the Hype Train is over.

Progress

The number of points contributed to the Hype Train at the current level.

Set to -1 when the hype train is over.

TopContributions

The contributors with the most points contributed.

Contains a maximum of two objects: one for the top bits contributor and one for the top subscriptions contributor (this includes gifted subscriptions).

ModifyChannelInfoRequest

Used to change a given channel’s information

Public Attributes

Parameter Type Description
GameId string_holder The current game ID being played on the channel. Use “0” to unset the game.
Language string_holder The language of the channel. A language value must be either the ISO 639-1 two-letter code for a supported stream language or “other”.
Title string_holder The title of the stream.
Delay = 0 int32_t Stream delay in seconds. Stream delay is a Twitch Partner feature; trying to set this value for other account types will return a 400 error.

PollChoiceInfo

Information about a given choice from a poll.

Public Attributes

Parameter Type Description
Id string_holder ID for the choice.
Title string_holder Text displayed for the choice.
Votes = 0 int64_t Total number of votes received for the choice across all methods of voting.
ChannelPointsVotes = 0 int64_t Number of votes received via Channel Points.
BitsVotes = 0 int64_t Number of votes received via Bits.

PollDefinition

Contains the information necessary to create a new poll.

Public Attributes

Parameter Type Description
Title string_holder Question displayed for the poll.
Choices vector< R66::string_holder > Array of the poll choices.
Duration = 0 int64_t Total duration for the poll (in seconds).
BitsVotingEnabled = false bool Indicates if Bits can be used for voting.
BitsPerVote = 0 int32_t Number of Bits required to vote once with Bits.
ChannelPointsVotingEnabled = false bool Indicates if Channel Points can be used for voting.
ChannelPointsPerVote = 0 int32_t Number of Channel Points required to vote once with Channel Points.

PollInfo

Describes a Poll on a Twitch channel.

Public Attributes

Parameter Type Description
Id string_holder ID of the poll.
BroadcasterId string_holder ID of the broadcaster.
Title string_holder Question displayed for the poll.
Choices vector< PollChoiceInfo > Array of the poll choices.
BitsVotingEnabled = false bool Indicates if Bits can be used for voting.
BitsPerVote = 0 int32_t Number of Bits required to vote once with Bits.
ChannelPointsVotingEnabled = false bool Indicates if Channel Points can be used for voting.
ChannelPointsPerVote = 0 int32_t Number of Channel Points required to vote once with Channel Points.
Status = PollStatus(0) PollStatus Poll status.
StartedAt string_holder UTC timestamp for the poll’s start time.
EndedAt string_holder UTC timestamp for the poll’s end time. Set to null if the poll is still PollStatus.Active.

PredictionDefinition

Contains the information necessary to create a new prediction.

Public Attributes

Parameter Type Description
Title string_holder Title for the Prediction.
Outcomes vector< R66::string_holder > Array of outcome titles for the Prediction. Array size must be 2. The first outcome object is the “blue” outcome and the second outcome object is the “pink” outcome when viewing the Prediction on Twitch.
Duration = 0 int32_t Total duration for the Prediction (in seconds). Minimum: 1. Maximum: 1800.

PredictionOutcome

Description of a prediction outcome

Public Attributes

Parameter Type Description
Id string_holder ID for the outcome.
Title string_holder Text displayed for outcome.
Users = 0 int64_t Number of unique users that chose the outcome.
ChannelPoints = 0 int64_t Number of Channel Points used for the outcome.
Color string_holder Color for the outcome. Valid values: BLUE, PINK

ResolveFnType< T >

Description.

Public Types

using Fn = std::function< void(T)>

ResolveFnType< void >

Description.

Public Types

using Fn = std::function< void()>

StreamInfo

Describes an active stream on Twitch.

Public Attributes

Parameter Type Description
Id string_holder Stream ID.
UserId string_holder ID of the user who is streaming.
UserLogin string_holder Login of the user who is streaming.
UserName string_holder Display name of the user who is streaming.
GameId string_holder ID of the game being played on the stream.
GameName string_holder Name of the game being played.
Type string_holder Stream type: “live” or “” (in case of error).
Title string_holder Stream title.
ViewerCount = 0 int64_t Number of viewers watching the stream at the time of the query.
StartedAt string_holder UTC timestamp.
Language string_holder Stream language. A language value is either the ISO 639-1 two-letter code for a supported stream language or “other”.
ThumbnailUrl string_holder Thumbnail URL of the stream. All image URLs have variable width and height. You can replace {width} and {height} with any values to get that size image
TagIds vector< R66::string_holder > Shows tag IDs that apply to the stream.
IsMature = false bool Indicates if the broadcaster has specified their channel contains mature content that may be inappropriate for younger audiences.

StreamMarkerInfo

Describes a Stream Marker.

Public Attributes

Parameter Type Description
Id string_holder Unique ID of the marker.
CreatedAt string_holder RFC3339 timestamp of the marker.
Description string_holder Description of the marker.
PositionSeconds = 0 int64_t Relative offset (in seconds) of the marker, from the beginning of the stream.

StreamQuery

Describes a query for streams. All fields are optional.

Public Attributes

Parameter Type Description
After string_holder Cursor for forward pagination: tells the server where to start fetching the next set of results, in a multi-page response. The cursor value specified here is from the PaginationCursor response field of a prior query.
First = 0 int32_t Maximum number of objects to return. Maximum: 100. Default: 20.
GameIds vector< string_holder > Returns streams broadcasting a specified game ID. You can specify up to 100 IDs.
Languages vector< string_holder > Stream language. You can specify up to 100 languages. A language value must be either the ISO 639-1 two-letter code for a supported stream language or “other”.
UserIds vector< string_holder > Returns streams broadcast by one or more specified user IDs. You can specify up to 100 IDs.
UserLogins vector< string_holder > Returns streams broadcast by one or more specified user login names. You can specify up to 100 names.

StreamQueryResult

The results of a stream query.

Public Attributes

Parameter Type Description
Streams vector< StreamInfo > List of streams matching the query.
PaginationCursor string_holder Pagination cursor to fetch the next page of results. May be empty if there are no further results.

StringHolder< TChar >

Holds either a by-value or a by-reference string.

This class contains either a string or a string_view. It enables you to use a string_view whenever possible.

Overloads

StringHolder (string_view s)

StringHolder (string &&s)

StringHolder (const StringHolder &s)

StringHolder (StringHolder &&s) noexcept

Public Attributes

Parameter Type Description  
StringHolder & operator= (const StringHolder &s)    
StringHolder & operator= (StringHolder &&s) noexcept    
const TChar * data () const String data, not null-terminated (like string_view.data()).  
const size_t size () const String length.  
string ToOwned () const Convert to owned string.  

Operators

operator string_view () const

Parameter Type Description
bool operator!= (const StringHolder &other) const  
bool operator== (const StringHolder &other) const  
string operator+ (string lhs, const StringHolder &rhs)  
bool operator== (const StringHolder &lhs, string_view rhs)  

TwitchEventStream< T >

Represents an active EventSub subscription.

Destroying this object releases the subscription.

You can have multiple concurrent subscriptions to the same event type. In that case, each event will be delivered to every single subscription.

Use WaitForEvent to be notified immediately when the next event arrives. Whenever an event arrives even though you are not currently waiting, that event is buffered. Hence, keeping an open subscription but never receiving events from it produces a memory leak.

Public Member Functions

Parameter Type Description
WaitForEvent (ResolveFn< const T & > resolve) void Wait for a new event to arrive

WaitForEvent()

void TwitchEventStream< T >::WaitForEvent  (   ResolveFn< const T & >      resolve )   

Wait for a new event to arrive.

Invoking this function concurrently, i.e., calling it before an earlier invocation returns, is allowed. In that case, an incoming event is always delivered to the oldest currently waiting WaitForEvent call.

This function waits until a matching event arrives, potentially forever. To cancel the the call, terminate your subscription by destroying the TwitchEventStream object.

UserInfo

All information about a given user.

Public Attributes

Parameter Type Description
ChannelId string_holder User’s ID.
LoginName string_holder User’s login name.
DisplayName string_holder User’s display name.
UserType string_holder User’s type: “staff”, “admin”, “global_mod”, or “”.
BroadcasterType string_holder User’s broadcaster type: “partner”, “affiliate”, or “”.
Description string_holder User’s channel description.
ProfileImageUrl string_holder URL of the user’s profile image.
OfflineImageUrl string_holder URL of the user’s offline image.
ViewCount = 0 int64_t Total number of views of the user’s channel.
CreatedAt string_holder Date when the user was created.
Email string_holder User’s verified email address. Only available if you have the user:read:email scope.

UserSubscriptionCheckResult

Describes a user’s subscription to a specified channel.

Public Attributes

Parameter Type Description
Tier string_holder Subscription tier. 1000 is tier 1, 2000 is tier 2, and 3000 is tier 3.
GifterLogin string_holder Login of the gifter (if UserSubscriptionCheckResult.IsGift is true).
GifterName string_holder Display name of the gifter (if UserSubscriptionCheckResult.IsGift is true).
IsGift = false bool Indicates if the subscription is a gift.
IsSubscribed = false bool Indicates if the user is subscribed at all. If this is false, all other fields are empty.

WebRequestResult

Results of a given web request.

Public Attributes

Parameter Type Description
HttpStatus = 0 int32_t The status of the request.
ResponseBody string_holder Holds of the data of the reponse body

TypeDefs

Type Description
ResolveFn = typename ResolveFnType< T >::Fn The resolver function
RejectFn = std::function< void(const std::exception &)> The rejection function
twitchchar = char The char type the Twitch library was compiled with.
string = std::basic_string< twitchchar > The string type used by the Twitch library.
string_view = std::basic_string_view< twitchchar > The string_view type used by the Twitch library.
string_holder = StringHolder< twitchchar > The StringHolder type used by the Twitch library.

RejectFn

A callback function which, on error, is given the exception.

ResolveFn

A callback function which, on success, is given a result and returns void.

twitchchar

The char type the Twitch library was compiled with.

This is defined as:

wchar_t if R66_STR_WSTRING is defined
char16_t if R66_STR_U16STRING is defined
char otherwise

string

The string type used by the Twitch library.

string_holder

The StringHolder type used by the Twitch library.

string_view

The string_view type used by the R66 library.

Enums

Enum Type Description
LogLevel : uint8_t { Debug = 0 , Info = 1 , Warning = 2 , Error = 3 } This log level determines verbosity of the logs
AuthStatus : uint8_t { LoggedOut = 0 , Loading = 1 , WaitingForCode = 2 , LoggedIn = 3 } The current user authentication status.
HypeTrainContributionType : uint8_t { Bits = 0 , Subscription = 1 } Describes the type of contribution
CustomRewardRedemptionState : uint8_t { Unknown = 0 , Unfulfilled = 1 , Fulfilled = 2 , Canceled = 3 } Describes the state of a given reward redemption
EventStreamKind : uint8_t { Subscription = 0 , Follower = 1 , Cheer = 2 , CustomRewardRedemption = 3 , HypeTrain = 4 , ChannelRaid = 5 } The type of an EventSub subscription.
PredictionStatus : uint8_t { Active = 0 , Locked = 1 , Resolved = 2 , Canceled = 3 } Status of a Prediction.
PollStatus : uint8_t { Active = 0 , Completed = 1 , Terminated = 2 , Archived = 3 , Moderated = 4 , Invalid = 5 } Status of a poll.
HttpMethod : uint8_t { Get = 0 , Post = 1 , Put = 2 , Patch = 3 , Delete = 4 } The type of HTTP call

AuthStatus

The current user authentication status.

Enum Status Description
LoggedOut The core library is logged out.
Loading The status can not be determined because an operation affecting it is currently in progress.
WaitingForCode The authorization code flow is in progress and we are currently waiting for the user to authorize.
LoggedIn We have valid OAuth credentials. Note that these credentials may still be rejected if the user revokes your Client-Id from their account.

CustomRewardRedemptionState

Enum Status Description
Unknown There was an error determining the state of the redemption.
Unfulfilled The channel points reward has been redeemed and is now waiting to be fulfilled.
Fulfilled The channel points reward has been fulfilled.
Canceled The channel points reward has been canceled, and the channel points have been refunded.

EventStreamKind

The type of an EventSub subscription.

Enum Status Description
Subscription A notification when a specified channel receives a subscriber. This does not include resubscribes.
Follower A specified channel receives a follow.
Cheer A user cheers on the specified channel.
CustomRewardRedemption A viewer has redeemed a custom channel points reward on the specified channel or the redemption has been updated (i.e., fulfilled or cancelled).
HypeTrain A Hype Train makes progress on the user’s channel. Requires the channel:read:hype_train scope.
ChannelRaid A broadcaster raids another broadcaster’s channel.

PollStatus

Status of a poll.

Enum Status Description
Active Poll is currently in progress.
Completed Poll has reached its PollInfo.EndedAt time.
Terminated Poll has been manually terminated before its PollInfo.EndedAt time.
Archived Poll is no longer visible on the channel.
Moderated Poll is no longer visible to any user on Twitch.
Invalid Something went wrong determining the state.

PredictionStatus

Status of a Prediction.

Enum Status Description
Active The Prediction is active and viewers can make predictions.
Locked The Prediction has been locked and viewers can no longer make predictions.
Resolved A winning outcome has been chosen and the Channel Points have been distributed to the users who guessed the correct outcome.
Canceled The Prediction has been canceled and the Channel Points have been refunded to participants.

Other Variables

Version

Parameter Type Description
Version string The current version of the SDK/Plugin