39 KiB

obs-websocket 4.2 protocol reference

This is the reference for the latest version of obs-websocket. See the list below for older versions.

General Introduction

Messages are exchanged between the client and the server as JSON objects. This protocol is based on the original OBS Remote protocol created by Bill Hamilton, with new commands specific to OBS Studio.

Authentication

OBSWebSocket uses SHA256 to transmit credentials.

A request for GetAuthRequired returns two elements:

  • A challenge: a random string that will be used to generate the auth response.
  • A salt: applied to the password when generating the auth response.

To generate the answer to the auth challenge, follow this procedure:

  • Concatenate the user declared password with the salt sent by the server (in this order: password + server salt).
  • Generate a binary SHA256 hash of the result and encode the resulting SHA256 binary hash to base64, known as a base64 secret.
  • Concatenate the base64 secret with the challenge sent by the server (in this order: base64 secret + server challenge).
  • Generate a binary SHA256 hash of the result and encode it to base64.
  • Voilà, this last base64 string is the auth response. You may now use it to authenticate to the server with the Authenticate request.

Pseudo Code Example:

password = "supersecretpassword"
challenge = "ztTBnnuqrqaKDzRM3xcVdbYm"
salt = "PZVbYpvAnZut2SS6JNJytDm9"

secret_string = password + salt
secret_hash = binary_sha256(secret_string)
secret = base64_encode(secret_hash)

auth_response_string = secret + challenge
auth_response_hash = binary_sha256(auth_response_string)
auth_response = base64_encode(auth_response_hash)

Table of Contents

Events

Events are broadcast by the server to each connected client when a recognized action occurs within OBS.

An event message will contain at least the following base fields:

  • update-type String: the type of event.
  • stream-timecode String (optional): time elapsed between now and stream start (only present if OBS Studio is streaming).
  • rec-timecode String (optional): time elapsed between now and recording start (only present if OBS Studio is recording).

Timecodes are sent using the format: HH:MM:SS.mmm

Additional fields may be present in the event message depending on the event type.

Scenes

OnSceneChange

Indicates a scene change.

Response Items:

Name Type Description
scene-name String The new scene.
sources Array List of sources in the new scene.

ScenesChanged

The scene list has been modified. Scenes have been added, removed, or renamed.

Response Items:

No additional response items.


SceneCollectionChanged

Triggered when switching to another scene collection or when renaming the current scene collection.

Response Items:

No additional response items.


SceneCollectionListChanged

Triggered when a scene collection is created, added, renamed, or removed.

Response Items:

No additional response items.


Transitions

SwitchTransition

The active transition has been changed.

Response Items:

Name Type Description
transition-name String The name of the new active transition.

TransitionListChanged

The list of available transitions has been modified. Transitions have been added, removed, or renamed.

Response Items:

No additional response items.


TransitionDurationChanged

The active transition duration has been changed.

Response Items:

Name Type Description
new-duration int New transition duration.

TransitionBegin

A transition (other than "cut") has begun.

Response Items:

Name Type Description
name String Transition name.
duration int Transition duration (in milliseconds).

Profiles

ProfileChanged

Triggered when switching to another profile or when renaming the current profile.

Response Items:

No additional response items.


ProfileListChanged

Triggered when a profile is created, added, renamed, or removed.

Response Items:

No additional response items.


Streaming

StreamStarting

A request to start streaming has been issued.

Response Items:

Name Type Description
preview-only boolean Always false (retrocompatibility).

StreamStarted

Streaming started successfully.

Response Items:

No additional response items.


StreamStopping

A request to stop streaming has been issued.

Response Items:

Name Type Description
preview-only boolean Always false (retrocompatibility).

StreamStopped

Streaming stopped successfully.

Response Items:

No additional response items.


StreamStatus

Emit every 2 seconds.

Response Items:

Name Type Description
streaming boolean Current streaming state.
recording boolean Current recording state.
preview-only boolean Always false (retrocompatibility).
bytes-per-sec int Amount of data per second (in bytes) transmitted by the stream encoder.
kbits-per-sec int Amount of data per second (in kilobits) transmitted by the stream encoder.
strain double Percentage of dropped frames.
total-stream-time int Total time (in seconds) since the stream started.
num-total-frames int Total number of frames transmitted since the stream started.
num-dropped-frames int Number of frames dropped by the encoder since the stream started.
fps double Current framerate.

Recording

RecordingStarting

A request to start recording has been issued.

Response Items:

No additional response items.


RecordingStarted

Recording started successfully.

Response Items:

No additional response items.


RecordingStopping

A request to stop recording has been issued.

Response Items:

No additional response items.


RecordingStopped

Recording stopped successfully.

Response Items:

No additional response items.


Replay Buffer

ReplayStarting

A request to start the replay buffer has been issued.

Response Items:

No additional response items.


ReplayStarted

Replay Buffer started successfully

Response Items:

No additional response items.


ReplayStopping

A request to start the replay buffer has been issued.

Response Items:

No additional response items.


ReplayStopped

Replay Buffer stopped successfully

Response Items:

No additional response items.


Other

Exiting

OBS is exiting.

Response Items:

No additional response items.


Sources

SourceOrderChanged

Scene items have been reordered.

Response Items:

Name Type Description
scene-name String Name of the scene where items have been reordered.

SceneItemAdded

An item has been added to the current scene.

Response Items:

Name Type Description
scene-name String Name of the scene.
item-name String Name of the item added to the scene.

SceneItemRemoved

An item has been removed from the current scene.

Response Items:

Name Type Description
scene-name String Name of the scene.
item-name String Name of the item removed from the scene.

SceneItemVisibilityChanged

An item's visibility has been toggled.

Response Items:

Name Type Description
scene-name String Name of the scene.
item-name String Name of the item in the scene.
item-visible boolean New visibility state of the item.

Studio Mode

PreviewSceneChanged

The selected preview scene has changed (only available in Studio Mode).

Response Items:

Name Type Description
scene-name String Name of the scene being previewed.
sources Source|Array List of sources composing the scene. Same specification as GetCurrentScene.

StudioModeSwitched

Studio Mode has been enabled or disabled.

Response Items:

Name Type Description
new-state boolean The new enabled state of Studio Mode.

Requests

Requests are sent by the client and require at least the following two fields:

  • request-type String: String name of the request type.
  • message-id String: Client defined identifier for the message, will be echoed in the response.

Once a request is sent, the server will return a JSON response with at least the following fields:

  • message-id String: The client defined identifier specified in the request.
  • status String: Response status, will be one of the following: ok, error
  • error String: An error message accompanying an error status.

Additional information may be required/returned depending on the request type. See below for more information.

General

GetVersion

Returns the latest version of the plugin and the API.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
version double OBSRemote compatible API version. Fixed to 1.1 for retrocompatibility.
obs-websocket-version String obs-websocket plugin version.
obs-studio-version String OBS Studio program version.
available-requests String|Array List of available request types.

GetAuthRequired

Tells the client if authentication is required. If so, returns authentication parameters challenge and salt (see "Authentication" for more information).

Request Fields:

No specified parameters.

Response Items:

Name Type Description
authRequired boolean Indicates whether authentication is required.
challenge String (optional)
salt String (optional)

Authenticate

Attempt to authenticate the client to the server.

Request Fields:

Name Type Description
auth String Response to the auth challenge (see "Authentication" for more information).

Response Items:

No additional response items.


Scenes

SetCurrentScene

Switch to the specified scene.

Request Fields:

Name Type Description
scene-name String Name of the scene to switch to.

Response Items:

No additional response items.


GetCurrentScene

Get the current scene's name and source items.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
name String Name of the currently active scene.
sources Source|Array Ordered list of the current scene's source items.

GetSceneList

Get a list of scenes in the currently active profile.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
current-scene String Name of the currently active scene.
scenes Scene|Array Ordered list of the current profile's scenes (See [GetCurrentScene](#getcurrentscene) for more information).

Sources

SetSourceRender

Show or hide a specified source item in a specified scene.

Request Fields:

Name Type Description
source String Name of the source in the specified scene.
render boolean Desired visibility.
scene-name String (optional) Name of the scene where the source resides. Defaults to the currently active scene.

Response Items:

No additional response items.


SetVolume

Set the volume of the specified source.

Request Fields:

Name Type Description
source String Name of the source.
volume double Desired volume. Must be between 0.0 and 1.0.

Response Items:

No additional response items.


GetVolume

Get the volume of the specified source.

Request Fields:

Name Type Description
source String Name of the source.

Response Items:

Name Type Description
name String Name of the source.
volume double Volume of the source. Between 0.0 and 1.0.
mute boolean Indicates whether the source is muted.

ToggleMute

Inverts the mute status of a specified source.

Request Fields:

Name Type Description
source String The name of the source.

Response Items:

No additional response items.


SetMute

Sets the mute status of a specified source.

Request Fields:

Name Type Description
source String The name of the source.
mute boolean Desired mute status.

Response Items:

No additional response items.


GetMute

Get the mute status of a specified source.

Request Fields:

Name Type Description
source String The name of the source.

Response Items:

Name Type Description
name String The name of the source.
muted boolean Mute status of the source.

SetSyncOffset

Set the audio sync offset of a specified source.

Request Fields:

Name Type Description
source String The name of the source.
offset int The desired audio sync offset (in nanoseconds).

Response Items:

No additional response items.


GetSyncOffset

Get the audio sync offset of a specified source.

Request Fields:

Name Type Description
source String The name of the source.

Response Items:

Name Type Description
name String The name of the source.
offset int The audio sync offset (in nanoseconds).

SetSceneItemPosition

Sets the coordinates of a specified source item.

Request Fields:

Name Type Description
scene-name String (optional) The name of the scene that the source item belongs to. Defaults to the current scene.
item String The name of the source item.
x double X coordinate.
y double Y coordinate.

Response Items:

No additional response items.


SetSceneItemTransform

Set the transform of the specified source item.

Request Fields:

Name Type Description
scene-name String (optional) The name of the scene that the source item belongs to. Defaults to the current scene.
item String The name of the source item.
x-scale double Width scale factor.
y-scale double Height scale factor.
rotation double Source item rotation (in degrees).

Response Items:

No additional response items.


SetSceneItemCrop

Sets the crop coordinates of the specified source item.

Request Fields:

Name Type Description
scene-name String (optional) the name of the scene that the source item belongs to. Defaults to the current scene.
item String The name of the source.
top int Pixel position of the top of the source item.
bottom int Pixel position of the bottom of the source item.
left int Pixel position of the left of the source item.
right int Pixel position of the right of the source item.

Response Items:

No additional response items.


GetTextGDIPlusProperties

Get the current properties of a Text GDI Plus source.

Request Fields:

Name Type Description
scene-name String (optional) Name of the scene to retrieve. Defaults to the current scene.
source String Name of the source.

Response Items:

Name Type Description
align String Text Alignment ("left", "center", "right").
bk-color int Background color.
bk-opacity int Background opacity (0-100).
chatlog boolean Chat log.
chatlog_lines int Chat log lines.
color int Text color.
extents boolean Extents wrap.
extents_cx int Extents cx.
extents_cy int Extents cy.
file String File path name.
read_from_file boolean Read text from the specified file.
font Object Holds data for the font. Ex: "font": { "face": "Arial", "flags": 0, "size": 150, "style": "" }
font.face String Font face.
font.flags int Font text styling flag. Bold=1, Italic=2, Bold Italic=3, Underline=5, Strikeout=8
font.size int Font text size.
font.style String Font Style (unknown function).
gradient boolean Gradient enabled.
gradient_color int Gradient color.
gradient_dir float Gradient direction.
gradient_opacity int Gradient opacity (0-100).
outline boolean Outline.
outline_color int Outline color.
outline_size int Outline size.
outline_opacity int Outline opacity (0-100).
text String Text content to be displayed.
valign String Text vertical alignment ("top", "center", "bottom").
vertical boolean Vertical text enabled.
render boolean Visibility of the scene item.

SetTextGDIPlusProperties

Get the current properties of a Text GDI Plus source.

Request Fields:

Name Type Description
scene-name String (optional) Name of the scene to retrieve. Defaults to the current scene.
source String Name of the source.
align String (optional) Text Alignment ("left", "center", "right").
bk-color int (optional) Background color.
bk-opacity int (optional) Background opacity (0-100).
chatlog boolean (optional) Chat log.
chatlog_lines int (optional) Chat log lines.
color int (optional) Text color.
extents boolean (optional) Extents wrap.
extents_cx int (optional) Extents cx.
extents_cy int (optional) Extents cy.
file String (optional) File path name.
read_from_file boolean (optional) Read text from the specified file.
font Object (optional) Holds data for the font. Ex: "font": { "face": "Arial", "flags": 0, "size": 150, "style": "" }
font.face String (optional) Font face.
font.flags int (optional) Font text styling flag. Bold=1, Italic=2, Bold Italic=3, Underline=5, Strikeout=8
font.size int (optional) Font text size.
font.style String (optional) Font Style (unknown function).
gradient boolean (optional) Gradient enabled.
gradient_color int (optional) Gradient color.
gradient_dir float (optional) Gradient direction.
gradient_opacity int (optional) Gradient opacity (0-100).
outline boolean (optional) Outline.
outline_color int (optional) Outline color.
outline_size int (optional) Outline size.
outline_opacity int (optional) Outline opacity (0-100).
text String (optional) Text content to be displayed.
valign String (optional) Text vertical alignment ("top", "center", "bottom").
vertical boolean (optional) Vertical text enabled.
render boolean (optional) Visibility of the scene item.

Response Items:

No additional response items.


GetBrowserSourceProperties

Get current properties for a Browser Source.

Request Fields:

Name Type Description
scene-name String (optional) Name of the scene that the source belongs to. Defaults to the current scene.
source String Name of the source.

Response Items:

Name Type Description
is_local_file boolean Indicates that a local file is in use.
url String Url or file path.
css String CSS to inject.
width int Width.
height int Height.
fps int Framerate.
shutdown boolean Indicates whether the source should be shutdown when not visible.
render boolean (optional) Visibility of the scene item.

SetBrowserSourceProperties

Set current properties for a Browser Source.

Request Fields:

Name Type Description
scene-name String (optional) Name of the scene that the source belongs to. Defaults to the current scene.
source String Name of the source.
is_local_file boolean (optional) Indicates that a local file is in use.
url String (optional) Url or file path.
css String (optional) CSS to inject.
width int (optional) Width.
height int (optional) Height.
fps int (optional) Framerate.
shutdown boolean (optional) Indicates whether the source should be shutdown when not visible.
render boolean (optional) Visibility of the scene item.

Response Items:

No additional response items.


ResetSceneItem

Reset a source item.

Request Fields:

Name Type Description
scene-name String (optional) Name of the scene the source belogns to. Defaults to the current scene.
item String Name of the source item.

Response Items:

No additional response items.


Streaming

GetStreamingStatus

Get current streaming and recording status.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
streaming boolean Current streaming status.
recording boolean Current recording status.
stream-timecode String (optional) Time elapsed since streaming started (only present if currently streaming).
rec-timecode String (optional) Time elapsed since recording started (only present if currently recording).
preview-only boolean Always false. Retrocompatibility with OBSRemote.

StartStopStreaming

Toggle streaming on or off.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


StartStreaming

Start streaming. Will return an error if streaming is already active.

Request Fields:

Name Type Description
stream Object (optional) Special stream configuration.
type String (optional) If specified ensures the type of stream matches the given type (usually 'rtmp_custom' or 'rtmp_common'). If the currently configured stream type does not match the given stream type, all settings must be specified in the settings object or an error will occur when starting the stream.
metadata Object (optional) Adds the given object parameters as encoded query string parameters to the 'key' of the RTMP stream. Used to pass data to the RTMP service about the streaming. May be any String, Numeric, or Boolean field.
settings Object (optional) Settings for the stream.
settings.server String (optional) The publish URL.
settings.key String (optional) The publish key of the stream.
settings.use-auth boolean (optional) Indicates whether authentication should be used when connecting to the streaming server.
settings.username String (optional) If authentication is enabled, the username for the streaming server. Ignored if use-auth is not set to true.
settings.password String (optional) If authentication is enabled, the password for the streaming server. Ignored if use-auth is not set to true.

Response Items:

No additional response items.


StopStreaming

Stop streaming. Will return an error if streaming is not active.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


Recording

StartStopRecording

Toggle recording on or off.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


StartRecording

Start recording. Will return an error if recording is already active.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


StopRecording

Stop recording. Will return an error if recording is not active.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


SetRecordingFolder

Change the current recording folder.

Request Fields:

Name Type Description
rec-folder Stsring Path of the recording folder.

Response Items:

No additional response items.


GetRecordingFolder

Get the path of the current recording folder.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
rec-folder String Path of the recording folder.

Replay Buffer

StartStopReplayBuffer

Toggle the Replay Buffer on/off.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


StartReplayBuffer

Start recording into the Replay Buffer. Will return an error if the Replay Buffer is already active or if the "Save Replay Buffer" hotkey is not set in OBS' settings. Setting this hotkey is mandatory, even when triggering saves only through obs-websocket.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


StopReplayBuffer

Stop recording into the Replay Buffer. Will return an error if the Replay Buffer is not active.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


SaveReplayBuffer

Save and flush the contents of the Replay Buffer to disk. This is basically the same as triggering the "Save Replay Buffer" hotkey. Will return an error if the Replay Buffer is not active.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


Transitions

GetTransitionList

List of all transitions available in the frontend's dropdown menu.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
current-transition String Name of the currently active transition.
transitions Object|Array List of transitions.
transitions[].name String Name of the transition.

GetCurrentTransition

Get the name of the currently selected transition in the frontend's dropdown menu.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
name String Name of the selected transition.
duration int (optional) Transition duration (in milliseconds) if supported by the transition.

SetCurrentTransition

Set the active transition.

Request Fields:

Name Type Description
transition-name String The name of the transition.

Response Items:

No additional response items.


SetTransitionDuration

Set the duration of the currently selected transition if supported.

Request Fields:

Name Type Description
duration int Desired duration of the transition (in milliseconds).

Response Items:

No additional response items.


GetTransitionDuration

Get the duration of the currently selected transition if supported.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
transition-duration int Duration of the current transition (in milliseconds).

Scene Collections

SetCurrentSceneCollection

Change the active scene collection.

Request Fields:

Name Type Description
sc-name String Name of the desired scene collection.

Response Items:

No additional response items.


GetCurrentSceneCollection

Get the name of the current scene collection.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
sc-name String Name of the currently active scene collection.

Profiles

SetCurrentProfile

Set the currently active profile.

Request Fields:

Name Type Description
profile-name String Name of the desired profile.

Response Items:

No additional response items.


GetCurrentProfile

Get the name of the current profile.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
profile-name String Name of the currently active profile.

ListProfiles

Get a list of available profiles.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
profiles Object|Array List of available profiles.

Settings

SetStreamingSettings

Sets one or more attributes of the current streaming server settings. Any options not passed will remain unchanged. Returns the updated settings in response. If 'type' is different than the current streaming service type, all settings are required. Returns the full settings of the stream (the same as GetStreamSettings).

Request Fields:

Name Type Description
type String The type of streaming service configuration, usually rtmp_custom or rtmp_common.
settings Object The actual settings of the stream.
settings.server String (optional) The publish URL.
settings.key String (optional) The publish key.
settings.use-auth boolean (optional) Indicates whether authentication should be used when connecting to the streaming server.
settings.username String (optional) The username for the streaming service.
settings.password String (optional) The password for the streaming service.
save boolean Persist the settings to disk.

Response Items:

No additional response items.


GetStreamSettings

Get the current streaming server settings.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
type String The type of streaming service configuration. Usually 'rtmp_custom' or 'rtmp_common'.
settings Object Setings of the stream.
settings.server String The publish URL.
settings.key String The publish key of the stream.
settings.use-auth boolean Indicates whether audentication should be used when connecting to the streaming server.
settings.username String The username to use when accessing the streaming server. Only present if use-auth is true.
settings.password String The password to use when accessing the streaming server. Only present if use-auth is true.

SaveStreamSettings

Save the current streaming server settings to disk.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


Studio Mode

GetStudioModeStatus

Indicates if Studio Mode is currently enabled.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
studio-mode boolean Indicates if Studio Mode is enabled.

GetPreviewScene

Get the name of the currently previewed scene and its list of sources. Will return an error if Studio Mode is not enabled.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
name String The name of the active preview scene.
sources Source|Array

SetPreviewScene

Set the active preview scene. Will return an error if Studio Mode is not enabled.

Request Fields:

Name Type Description
scene-name String The name of the scene to preview.

Response Items:

No additional response items.


TransitionToProgram

Transitions the currently previewed scene to the main output. Will return an error if Studio Mode is not enabled.

Request Fields:

Name Type Description
with-transition Object (optional) Change the active transition before switching scenes. Defaults to the active transition.
with-transition.name String Name of the transition.
with-transition.duration int (optional) Transition duration (in milliseconds).

Response Items:

No additional response items.


EnableStudioMode

Enables Studio Mode.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


DisableStudioMode

Disables Studio Mode.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


ToggleStudioMode

Toggles Studio Mode.

Request Fields:

No specified parameters.

Response Items:

No additional response items.


GetSpecialSources

Get configured special sources like Desktop Audio and Mic/Aux sources.

Request Fields:

No specified parameters.

Response Items:

Name Type Description
desktop-1 String (optional) Name of the first Desktop Audio capture source.
desktop-2 String (optional) Name of the second Desktop Audio capture source.
mic-1 String (optional) Name of the first Mic/Aux input source.
mic-2 String (optional) Name of the second Mic/Aux input source.
mic-3 String (optional) NAme of the third Mic/Aux input source.