Api

Requests

Reference of all requests that made to a Streamer.bot instance

getInfo

Fetch information about the connected Streamer.bot instance.

Signature

getInfo(): Promise<GetInfoResponse>

Response Type

GetInfoResponse.ts
  type GetInfoResponse = {
    status: 'ok' | 'error';
    id: string;
    info: {
      instanceId: string;
      name: string;
      os: 'windows' | 'linux' | 'macosx' | string;
      osVersion: string;
      version: string;
      source?: 'websocketServer' | 'streamDeckServer' | 'httpServer' | string;
    }
  }

Examples

const infoResponse = await client.getInfo();

getEvents

Fetch a list of all events that can be subscribed to on the connected Streamer.bot instance.

Signature

getEvents(): Promise<GetEventsResponse>

Response Type

GetEventsResponse.ts
  type GetEventsResponse = {
    status: 'ok' | 'error';
    id: string;
    events: StreamerbotEventsType;
  }

Examples

const response: GetEventsResponse = await client.getEvents();

The events key will contain the Streamer.bot Events structure, with all events supported by the connected instance.

on

Quickly define an event handler for a specific event or set of events.

Event subscriptions will be automatically added as needed

Signature

on(events: StreamerbotEventName | StramerbotEventName[], listener: (data: unknown) => void): Promise<void>

Parameters

eventsrequired
StreamerbotEventName | StreamerbotEventName[]

Define the event(s) to subscribe to, formatted as '[source].[eventType]'

  • eventType supports wildcards, e.g. Twitch.*
listenerrequired
(data: unknown) => void

Define a callback function to handle data anytime the requested events are triggered

Examples

// Subscribe to Twitch ChatMessage events
await client.on('Twitch.ChatMessage', (data) => {
  console.log('Twitch Chat Message Received:', data);
});

subscribe

Subscribe to a set of events on the connected Streamer.bot instance.

Signature

subscribe(events: StreamerbotEventsSubscription | '*'): Promise<SubscribeResponse>

Parameters

eventsrequired
StreamerbotEventsSubscription | '*'

Define the events to subscribe to, formatted as an Events Subscription

  • You can use wildcard '*' to subscribe to all events

Response Type

SubscribeResponse.ts
  type SubscribeResponse = {
    status: 'ok' | 'error';
    id: string;
    events: StreamerbotEventsSubscription
  }

Examples

// Subscribe to Twitch ChatMessage events
const response = await client.subscribe({
  "Twitch": ["ChatMessage"]
});

unsubscribe

Unsubscribe from a set of events on the connected Streamer.bot instance.

Signature

unsubscribe(events: StreamerbotEventsSubscription | '*'): Promise<UnsubscribeResponse>

Parameters

eventsrequired
StreamerbotEventsSubscription | '*'

Define the events to unsubscribe from, formatted as an Events Subscription

  • You can use wildcard '*' to unsubscribe from all events

Response Type

UnsubscribeResponse.ts
  type UnsubscribeResponse = {
    status: 'ok' | 'error';
    id: string;
    events: StreamerbotEventsSubscription
  }

Examples

// Unsubscribe from Twitch ChatMessage events
const response = await client.unsubscribe({
  "Twitch": ["ChatMessage"]
});

getActions

Fetch a list of all actions in the connected Streamer.bot instance.

Signature

getActions(): Promise<GetActionsResponse>

Response Type

GetActionsResponse.ts
  type GetActionsResponse = {
    status: 'ok' | 'error';
    id: string;
    actions: Array<{
      enabled: boolean;
      group: string;
      id: string;
      name: string;
      subaction_count: number;
    }>;
    count: number;
  }

Examples

const response = await client.getActions();

doAction

Execute an action on the connected Streamer.bot instance.

Signature

doAction(action: string | { id?: string, name?: string }, args?: Record<string, any>): Promise<DoActionResponse>

Parameters

actionrequired
string | { id?: string, name?: string }

The id of the action to execute, or an object containting the action id and/or name

args
Record<string, any>

Optionally define any arguments to pass to the executed action as JSON

Response Type

Response
  type DoActionResponse = {
    status: 'ok' | 'error';
    id: string;
  }

Examples

// Execute an action by id
const response = await client.doAction("[action-id]");

// Execute an action by name
const response = await client.doAction({ name: "My Action" });

getBroadcaster

Fetch information about the connected broadcaster account(s)

Signature

getBroadcaster(): Promise<GetBroadcasterResponse>

Response Type

GetBroadcasterResponse.ts
  type GetBroadcasterResponse = {
    status: 'ok' | 'error';
    id: string;
    platforms: {
      twitch?: {
        broadcastUser: string;
        broadcastUserName: string;
        broadcastUserId: string;
        broadcastIsAffiliate: boolean;
        broadcastIsPartner: boolean;
      },
      youtube?: {
        broadcastUserName: string;
        broadcastUserId: string;
        broadcastUserProfileImage: string;
      }
    };
    connected: Array<"twitch" | "youtube">;
    disconnected: Array<"twitch" | "youtube">;
  }

Examples

const response = await client.getBroadcaster();

getActiveViewers

Fetch a list of all active viewers for connected Twitch or YouTube accounts.

Signature

getActiveViewers(): Promise<GetActiveViewersResponse>

Response Type

GetActiveViewersResponse.ts
  type GetActiveViewersResponse = {
    status: 'ok' | 'error';
    id: string;
    viewers: Array<{
      channelPointsUsed: number;
      display: string;
      exempt: boolean;
      groups: Array<string>;
      id: string;
      login: string;
      previousActive: string;
      role: string;
      subscribed: boolean;
    }>;
  }

Examples

const response = await client.getActiveViewers();

getCodeTriggers

Fetch a list of all Custom Triggers that have been defined on the connected Streamer.bot instance

Signature

getCodeTriggers(): Promise<GetCodeTriggersResponse>

Response Type

GetCodeTriggersResponse.ts
type GetCodeTriggersResponse = {
  status: 'ok' | 'error';
  id: string;
  triggers: Array<{
    name: string;
    eventName: string;
    category: string;
  }>;
  count: number;
}

Examples

const response = await client.getCodeTriggers();

executeCodeTrigger

Execute a Custom Trigger that has been defined on the connected Streamer.bot instance

Signature

executeCodeTrigger(triggerName: string, args?: Record<string, any>): Promise<ExecuteCodeTriggerResponse>

Parameters

triggerNamerequired
String

The name of your custom code trigger

args
Record<string, any>

Any arguments you want to pass to your trigger execution as JSON

Response Type

ExecuteCodeTriggerResponse.ts
type ExecuteCodeTriggerResponse = {
  status: 'ok' | 'error';
  id: string;
}

Examples

// Execute a trigger named 'myCustomTrigger', with some custom arguments
const response = await client.executeCodeTrigger('myCustomTrigger', {
  value: 23,
  someArg: 'testing!'
});

getCredits

Fetch the current credits system data.

Signature

getCredits(): Promise<GetCreditsResponse>

Response Type

GetCreditsResponse.ts
  type GetCreditsResponse = {
    status: 'ok' | 'error';
    id: string;
    credits: {
      events: {
        cheers?: Array<string>;
        follows?: Array<string>;
        gameupdates?: Array<string>;
        giftbombs?: Array<string>;
        giftsubs?: Array<string>;
        goalcontributions?: Array<string>;
        hypetrains?: Array<string>;
        pyramids?: Array<string>;
        raided?: Array<string>;
        resubs?: Array<string>;
        rewardredemptions?: Array<string>;
        subs?: Array<string>;
      };
      users: {
        editors?: Array<string>;
        groups?: Array<string>;
        moderators?: Array<string>;
        subscribers?: Array<string>;
        vips?: Array<string>;
        users?: Array<string>;
      };
      hypeTrain: {
        conductors: Array<string>;
        contributors: Array<string>;
      }
      top: {
        allBits: Array<string>;
        monthBits: Array<string>;
        weekBits: Array<string>;
        channelRewards: Array<string>;
      };
      groups: {};
      custom: {};
    }
  }

Examples

const response = await client.getCredits();

testCredits

Fill credits system with test data for testing.

Signature

testCredits(): Promise<TestCreditsResponse>

Response Type

TestCreditsResponse.ts
  type TestCreditsResponse = {
    status: 'ok' | 'error';
    id: string;
    credits: {
      events: {
        cheers?: Array<string>;
        follows?: Array<string>;
        gameupdates?: Array<string>;
        giftbombs?: Array<string>;
        giftsubs?: Array<string>;
        goalcontributions?: Array<string>;
        hypetrains?: Array<string>;
        pyramids?: Array<string>;
        raided?: Array<string>;
        resubs?: Array<string>;
        rewardredemptions?: Array<string>;
        subs?: Array<string>;
      };
      users: {
        editors?: Array<string>;
        groups?: Array<string>;
        moderators?: Array<string>;
        subscribers?: Array<string>;
        vips?: Array<string>;
        users?: Array<string>;
      };
      hypeTrain: {
        conductors: Array<string>;
        contributors: Array<string>;
      }
      top: {
        allBits: Array<string>;
        monthBits: Array<string>;
        weekBits: Array<string>;
        channelRewards: Array<string>;
      };
      groups: {};
      custom: {};
    }
  }

Examples

const response = await client.testCredits();

clearCredits

Reset the current credits system data.

Signature

clearCredits(): Promise<ClearCreditsResponse>

Response Type

ClearCreditsResponse.ts
  type ClearCreditsResponse = {
    status: 'ok' | 'error';
    id: string;
  }

Examples

const response = await client.clearCredits();

getCommands

Requires Streamer.bot v0.2.5

Fetch a list of commands for the connected Streamer.bot instance

Signature

getCommands: Promise<GetCommandsResponse>

Response Type

GetCommandsResponse.ts
  type GetCommandsResponse = {
    status: 'ok' | 'error';
    commands: Array<{
      id: string;
      enabled: boolean;
      name: string;
      group: string;
      commands: Array<string>;
      caseSensitive: boolean;
      ignoreInternal: boolean;
      ignoreBotAccount: boolean;
      sources: Array<string>;
    }>;
    count: number;
  }

Examples

const response = await client.getCommands();

getMonitoredYouTubeBroadcasts

Requires Streamer.bot v0.2.5

Fetch a list of currently monitored YouTube broadcasts

Signature

getMonitoredYouTubeBroadcasts: Promise<GetMonitoredYouTubeBroadcastsResponse>

Response Type

GetMonitoredYouTubeBroadcastsResponse.ts
  type GetMonitoredYouTubeBroadcastsResponse = {
    status: 'ok' | 'error';
    broadcasts: Array<{
      actualEndTime: string;
      actualStartTime: string;
      categoryId: string;
      channelId: string;
      description: string;
      id: string;
      liveChatId: string;
      privacy: 'public' | 'private' | 'unlisted' | string;
      publishedAt: string;
      scheduledEndTime: string;
      scheduledStartTime: string;
      status: 'ready' | 'complete' | string;
      title: string;
      tags: Array<string>;
      defaultLanguage: string;
      defaultAudioLanguage: string;
    }>;
    count: number;
  }

Examples

const response = await client.getMonitoredYouTubeBroadcasts();

getEmotes

Requires Streamer.bot v0.2.5

Fetch a list of emotes for the selected platform

Signature

getEmotes: Promise<TwitchGetEmotesResponse | YouTubeGetEmotesResponse>

Parameters

platformrequired
'twitch' | 'youtube'

Select the platform to fetch emotes for

Response Type

  type TwitchGetEmotesResponse = {
    status: 'ok' | 'error';
    emotes: {
      userEmotes: Array<{
        type: string;
        name: string;
        imageUrl: string;
      }>;
      bttvEmotes: Array<{
        type: string;
        name: string;
        imageUrl: string;
      }>;
      ffzEmotes: Array<{
        type: string;
        name: string;
        imageUrl: string;
      }>;
      sevenTvEmotes: Array<{
        type: string;
        name: string;
        imageUrl: string;
      }>;
    }
  }

Examples

const response = await client.getEmotes('twitch');

getGlobals

Requires Streamer.bot v0.2.5

Fetch a list of global variables defined on the Streamer.bot instance

Signature

getGlobals: Promise<GetGlobalsResponse>

Parameters

persisted
boolean

Fetch persisted or non-persisted variables

  • Default: true

Response Type

GetGlobalsResponse.ts
type GetGlobalsResponse = StreamerbotResponse<{
  variables: {
    [key: string]: {
      name: string;
      value: string | number | boolean | null;
      lastWrite: string;
    }
  };
  count: number;
  status: 'ok' | 'error';
}>;

Examples

const response = await client.getGlobals();

getGlobal

Requires Streamer.bot v0.2.5

Fetch a specific global variable by name

Signature

getGlobal(name: K, persisted = true): Promise<GetGlobalResponse>

Response Type

GetGlobalResponse.ts
type GetGlobalResponse<T, K = string> = StreamerbotResponse<{
  variable: {
    name: K;
    value: T;
    lastWrite: string;
  };
  status: 'ok' | 'error';
}>;

Examples

const response = await client.getGlobals();

getUserGlobals

Requires Streamer.bot v0.2.5

Fetch a list of defined user global variables for a given platform

Signature

getUserGlobals<T, K, P>(platform: P, persisted = true): Promise<GetUserGlobalsResponse<T, K, P>>

Parameters

platformrequired
'twitch' | 'youtube' | 'trovo'

Select the platform to fetch globals for

persisted
boolean
  • Default: true

Response Type

GetGlobalsResponse.ts
type GetUserGlobalsResponse = StreamerbotResponse<{
  variables: {
    [key: string]: {
      name: string;
      value: string | number | boolean | null;
      lastWrite: string;
      platform: 'twitch' | 'youtube' | 'trovo';
      userId: string;
      userLogin: string;
      userName: string;
    }
  };
  count: number;
  status: 'ok' | 'error';
}>;

Examples

const response = await client.getUserGlobals('twitch');

getUserGlobal

Requires Streamer.bot v0.2.5

Fetch user global variables by user ID and (optionally) variable name

Signature

getUserGlobal<T, K, U, P>(platform: P, userId: U, name: K = null, persisted = true): Promise<GetUserGlobalResponse<T, K> | GetUserGlobalByNameResponse<T, K>>

Parameters

platformrequired
'twitch' | 'youtube' | 'trovo'

Select the platform to fetch globals for

userIdrequired
string

Provide the specific user ID to fetch globals for

name
string

Optionally provide a variable name

persisted
boolean
  • Default: true

Response Type

type GetUserGlobalResponse = StreamerbotResponse<{
  variables: {
    [key: string]: {
      name: string;
      value: string | number | boolean | null;
      lastWrite: string;
    }
  };
  count: number;
  status: 'ok';
}>;

Examples

// Fetch all user global variables for a given user ID
const response = await client.getUserGlobal('twitch', '12345678');

// Fetch a specific user global variable by user ID and variable name
const response = await client.getUserGlobal('twitch', '12345678', 'test');

sendMessage

Requires Streamer.bot v0.2.5

Send a chat message to the selected platform

Signature

sendMessage(
  platform: 'twitch' | 'youtube' | 'trovo',
  message: string,
  options?: {
    bot?: boolean;
    internal?: boolean;
    replyId?: string;
    broadcastId?: string;
  }
): Promise<SendMessageResponse>

Parameters

platformrequired
'twitch' | 'youtube' | 'trovo'

Select the platform to send the message to

messagerequired
string

Enter the content of the message to send

options.bot
boolean
  • Default: false Send with the bot account?
options.internal
boolean
  • Default: true Send as an Internal message

Useful in combination with the Ignore Internal option on Commands

options.replyId
string

Optional message id to send a reply to

Currently only supported by Twitch

options.broadcastId
string

Optioanl broadcast id to send the message to

Currently only supported by YouTube

Response Type

type SendMessageResponse = StreamerbotResponse<{
  id: string;
  status: 'ok' | 'error';
  error?: string;
}>;

Examples

// Send a message with the Twitch broadcaster account
const response = await client.sendMessage('twitch', 'Hello, world!');

// Send a message with the Twitch bot account
const response = await client.getUserGlobal('twitch', 'Hello, from bot account!', { bot: true });

getUserPronouns

Requires Streamer.bot v0.2.5

Fetch user pronouns (alejo.io)

Signature

getUserPronouns(platform: 'twitch' | 'youtube' | 'trovo', userLogin: string)

Parameters

platformrequired
'twitch' | 'youtube' | 'trovo'

Select the platform to fetch pronouns for

Currently only supported by Twitch

userLoginrequired
string

Provide the specific user login to fetch pronouns for

Response Type

export type GetUserPronounsResponse = StreamerbotResponse<{
  status: 'ok';
  userLogin: string;
  pronoun: {
    pronouns: string;
    pronounSubject: string;
    pronounObject: string;
    pronounPossessive: string;
    pronounPronoun: string;
    pronounReflexive: string;
    pronounPastTense: string;
    pronounSubjectLower: string;
    pronounObjectLower: string;
    pronounPossessiveLower: string;
    pronounPronounLower: string;
    pronounReflexiveLower: string;
    pronounPastTenseLower: string;
    pronounCurrentTense: string;
    pronounCurrentTenseLower: string;
    pronounPluralLower: string;
    pronounLastCached: string;
    userFound: boolean;
  };
}>

Examples

const response = await client.getUserPronouns('twitch', 'whipstickgostop');