Appearance
Class: StreamService
Service exposing the state of the current stream: its identifier, its start time, and access to aggregated data (chatters, follows, subs, raids, etc.).
Remarks
Available everywhere via k.stream. You never have to instantiate this service yourself — it is created by the SDK when the app/widget starts.
The stream_id and stream_started_at properties reflect the current state and are updated automatically when the stream goes online/offline or restarts.
Example
ts
if (k.stream.stream_id) {
const data = await k.stream.getData();
console.log(`${Object.keys(data['twitch-chatters']).length} chat participants`);
}Implements
Properties
stream_id
ts
stream_id: string;stream_started_at
ts
stream_started_at: number;Methods
getData()
ts
getData(): Promise<StreamData>;Fetches the aggregated stream data from the backend: participant statistics indexed by display name, event lists (follow, raid, sub, sub gift, sub message, channel information), and the stream's start timestamp.
Returns
Promise<StreamData>
The stream data (StreamData).
Example
ts
const data = await k.stream.getData();
for (const follow of data['twitch-follow']) {
console.log(follow.user_name);
}