API reference
Everything a widget can call or listen to, on one page. Types for all of it: se-api.d.ts (the code editor uses them for suggestions).
Window events
| Event | detail |
Page |
|---|---|---|
onWidgetLoad |
{ channel, currency, fieldData, recents, session: { data }, overlay } |
Lifecycle |
onEventReceived |
{ listener, event } |
Events |
onSessionUpdate |
{ session } |
Session data |
window.addEventListener('onWidgetLoad', (obj) => { /* obj.detail */ });SE_API
SE_API is a global object. Calls that return a promise answer at once unless they go to the server (store).
store
SE_API.store.set(key, value) → Promise<void> and SE_API.store.get(key) → Promise<any>. Values kept on Streamed for all custom widgets of the account. Store
counters
SE_API.counters.get(name) → Promise<{ id, counter, count, value }>. Reads a variable: a number, unless it holds a text; 0 when it does not exist.
cheerFilter
SE_API.cheerFilter(message) → Promise<string>. Removes Twitch cheermotes (Cheer100, Kappa50, …) from a message and tidies the spaces.
SE_API.cheerFilter('Cheer500 Great play!').then((text) => { /* "Great play!" */ });sanitize
SE_API.sanitize({ message }) → Promise<{ skip: false, result: { message } }>. On StreamElements it filters bad words; here it returns the message unchanged. It does not make text safe for innerHTML: use textContent.
setField
SE_API.setField(key, value, shouldReload?) changes a field's value while the widget runs. In the editor's preview the value also shows in the settings (unsaved) and the preview reloads; on stream nothing is saved. Fields
getOverlayStatus
SE_API.getOverlayStatus() → Promise<{ isEditorMode, muted }>: the same as overlay in onWidgetLoad.
resumeQueue
SE_API.resumeQueue() lets the next queued alert play now, without waiting for the rest of widgetDuration. Lifecycle: the event queue
jQuery
jQuery 3 is loaded before your code, as $ and jQuery.
Not available
StreamElements' REST API and anything that needs its API token (channel.apiToken is empty). The browser features that a sandboxed page cannot use. Limits and security