# API reference Everything a widget can call or listen to, on one page. Types for all of it: [se-api.d.ts](https://streamed.hu/assets/js/widgets/custom-widget/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](https://streamed.hu/docs/lifecycle.md#onwidgetload) | | `onEventReceived` | `{ listener, event }` | [Events](https://streamed.hu/docs/events.md) | | `onSessionUpdate` | `{ session }` | [Session data](https://streamed.hu/docs/session-data.md) | ```js 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` and `SE_API.store.get(key)` → `Promise`. Values kept on Streamed for all custom widgets of the account. [Store](https://streamed.hu/docs/store.md) ### counters `SE_API.counters.get(name)` → `Promise<{ id, counter, count, value }>`. Reads a [variable](https://streamed.hu/docs/variables.md): a number, unless it holds a text; `0` when it does not exist. ### cheerFilter `SE_API.cheerFilter(message)` → `Promise`. Removes Twitch cheermotes (`Cheer100`, `Kappa50`, …) from a message and tidies the spaces. ```js 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](https://streamed.hu/docs/fields.md#changing-a-value-from-code) ### 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](https://streamed.hu/docs/lifecycle.md#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](https://streamed.hu/docs/limits-and-security.md)