2021-03-08 11:56:43 +00:00
<!-- This file was generated based on handlebars templates. Do not edit directly! -->
2021-04-26 16:55:33 +00:00
# obs-websocket 5.0.0 protocol reference
## General Introduction
obs-websocket provides a feature-rich RPC communication protocol, giving access to much of OBS's feature set. This document contains everything you should know in order to make a connection and use obs-websocket's functionality to the fullest.
2021-04-27 00:27:47 +00:00
### Design Goals
- Abstraction of identification, events, requests, and batch requests into dedicated message types
- Conformity of request naming using similar terms like `Get` , `Set` , `Get[x]List` , `Start[x]` , `Toggle[x]`
- Conformity of OBS data key names like `sourceName` , `sourceKind` , `sourceType` , `sceneName` , `sceneItemName`
- Error code response system - integer corrosponds to type of error, with optional comment
- Possible support for multiple message encoding options: JSON and MessagePack
- PubSub system - Allow clients to specify which events they do or don't want to receive from OBS
- RPC versioning - Client and server negotiate the latest version of the obs-websocket protocol to communicate with.
2021-04-26 16:55:33 +00:00
## Table of Contents
2021-04-26 17:01:25 +00:00
- [Connecting to obs-websocket ](#connecting-to-obs-websocket )
- [Connection steps ](#connection-steps )
- [Creating an authentication string ](#creating-an-authentication-string )
2021-04-30 17:03:08 +00:00
- [Enumerations ](#enumerations )
2021-04-26 17:01:25 +00:00
- [Base message types ](#message-types )
2021-08-28 12:14:17 +00:00
- [OpCode 0 Hello ](#hello-opcode-0 )
- [OpCode 1 Identify ](#identify-opcode-1 )
- [OpCode 2 Identified ](#identified-opcode-2 )
- [OpCode 3 Reidentify ](#reidentify-opcode-3 )
- [OpCode 5 Event ](#event-opcode-5 )
- [OpCode 6 Request ](#request-opcode-6 )
- [OpCode 7 RequestResponse ](#requestresponse-opcode-7 )
- [OpCode 8 RequestBatch ](#requestbatch-opcode-8 )
- [OpCode 9 RequestBatchResponse ](#requestbatchresponse-opcode-9 )
2021-04-26 16:55:33 +00:00
- [Events ](#events )
2021-08-28 12:02:58 +00:00
- [Requests ](#requests )
2021-03-08 11:56:43 +00:00
2021-04-26 17:01:25 +00:00
## Connecting to obs-websocket
2021-04-26 16:55:33 +00:00
Here's info on how to connect to obs-websocket
2021-03-08 11:56:43 +00:00
2021-04-27 01:52:04 +00:00
---
2021-04-26 17:01:25 +00:00
### Connection steps
2021-04-27 00:27:47 +00:00
These steps should be followed precisely. Failure to connect to the server as instructed will likely result in your client being treated in an undefined way.
2021-08-28 12:02:58 +00:00
- Initial HTTP request made to the obs-websocket server.
2021-04-27 00:27:47 +00:00
- HTTP request headers can be used to set the websocket communication type. The default format is JSON. Example headers:
- `Content-Type: application/json`
2021-06-13 09:43:46 +00:00
- `Content-Type: application/msgpack`
2021-08-28 12:02:58 +00:00
- If an invalid `Content-Type` is specified, the connection will be closed with [`WebSocketCloseCode::InvalidContentType` ](#websocketclosecode-enum ) after upgrade (but before `Hello` ).
2021-04-27 00:27:47 +00:00
2021-08-28 12:14:17 +00:00
- Once the connection is upgraded, the websocket server will immediately send an [OpCode 0 `Hello` ](#hello-opcode-0 ) message to the client.
2021-04-27 00:27:47 +00:00
2021-08-28 12:14:17 +00:00
- The client listens for the `Hello` and responds with an [OpCode 1 `Identify` ](#identify-opcode-1 ) containing all appropriate session parameters.
2021-08-28 12:02:58 +00:00
- If there is an `authentication` key in the `messageData` object, the server requires authentication, and the steps in [Creating an authentication string ](#creating-an-authentication-string ) should be followed.
- If there is no `authentication` key, the resulting `Identify` object sent to the server does not require an `authentication` string.
- The client determines if the server's `rpcVersion` is supported, and if not it provides its closest supported version in `Identify` .
2021-04-27 00:27:47 +00:00
2021-08-28 12:02:58 +00:00
- The server receives and processes the `Identify` sent by the client.
- If authentication is required and the `Identify` message data does not contain an `authentication` string, or the string is not correct, the connection is dropped with [`WebSocketCloseCode::AuthenticationFailed` ](#websocketclosecode-enum )
- If the client has requested an `rpcVersion` which the server cannot use, the connection is dropped with [`WebSocketCloseCode::UnsupportedProtocolVersion` ](#websocketclosecode-enum ). This system allows both the server and client to have seamless backwards compatability.
2021-04-30 17:03:08 +00:00
- If any other parameters are malformed (invalid type, etc), the connection is dropped with [`WebSocketCloseCode::InvalidIdentifyParameter` ](#websocketclosecode-enum )
2021-04-27 00:27:47 +00:00
2021-08-28 12:14:17 +00:00
- Once identification is processed on the server, the server responds to the client with an [OpCode 2 `Identified` ](#identified-opcode-2 ).
2021-04-27 00:27:47 +00:00
- The client will begin receiving events from obs-websocket and may now make requests to obs-websocket.
2021-08-28 12:14:17 +00:00
- At any time after a client has been identified, it may send an [OpCode 3 `Reidentify` ](#reidentify-opcode-3 ) message to update certain allowed session parameters. The server will respond in the same way it does during initial identification.
2021-04-27 00:59:44 +00:00
#### Connection Notes
2021-08-28 12:02:58 +00:00
- If the Content Type is `application/msgpack` , all messages must be sent over binary. If it is `application/json` , all messages must be sent over text.
2021-08-28 12:14:17 +00:00
- The obs-websocket server listens for any messages containing a `request-type` key in the first level JSON from unidentified clients. If a message matches, the connection is dropped with [`WebSocketCloseCode::UnsupportedProtocolVersion` ](#websocketclosecode-enum ) and a warning is logged.
2021-04-30 17:03:08 +00:00
- If a message with a `messageType` is not recognized to the obs-websocket server, the connection is dropped with [`WebSocketCloseCode::UnknownMessageType` ](#websocketclosecode-enum ).
2021-08-28 12:02:58 +00:00
- At no point may the client send any message other than a single `Identify` before it has received an `Identified` . Doing so will result in the connection being dropped by the server with [`WebSocketCloseCode::NotIdentified` ](#websocketclosecode-enum ).
2021-03-08 11:56:43 +00:00
2021-04-27 01:42:41 +00:00
---
2021-04-26 17:01:25 +00:00
### Creating an authentication string
2021-08-28 12:02:58 +00:00
obs-websocket uses SHA256 to transmit authentication credentials. The server starts by sending an object in the `authentication` key of its `Hello` message data. The client processes the authentication challenge and responds via the `authentication` string in the `Identify` message data.
2021-04-27 00:27:47 +00:00
For this guide, we'll be using `supersecretpassword` as the password.
2021-08-28 12:02:58 +00:00
The `authentication` object in `Hello` looks like this (example):
2021-04-27 00:27:47 +00:00
```json
{
2021-04-27 01:39:26 +00:00
"challenge": "+IxH4CnCiqpX1rM9scsNynZzbOe4KhDeYcTNS3PDaeY=",
"salt": "lM1GncleQOaCu9lT1yeUZhFYnqhsLLP1G5lAGo3ixaI="
2021-04-27 00:27:47 +00:00
}
```
2021-03-08 11:56:43 +00:00
2021-04-27 00:59:44 +00:00
To generate the authentication string, follow these steps:
- Concatenate the websocket password with the `salt` provided by the server (`password + salt`)
2021-08-28 12:02:58 +00:00
- Generate an SHA256 binary hash of the result and base64 encode it, known as a base64 secret.
2021-04-27 00:59:44 +00:00
- Concatenate the base64 secret with the `challenge` sent by the server (`base64_secret + challenge`)
2021-08-28 12:02:58 +00:00
- Generate a binary SHA256 hash of that result and base64 encode it. You now have your `authentication` string.
2021-04-27 00:59:44 +00:00
2021-08-28 12:02:58 +00:00
For real-world examples of the `authentication` string creation, refer to the obs-websocket client libraries listed on the [README ](README.md ).
2021-04-27 00:59:44 +00:00
2021-04-27 01:42:41 +00:00
---
2021-04-30 17:03:08 +00:00
### Enumerations
2021-04-27 01:39:26 +00:00
These are the enumeration definitions for various codes used by obs-websocket.
2021-08-28 12:02:58 +00:00
#### WebSocketOpCode Enum
```cpp
enum WebSocketOpCode {
Hello = 0,
Identify = 1,
Identified = 2,
Reidentify = 3,
Event = 5,
Request = 6,
RequestResponse = 7,
RequestBatch = 8,
RequestBatchResponse = 9,
};
```
#### WebSocketCloseCode Enum
```cpp
enum WebSocketCloseCode {
// Internal only
DontClose = 0,
// Reserved
UnknownReason = 4000,
// The requested `Content-Type` specified in the request HTTP header is invalid.
InvalidContentType = 4001,
// The server was unable to decode the incoming websocket message
MessageDecodeError = 4002,
// A data key is missing but required
MissingDataKey = 4003,
// A data key has an invalid type
InvalidDataKeyType = 4004,
// The specified `op` was invalid or missing
UnknownOpCode = 4005,
// The client sent a websocket message without first sending `Identify` message
NotIdentified = 4006,
// The client sent an `Identify` message while already identified
AlreadyIdentified = 4007,
// The authentication attempt (via `Identify` ) failed
AuthenticationFailed = 4008,
// The server detected the usage of an old version of the obs-websocket protocol.
UnsupportedRpcVersion = 4009,
// The websocket session has been invalidated by the obs-websocket server.
SessionInvalidated = 4010,
};
```
#### EventSubscriptions Enum
```cpp
enum EventSubscription {
// Set subscriptions to 0 to disable all events
None = 0,
// Receive events in the `General` category
General = (1 < < 0 ) ,
// Receive events in the `Config` category
Config = (1 < < 1 ) ,
// Receive events in the `Scenes` category
Scenes = (1 < < 2 ) ,
// Receive events in the `Inputs` category
Inputs = (1 < < 3 ) ,
// Receive events in the `Transitions` category
Transitions = (1 < < 4 ) ,
// Receive events in the `Filters` category
Filters = (1 < < 5 ) ,
// Receive events in the `Outputs` category
Outputs = (1 < < 6 ) ,
// Receive events in the `Scene Items` category
SceneItems = (1 < < 7 ) ,
// Receive events in the `MediaInputs` category
MediaInputs = (1 < < 8 ) ,
// Receive all event categories
All = (General | Config | Scenes | Inputs | Transitions | Filters | Outputs | SceneItems | MediaInputs),
// InputVolumeMeters event (high-volume)
InputVolumeMeters = (1 < < 9 ) ,
// InputActiveStateChanged event (high-volume)
InputActiveStateChanged = (1 < < 10 ) ,
// InputShowStateChanged event (high-volume)
InputShowStateChanged = (1 < < 11 ) ,
};
```
Subscriptions are a bitmask system. In many languages, to generate a bitmask that subscribes to `General` and `Scenes` , you would do: `subscriptions = ((1 << 0) | (1 << 2))`
2021-04-27 01:39:26 +00:00
#### RequestStatus Enum
```cpp
2021-05-14 00:56:50 +00:00
enum RequestStatus {
Unknown = 0,
// For internal use to signify a successful parameter check
NoError = 10,
Success = 100,
2021-08-28 12:14:17 +00:00
// The `requestType` key is missing from the request data
2021-05-14 00:56:50 +00:00
MissingRequestType = 203,
// The request type is invalid (does not exist)
UnknownRequestType = 204,
// Generic error code (comment is expected to be provided)
GenericError = 205,
// A required request parameter is missing
MissingRequestParameter = 300,
// The request does not have a valid requestData object.
MissingRequestData = 301,
// Generic invalid request parameter message
InvalidRequestParameter = 400,
// A request parameter has the wrong data type
InvalidRequestParameterDataType = 401,
// A request parameter (float or int) is out of valid range
RequestParameterOutOfRange = 402,
// A request parameter (string or array) is empty and cannot be
RequestParameterEmpty = 403,
2021-08-28 12:14:17 +00:00
// There are too many request parameters (eg. a request takes two optionals, where only one is allowed at a time)
TooManyRequestParameters = 404,
2021-05-14 00:56:50 +00:00
// An output is running and cannot be in order to perform the request (generic)
OutputRunning = 500,
// An output is not running and should be
OutputNotRunning = 501,
// Stream is running and cannot be
StreamRunning = 502,
// Stream is not running and should be
StreamNotRunning = 503,
// Record is running and cannot be
RecordRunning = 504,
// Record is not running and should be
RecordNotRunning = 505,
// Record is paused and cannot be
RecordPaused = 506,
// Replay buffer is running and cannot be
ReplayBufferRunning = 507,
// Replay buffer is not running and should be
ReplayBufferNotRunning = 508,
// Replay buffer is disabled and cannot be
ReplayBufferDisabled = 509,
// Studio mode is active and cannot be
StudioModeActive = 510,
// Studio mode is not active and should be
StudioModeNotActive = 511,
// Virtualcam is running and cannot be
VirtualcamRunning = 512,
// Virtualcam is not running and should be
VirtualcamNotRunning = 513,
// The specified source (obs_source_t) was of the invalid type (Eg. input instead of scene)
InvalidSourceType = 600,
// The specified source (obs_source_t) was not found (generic for input, filter, transition, scene)
SourceNotFound = 601,
// The specified source (obs_source_t) already exists. Applicable to inputs, filters, transitions, scenes
SourceAlreadyExists = 602,
// The specified input (obs_source_t-OBS_SOURCE_TYPE_FILTER) was not found
InputNotFound = 603,
// The specified input (obs_source_t-OBS_SOURCE_TYPE_INPUT) had the wrong kind
InvalidInputKind = 604,
// The specified filter (obs_source_t-OBS_SOURCE_TYPE_FILTER) was not found
FilterNotFound = 605,
// The specified transition (obs_source_t-OBS_SOURCE_TYPE_TRANSITION) was not found
TransitionNotFound = 606,
// The specified transition (obs_source_t-OBS_SOURCE_TYPE_TRANSITION) does not support setting its position (transition is of fixed type)
TransitionDurationFixed = 607,
// The specified scene (obs_source_t-OBS_SOURCE_TYPE_SCENE), (obs_scene_t) was not found
SceneNotFound = 608,
// The specified scene item (obs_sceneitem_t) was not found
SceneItemNotFound = 609,
// The specified scene collection was not found
SceneCollectionNotFound = 610,
// The specified profile was not found
ProfileNotFound = 611,
// The specified output (obs_output_t) was not found
OutputNotFound = 612,
// The specified encoder (obs_encoder_t) was not found
EncoderNotFound = 613,
// The specified service (obs_service_t) was not found
ServiceNotFound = 614,
// The specified hotkey was not found
HotkeyNotFound = 615,
// The specified directory was not found
DirectoryNotFound = 616,
2021-06-13 09:43:46 +00:00
// The specified config item (config_t) was not found. Could be section or parameter name
2021-05-14 00:56:50 +00:00
ConfigParameterNotFound = 617,
// The specified property (obs_properties_t) was not found
PropertyNotFound = 618,
2021-06-13 09:43:46 +00:00
// The specififed key (OBS_KEY_*) was not found
KeyNotFound = 619,
2021-08-28 12:14:17 +00:00
// The specified data realm (OBS_WEBSOCKET_DATA_REALM_*) was not found
DataRealmNotFound = 620,
// The scene collection already exists
SceneCollectionAlreadyExists = 621,
// There are not enough scene collections to perform the action
NotEnoughSceneCollections = 622,
// The profile already exists
ProfileAlreadyExists = 623,
// There are not enough profiles to perform the action
NotEnoughProfiles = 624,
// There are not enough scenes to perform the action
NotEnoughScenes = 625,
2021-05-14 00:56:50 +00:00
// Processing the request failed unexpectedly
RequestProcessingFailed = 700,
// Starting the Output failed
OutputStartFailed = 701,
// Duplicating the scene item failed
SceneItemDuplicationFailed = 702,
// Rendering the screenshot failed
ScreenshotRenderFailed = 703,
// Encoding the screenshot failed
ScreenshotEncodeFailed = 704,
// Saving the screenshot failed
ScreenshotSaveFailed = 705,
// Creating the directory failed
DirectoryCreationFailed = 706,
2021-06-13 09:43:46 +00:00
// The combination of request parameters cannot be used to perform an action
CannotAct = 707,
2021-08-28 12:14:17 +00:00
// Creation of a new stream service failed
StreamServiceCreationFailed = 708,
2021-04-27 01:39:26 +00:00
};
```
2021-04-30 17:03:08 +00:00
2021-08-28 12:02:58 +00:00
## Message Types (OpCodes)
The following message types are the low-level message types which may be sent to and from obs-websocket.
2021-03-08 11:56:43 +00:00
2021-08-28 12:14:17 +00:00
Messages sent from the obs-websocket server or client may contain these first-level keys, known as the base object:
2021-04-27 01:39:26 +00:00
```
{
2021-08-28 12:02:58 +00:00
"op": number,
"d": object
2021-04-27 01:39:26 +00:00
}
```
2021-08-28 12:14:17 +00:00
- `op` is a [`WebSocketOpCode` OpCode. ](#websocketopcode-enum )
- `d` is an object of the data keys associated with the operation.
2021-04-27 01:39:26 +00:00
2021-04-27 01:52:04 +00:00
---
2021-08-28 12:02:58 +00:00
### Hello (OpCode 0)
2021-04-26 16:55:33 +00:00
- Sent from: obs-websocket
- Sent to: Freshly connected websocket client
2021-04-27 01:39:26 +00:00
- Description: First message sent from the server immediately on client connection. Contains authentication information if auth is required. Also contains RPC version for version negotiation.
2021-08-28 12:14:17 +00:00
**Data Keys:**
2021-04-27 01:39:26 +00:00
```
{
2021-06-13 09:43:46 +00:00
"obsWebSocketVersion": string,
2021-04-27 01:39:26 +00:00
"rpcVersion": number,
"authentication": object(optional)
}
```
- `rpcVersion` is a version number which gets incremented on each **breaking change** to the obs-websocket protocol. Its usage in this context is to provide the current rpc version that the server would like to use.
**Example Messages:**
Authentication is required
```json
{
2021-08-28 12:02:58 +00:00
"op": 0,
"d": {
"obsWebSocketVersion": "5.0.0",
"rpcVersion": 1,
"authentication": {
"challenge": "+IxH4CnCiqpX1rM9scsNynZzbOe4KhDeYcTNS3PDaeY=",
"salt": "lM1GncleQOaCu9lT1yeUZhFYnqhsLLP1G5lAGo3ixaI="
}
2021-04-27 01:39:26 +00:00
}
}
```
Authentication is not required
```json
{
2021-08-28 12:02:58 +00:00
"op": 0,
"d": {
"obsWebSocketVersion": "5.0.0",
"rpcVersion": 1
}
2021-04-27 01:39:26 +00:00
}
```
2021-03-08 11:56:43 +00:00
2021-04-27 01:42:41 +00:00
---
2021-08-28 12:02:58 +00:00
### Identify (OpCode 1)
2021-04-26 16:55:33 +00:00
- Sent from: Freshly connected websocket client
- Sent to: obs-websocket
2021-04-27 01:39:26 +00:00
- Description: Response to `Hello` message, should contain authentication string if authentication is required, along with PubSub subscriptions and other session parameters.
2021-08-28 12:14:17 +00:00
**Data Keys:**
2021-04-27 01:39:26 +00:00
```
{
"rpcVersion": number,
"authentication": string(optional),
"ignoreInvalidMessages": bool(optional) = false,
"ignoreNonFatalRequestChecks": bool(optional) = false,
2021-05-14 08:14:53 +00:00
"eventSubscriptions": number(optional) = (EventSubscription::All)
2021-04-27 01:39:26 +00:00
}
```
- `rpcVersion` is the version number that the client would like the obs-websocket server to use.
2021-04-30 17:03:08 +00:00
- When `ignoreInvalidMessages` is true, the socket will not be closed for [`WebSocketCloseCode` ](#websocketclosecode-enum ): `MessageDecodeError` , `UnknownMessageType` , or `RequestMissingRequestId` . Instead, the message will be logged and dropped.
- When `ignoreNonFatalRequestChecks` is true, requests will ignore checks which are not critical to the function of the request. Eg calling `DeleteScene` when the target scene does not exist would still return [`RequestStatus::Success` ](#requeststatus-enum ) if this flag is enabled.
- `eventSubscriptions` is a bitmask of [`EventSubscriptions` ](#eventsubscriptions-enum ) items to subscribe to events and event categories at will. By default, all event categories are subscribed, except for events marked as high volume. High volume events must be explicitly subscribed to.
2021-04-27 01:39:26 +00:00
**Example Message:**
```json
{
2021-08-28 12:02:58 +00:00
"op": 1,
"d": {
"rpcVersion": 1,
"authentication": "Dj6cLS+jrNA0HpCArRg0Z/Fc+YHdt2FQfAvgD1mip6Y=",
"eventSubscriptions": 33
}
2021-04-27 01:39:26 +00:00
}
```
2021-03-08 11:56:43 +00:00
2021-04-27 01:42:41 +00:00
---
2021-08-28 12:02:58 +00:00
### Identified (OpCode 2)
2021-04-26 16:55:33 +00:00
- Sent from: obs-websocket
- Sent to: Freshly identified client
2021-04-27 01:39:26 +00:00
- Description: The identify request was received and validated, and the connection is now ready for normal operation.
2021-08-28 12:14:17 +00:00
**Data Keys:**
2021-04-27 01:39:26 +00:00
```
{
"negotiatedRpcVersion": number
}
```
- If rpc version negotiation succeeds, the server determines the RPC version to be used and gives it to the client as `negotiatedRpcVersion`
**Example Message:**
```json
{
2021-08-28 12:02:58 +00:00
"op": 2,
"d": {
"negotiatedRpcVersion": 1
}
2021-04-27 01:39:26 +00:00
}
```
2021-03-08 11:56:43 +00:00
2021-04-27 01:42:41 +00:00
---
2021-08-28 12:02:58 +00:00
### Reidentify (OpCode 3)
2021-04-26 16:55:33 +00:00
- Sent from: Identified client
- Sent to: obs-websocket
2021-04-27 01:39:26 +00:00
- Description: Sent at any time after initial identification to update the provided session parameters.
2021-08-28 12:14:17 +00:00
**Data Keys:**
2021-04-27 01:39:26 +00:00
```
{
2021-04-30 17:03:08 +00:00
"ignoreInvalidMessages": bool(optional) = false,
"ignoreNonFatalRequestChecks": bool(optional) = false,
2021-05-14 08:14:53 +00:00
"eventSubscriptions": number(optional) = (EventSubscription::All)
2021-04-27 01:39:26 +00:00
}
```
2021-04-30 17:03:08 +00:00
- Only the listed parameters may be changed after initial identification. To change a parameter not listed, you must reconnect to the obs-websocket server.
2021-03-08 11:56:43 +00:00
2021-04-27 01:42:41 +00:00
---
2021-08-28 12:02:58 +00:00
### Event (OpCode 5)
2021-04-26 16:55:33 +00:00
- Sent from: obs-websocket
- Sent to: All subscribed and identified clients
2021-04-27 01:39:26 +00:00
- Description: An event coming from OBS has occured. Eg scene switched, source muted.
2021-08-28 12:14:17 +00:00
**Data Keys:**
2021-04-27 01:39:26 +00:00
```
{
"eventType": string,
"eventData": object(optional)
}
```
2021-03-08 11:56:43 +00:00
2021-08-28 12:02:58 +00:00
**Example Message:**
```json
{
"op": 2,
"d": {
"eventType": "StudioModeStateChanged",
"eventData": {
"studioModeEnabled": true
}
}
}
```
2021-04-27 01:42:41 +00:00
---
2021-08-28 12:02:58 +00:00
### Request (OpCode 6)
2021-04-26 16:55:33 +00:00
- Sent from: Identified client
- Sent to: obs-websocket
2021-04-27 01:39:26 +00:00
- Description: Client is making a request to obs-websocket. Eg get current scene, create source.
2021-08-28 12:14:17 +00:00
**Data Keys:**
2021-04-27 01:39:26 +00:00
```
{
"requestType": string,
"requestId": string,
"requestData": object(optional),
}
```
**Example Message:**
```json
{
2021-08-28 12:02:58 +00:00
"op": 6,
"d": {
"requestType": "SetCurrentScene",
"requestId": "f819dcf0-89cc-11eb-8f0e-382c4ac93b9c",
"requestData": {
"sceneName": "Scene 12"
}
2021-04-27 01:39:26 +00:00
}
}
```
2021-03-08 11:56:43 +00:00
2021-04-27 01:42:41 +00:00
---
2021-08-28 12:02:58 +00:00
### RequestResponse (OpCode 7)
2021-04-26 16:55:33 +00:00
- Sent from: obs-websocket
- Sent to: Identified client which made the request
2021-04-27 01:39:26 +00:00
- Description: obs-websocket is responding to a request coming from a client.
2021-08-28 12:14:17 +00:00
**Data Keys:**
2021-04-27 01:39:26 +00:00
```
{
"requestType": string,
"requestId": string,
"requestStatus": object,
"responseData": object(optional)
}
```
- The `requestType` and `requestId` are simply mirrors of what was sent by the client.
`requestStatus` object:
```
{
"result": bool,
"code": number,
"comment": string(optional)
}
```
2021-04-30 17:03:08 +00:00
- `result` is `true` if the request resulted in [`RequestStatus::Success` ](#requeststatus-enum ). False if otherwise.
2021-04-27 01:39:26 +00:00
- `code` is a [`RequestStatus` ](#requeststatus-enum ) code.
- `comment` may be provided by the server on errors to offer further details on why a request failed.
**Example Messages:**
Successful Response
```json
{
2021-08-28 12:02:58 +00:00
"op": 7,
"d": {
"requestType": "SetCurrentScene",
"requestId": "f819dcf0-89cc-11eb-8f0e-382c4ac93b9c",
"requestStatus": {
"result": true,
"code": 100
}
2021-04-27 01:39:26 +00:00
}
}
```
Failure Response
```json
{
2021-08-28 12:02:58 +00:00
"op": 7,
"d": {
"requestType": "SetCurrentScene",
"requestId": "f819dcf0-89cc-11eb-8f0e-382c4ac93b9c",
"requestStatus": {
"result": false,
"code": 608,
"comment": "Parameter: sceneName"
}
2021-04-27 01:39:26 +00:00
}
}
```
2021-03-08 11:56:43 +00:00
2021-04-27 01:42:41 +00:00
---
2021-08-28 12:02:58 +00:00
### RequestBatch (OpCode 8)
2021-04-26 16:55:33 +00:00
- Sent from: Identified client
- Sent to: obs-websocket
2021-04-27 01:52:04 +00:00
- Description: Client is making a batch of requests for obs-websocket. Requests are processed serially (in order) by the server.
2021-08-28 12:14:17 +00:00
**Data Keys:**
2021-04-27 01:52:04 +00:00
```
{
"requestId": string,
"haltOnFailure": bool(optional) = false,
"requests": array< object >
}
```
2021-08-28 12:14:17 +00:00
- When `haltOnFailure` is `true` , the processing of requests will be halted on first failure. Returns only the processed requests in [`RequestBatchResponse` ](#requestbatchresponse-opcode-9 ).
2021-08-28 12:02:58 +00:00
- Requests in the `requests` array follow the same structure as the `Request` payload data format, however `requestId` is an optional key.
2021-03-08 11:56:43 +00:00
2021-04-27 01:42:41 +00:00
---
2021-08-28 12:02:58 +00:00
### RequestBatchResponse (OpCode 9)
2021-04-26 16:55:33 +00:00
- Sent from: obs-websocket
- Sent to: Identified client which made the request
2021-04-27 01:52:04 +00:00
- Description: obs-websocket is responding to a request batch coming from the client.
2021-08-28 12:14:17 +00:00
**Data Keys:**
2021-04-27 01:52:04 +00:00
```
{
"requestId": string,
"results": array< object >
}
```
2021-03-08 11:56:43 +00:00
2021-04-27 02:04:55 +00:00
## Requests/Events Table of Contents
2021-03-08 11:56:43 +00:00
2021-04-26 16:55:33 +00:00
<!-- toc -->
2021-03-08 11:56:43 +00:00
2021-04-26 16:55:33 +00:00
- [Events ](#events )
- [Requests ](#requests )
2021-03-08 11:56:43 +00:00
2021-04-26 16:55:33 +00:00
<!-- tocstop -->
2021-03-08 11:56:43 +00:00
2021-04-26 16:55:33 +00:00
## Events
2021-03-08 11:56:43 +00:00
2021-04-26 16:55:33 +00:00
## Requests
2021-03-08 11:56:43 +00:00