# obs-websocket

Source: https://docs.lightair.app/developers/control/obs-websocket

> Lightair speaks obs-websocket 5 on port 4455, so OBS tools work with it. Which requests and events it answers, and how OBS's terms map to Lightair's.

In short:
- Point an OBS tool at `ws://127.0.0.1:4455` with the Remote API password. Lightair speaks obs-websocket 5.5.2, JSON only.
- A scene is a scene, a scene item an object, an input a source, and an input's volume its mixer track.
- Each destination is an output of its own, by name; `StartStream` goes live on every enabled destination.
- `GetVersion` reports `obsVersion` 0.0.0 and `platformDescription` "Lightair" with its version.

In the app: Lightair › Settings… › Remote API › Connect › OBS tools (obs-websocket 5)

Lightair answers obs-websocket version 5 at the root of its Remote API, so tools made for OBS (Stream Deck plugins, Touch Portal, chat bots, scripts) can switch scenes, mute sources, go live and record without changes.

## Connect an OBS tool

1. In the tool's OBS connection settings, set the host to `127.0.0.1` (or this computer's address, with **Other devices on your network** on) and the port to `4455`.
2. Enter the password from **Settings › Remote API › Password**. With **Ask for the password** off, leave it empty.

Lightair uses obs-websocket's own authentication: the `Hello` carries a challenge and salt, and the client answers in `Identify`. It offers the `obswebsocket.json` subprotocol; MessagePack isn't supported.

## The version it reports

Lightair isn't OBS and doesn't claim to be. `GetVersion` answers:

| Field | Value |
|---|---|
| `obsVersion` | `0.0.0` |
| `obsWebSocketVersion` | `5.5.2` |
| `rpcVersion` | `1` |
| `platform` | `macos` or `windows` |
| `platformDescription` | `Lightair <version>`: the word Lightair and the app's version |
| `availableRequests` | The requests in the table below |
| `supportedImageFormats` | `png` |

A tool that turns features on or off by OBS's version treats Lightair as an old OBS.

## How OBS's terms map to Lightair's

| OBS | Lightair |
|---|---|
| Scene | Scene. `sceneUuid` is the scene's id |
| Scene item | Object. `sceneItemId` is a number made from the object's id, the same every time |
| Input | Source. `inputUuid` is the source's id |
| Input volume and mute | The source's mixer track |
| Program scene | The scene on air |
| Stream | Going live on every enabled destination |
| Output | One destination, by its name (or id), with kind `rtmp_output` |
| Record | The recording |
| Replay buffer | Clips |
| Virtual camera | Virtual camera |
| Scene collection | The open workspace |
| Profile | Always one, "Lightair" |
| Studio mode, preview scene | Not offered: `GetStudioModeEnabled` is false and the other studio mode requests answer 506 |
| Groups, hotkeys | None: their lists are empty |

Scenes are listed bottom first, each with its `sceneIndex`, as OBS does. Scene item lists hold a scene's top-level objects only; objects inside a group aren't listed.

### Input kinds

Lightair's own sources are named with the kind OBS uses for the same thing on that platform. Other kinds pass through as they are.

| Lightair source | macOS kind | Windows kind |
|---|---|---|
| Screen | `screen_capture` | `monitor_capture` |
| Camera | `macos-avcapture` | `dshow_input` |
| Microphone, audio device | `coreaudio_input_capture` | `wasapi_input_capture` |
| Desktop audio | `sck_audio_capture` | `wasapi_output_capture` |
| App audio | `sck_audio_capture` | `wasapi_process_output_capture` |
| Web page | `browser_source` | `browser_source` |

## Requests

| Area | Requests |
|---|---|
| General | `GetVersion`, `GetStats`, `Sleep`, `GetHotkeyList`, `GetVideoSettings`, `GetProfileList`, `GetSceneCollectionList` |
| Scenes | `GetSceneList`, `GetGroupList`, `GetCurrentProgramScene`, `SetCurrentProgramScene`, `CreateScene`, `RemoveScene`, `SetSceneName`, `GetStudioModeEnabled` |
| Scene items | `GetSceneItemList`, `GetGroupSceneItemList`, `GetSceneItemId`, `GetSceneItemSource`, `GetSceneItemEnabled`, `SetSceneItemEnabled`, `GetSceneItemLocked`, `SetSceneItemLocked`, `GetSceneItemIndex`, `SetSceneItemIndex`, `GetSceneItemTransform`, `SetSceneItemTransform`, `CreateSceneItem`, `RemoveSceneItem` |
| Inputs | `GetInputList`, `GetInputKindList`, `GetSpecialInputs`, `GetInputSettings`, `SetInputSettings`, `SetInputName`, `CreateInput`, `RemoveInput`, `GetInputMute`, `SetInputMute`, `ToggleInputMute`, `GetInputVolume`, `SetInputVolume`, `GetSourceActive` |
| Media | `GetMediaInputStatus`, `TriggerMediaInputAction` (play, pause, restart, stop), `SetMediaInputCursor` |
| Screenshots | `GetSourceScreenshot`, `SaveSourceScreenshot` (of a scene, as PNG) |
| Transitions | `GetCurrentSceneTransition`, `GetSceneTransitionList` |
| Stream | `GetStreamStatus`, `StartStream`, `StopStream`, `ToggleStream` |
| Outputs | `GetOutputList`, `GetOutputStatus`, `StartOutput`, `StopOutput`, `ToggleOutput` |
| Record | `GetRecordStatus`, `StartRecord`, `StopRecord`, `ToggleRecord`, `PauseRecord`, `ResumeRecord`, `ToggleRecordPause`, `SplitRecordFile`, `CreateRecordChapter`, `GetRecordDirectory` |
| Replay buffer | `GetReplayBufferStatus`, `SaveReplayBuffer`, `GetLastReplayBufferReplay` |
| Virtual camera | `GetVirtualCamStatus`, `StartVirtualCam`, `StopVirtualCam`, `ToggleVirtualCam` |

Batches (`RequestBatch`) work, with `haltOnFailure`. Any other request answers code 204, "Lightair doesn't do `…` yet."

Where Lightair differs from OBS:

- **Destinations are outputs.** `GetOutputList` lists every destination with its canvas's size. `GetOutputStatus` gives its state, reconnecting, bytes, frames the encoder skipped and total frames. `StartOutput`, `StopOutput` and `ToggleOutput` start or stop that destination alone, with OBS's 500 and 501 answers when it already is or isn't running. obs-websocket has no event for one output, so watch it with `GetOutputStatus`, or with Lightair's own `output.changed` event over [JSON-RPC](/developers/control/events#outputs).
- **The stream's status is brief.** `GetStreamStatus` gives whether it's live and for how long; its byte and frame counts are 0. Use `GetOutputStatus` for each destination's.
- **Transforms are position, size and rotation.** `GetSceneItemTransform` reports the object's position and size with a scale of 1, top-left alignment, no bounds and no crop. `SetSceneItemTransform` takes `positionX`, `positionY` and `rotation`; `boundsWidth` and `boundsHeight` (over 1) set the size, or else `scaleX` and `scaleY` multiply it. Crop and alignment aren't used.
- **Volume** is set in dB from −100 to 26; `inputVolumeMul` is turned into dB.
- **Transitions** always report one, a 300 ms Fade. Set transitions in Lightair or with [transition.set](/developers/remote-api/transition.set).
- **The replay buffer** is Lightair's clips, which run on their own: `StartReplayBuffer`, `StopReplayBuffer` and `ToggleReplayBuffer` answer success and change nothing. `SaveReplayBuffer` saves a clip.
- **`GetVideoSettings`** gives the first canvas's size and frame rate.
- **Screenshots** are of scenes, not single sources. `SaveSourceScreenshot` writes the file on the computer running Lightair.
- **`GetStats`** has CPU, memory, disk space, frame rate, render time and skipped frames; the WebSocket message counts are null.

## Events

Lightair sends these events in OBS's names, to clients subscribed to their category (all categories unless `Identify` or `Reidentify` sets `eventSubscriptions`).

| Event | Category | When |
|---|---|---|
| `CurrentProgramSceneChanged` | Scenes | Another scene goes on air |
| `SceneListChanged` | Scenes | Scenes are added, removed, renamed or reordered |
| `StreamStateChanged` | Outputs | Going live or ending |
| `RecordStateChanged` | Outputs | Recording starts, stops, pauses or resumes, with `outputPath` |
| `VirtualcamStateChanged` | Outputs | The virtual camera starts or stops |
| `ReplayBufferSaved` | Outputs | A clip is saved, with `savedReplayPath` |
| `InputMuteStateChanged` | Inputs | A track is muted or unmuted |
| `InputVolumeChanged` | Inputs | A track's volume changes |
| `SceneItemEnableStateChanged` | Scene items | An object is shown or hidden |

Output events carry `outputActive` and `outputState` (`OBS_WEBSOCKET_OUTPUT_STARTED`, `…_PAUSED` or `…_STOPPED`).

## Related

- [Connect to the Remote API](/developers/control/connect)
- [Errors](/developers/control/errors#obs-websocket)
- [Stream Deck](/desktop/control-and-automate/stream-deck)
