Go client for an OBS WebSockets server



Go Reference

It's a Go client for Palakis/obs-websocket, allowing us to interact with OBS Studio via Go.


This project is still a work-in-progress.

It's currently using v4.5.0 of the protocol.


Here's the contents of examples/sources.go. For brevity, we skip error checking:

package main

import (


var localhost = "" // you'll likely have to change this :)

func main() {
	client, err := goobs.New(localhost+":4444", goobs.WithPassword("hello"))
	if err != nil {
	defer client.Disconnect()

	version, _ := client.General.GetVersion()
	fmt.Printf("Websocket server version: %s\n", version.ObsWebsocketVersion)
	fmt.Printf("OBS Studio version: %s\n", version.ObsStudioVersion)

	go func() {
		for event := range client.IncomingEvents {
			switch e := event.(type) {
			case *events.TransitionBegin:
				log.Printf("Transition the scene: %#v", e)
			case *events.Error:
				log.Printf("Got an error: %s", e.Err)
				log.Printf("Unhandled event: %#v", e.GetUpdateType())

	list, _ := client.Sources.GetSourcesList()

	fmt.Println("Available sources:")
	for _, v := range list.Sources {
		fmt.Printf("- %-25s of type %s\n", v.Name, v.TypeId)

	update := func(volume float64) {
		da := "Desktop Audio"
			Source: da,
			Volume: volume,
		volumeResp, _ := client.Sources.GetVolume(&sources.GetVolumeParams{Source: da})
		fmt.Printf("Now %q is at %.3f\n", da, volumeResp.Volume)


And the corresponding output:

go run examples/sources.go
2021/05/29 15:32:07 connecting to ws://
Websocket server version: 4.9.0
OBS Studio version: 26.1.1
Available sources:
- Video Capture Device      of type dshow_input
- Audio Output Capture      of type wasapi_output_capture
- Window Capture            of type window_capture
- Chat                      of type browser_source
- Mic/Aux                   of type wasapi_input_capture
- Desktop Audio             of type wasapi_output_capture
2021/05/29 15:32:07 Unhandled event: "SourceVolumeChanged"
Now "Desktop Audio" is at 0.300
2021/05/29 15:32:07 Unhandled event: "SourceVolumeChanged"
Now "Desktop Audio" is at 0.500
  • Expose internal structs

    Expose internal structs

    Great work on this!

    The only issue I'm currently facing is accessing nested structs like Font in SetTextFreetype2PropertiesParams. Since the struct isn't a proper type, it's a bit awkward to first initialize the parent in order to access the nested struct.

    Do you think we could improve the generator here?

    opened by muesli 8
  • Make API values optional

    Make API values optional

    It would be nice if values like SetSceneItemPropertiesParams's Locked or Rotation were pointers to their values, making setting them optional. Currently forgetting to set that member value will essentially reset the Locked status or Rotation.

    The biggest risk I see here is that newer versions of the OBS Websockets API and this library will introduce new member values. Bumping the goobs dependency (e.g. in obs-cli) is a bit risky then, as any unhandled member values could potentially cause unexpected behavior.

    See: https://github.com/muesli/obs-cli/issues/34

    opened by muesli 6
  • Please drop vendored libraries

    Please drop vendored libraries

    I packaged goobs for Debian (see https://tracker.debian.org/pkg/golang-github-andreykaipov-goobs) and had to remove the vendored libraries from the source package (internal/vendor and vendor). Since you are using go.mod can you drop the vendored libraries from the git repository?

    opened by bdrung 4
  • Please support setting the client name and version

    Please support setting the client name and version

    Please allow users of the goobs library to set the client name and version. Otherwise it will use Go-http-client/1.1. See also https://github.com/muesli/obs-cli/issues/26

    websocket.Dial takes a requestHeader of type http.Header which could be used.

    opened by bdrung 4
  • Websocket 5.0.*

    Websocket 5.0.*

    Hey there,

    I've noticed that there's a 5.0 branch that's been untouched since February. Are there any plans to update this project to support 5.0, or is it considered dead/unmaintained?

    opened by Mindgamesnl 3
  • Fix panic on connection close

    Fix panic on connection close

    When the connection is closed from OBS side handleConnection() needs to stop trying to call ReadJSON(). Otherwise the underlying websocket package panics with panic: repeated read on failed websocket connection.

    I'm not completely sure if this is the right approach to handle this issue. It works pretty well for me by listening to errors and recreating the goobs instance in this case.

    opened by lnqs 3
  • timeout waiting for authentication

    timeout waiting for authentication

    Trying to connect to OBS on Windows local network gives authentication error.

    Steps to reproduce:

    1. Configure ethernet on windows to be private and open port 4444 (not 4455 from tutorial)
    2. Configure OBS 27.2.4 with obs-websockets 4.9.1-compat
    3. Follow the "Here's a basic example" tutorial
    4. Run program

    The OBS log will show connection is established (meaning it is not a firewall issue)

    11:59:21.137: [obs-websocket 4.9.1-compat] new client connection from
    11:59:31.146: [obs-websocket 4.9.1-compat] Websocket connection with client '' closed (disconnected). Code is 1006, reason is: 'End of File'

    The program exits with:

    2022/08/14 18:53:19 timeout waiting for authentication: 10000ms
    exit status 1

    I re-entered the OBS websocket password several times to ensure it's not a typo in the password.

    opened by alexluecke 2
  • v5


    obs-websocket has not officially released v5 yet, but https://github.com/obsproject/obs-websocket/pull/863 to overhaul the documentation has been merged in and the new generated protocol can be found at https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.json.

    Although v5 still in development, I think it's possible to start tinkering around with parsing the v5 protocol json. I haven't taken a close look, but it's very likely just rewriting it from scratch would be much cleaner than trying to mold the existing code... as a lot of it is very different to v4.9.

    opened by andreykaipov 2
  • Add Go build/test workflow

    Add Go build/test workflow

    Adds two GitHub Action workflow that run for every push and pull request.

    The first one tries to build the entire project on Ubuntu, macOS, and Windows for Go 1.11 (minimum required version) as well as the latest available Go version (at the time of the action being run). It will also run go test should we have test cases in the future. Currently it will just silently pass as it doesn't find any.

    The second one runs the generator (make generate) on Ubuntu and tries to build the project with the freshly generated sources.

    opened by muesli 2
  • obs websocket v5.1.0

    obs websocket v5.1.0

    Guess there's no new stuff. Surprised there's no breaking changes!

    For posterity, release process was as follows:

    1. Bump goobs_version and obs_protocol_version in version.go
    2. Bump the versions of the links in the README.md
    3. Run make clean && make generate to pull in latest protocol changes
    4. Ensure no tests are failing via make test, modifying internal/generate/tests/main.go if necessary
    5. Double check the versions from step 1, and merge the PR in
    6. Back on the main branch, pull in the latest changes and run make release
    7. View and edit the release from the Web UI if necessary (I like to add the corresponding obs-websocket protocol version to the name of the release)
    opened by andreykaipov 1
  • client: close protocol version check connection

    client: close protocol version check connection

    This change is not important. Just a small improvement.

    I noticed that obs-websocket server closes the version check connection 5 seconds after version check. Probably according to the value of timeout_close_handshake from websocketpp.

    After this change, version check connection closes immediately.

    opened by afriza 1
  • v0.12.0(Dec 17, 2022)

    What's Changed

    • obs websocket v5.1.0 by @andreykaipov in https://github.com/andreykaipov/goobs/pull/43

    Full Changelog: https://github.com/andreykaipov/goobs/compare/v0.11.0...v0.12.0

    Source code(tar.gz)
    Source code(zip)
  • v0.11.0(Dec 17, 2022)

    What's Changed

    • ci by @andreykaipov in https://github.com/andreykaipov/goobs/pull/35
    • client: error out when connecting to an obs-websocket v4.x instance by @andreykaipov in https://github.com/andreykaipov/goobs/pull/37
    • client: error out when authentication failed by @afriza in https://github.com/andreykaipov/goobs/pull/38
    • client: don't panic if server is not running by @afriza in https://github.com/andreykaipov/goobs/pull/39
    • client: close protocol version check connection by @afriza in https://github.com/andreykaipov/goobs/pull/40
    • obs websocket v5.0.2 by @andreykaipov in https://github.com/andreykaipov/goobs/pull/41

    New Contributors

    • @afriza made their first contribution in https://github.com/andreykaipov/goobs/pull/38

    Full Changelog: https://github.com/andreykaipov/goobs/compare/v0.10.0...v0.11.0

    Source code(tar.gz)
    Source code(zip)
  • v0.10.0(Aug 11, 2022)

    This new release doesn't change much apart from housekeeping things. The v5.0.1 protocol didn't change anything either.

    I don't imagine many people immediately jumped onto the v0.9.0 release in any case.

    The only significant API change is simplified import paths for MediaInputs and SceneInputs, changing the following:

    import (
    	mediainputs "github.com/andreykaipov/goobs/api/requests/media_inputs"
    	sceneitems "github.com/andreykaipov/goobs/api/requests/scene_items"


    import (

    The motivation for this was to have gopls recognize when we use mediainputs or sceneitems in our code. It seems like it has trouble auto-importing when the directory name doesn't match the package exactly.

    Full Changelog: https://github.com/andreykaipov/goobs/compare/v0.9.0...v0.10.0

    Source code(tar.gz)
    Source code(zip)
  • v0.9.0(Aug 10, 2022)

    What's Changed

    It's the v5.0.0 release corresponding to https://github.com/obsproject/obs-websocket/releases/tag/5.0.0.

    There are unfortunately way too many changes to list. Due to the nature of the upstream protocol changing, the API has also changed, namely many requests and the field names in request bodies.

    Full Changelog: https://github.com/andreykaipov/goobs/compare/v0.8.0...v0.9.0

    New Contributors

    • @lnqs made their first contribution in https://github.com/andreykaipov/goobs/pull/31 for fixing a panic on a connection close. Never tagged a release with this change it seems!
    Source code(tar.gz)
    Source code(zip)
  • v0.8.1(Aug 14, 2022)

  • v0.8.0(Dec 29, 2021)

    What's Changed

    • Add configurable underlying dialer and request header options. (https://github.com/andreykaipov/goobs/pull/25)

      • New client options: WithDialer(x *websocket.Dialer) and WithRequestHeader(x http.Header).
    • Improve error handling and general client enhancements. (https://github.com/andreykaipov/goobs/pull/24)

      • The client errors out if it doesn't receive a response from the server after a certain timeout; configurable via the new WithResponseTimeout(x time.Duration) option. (https://github.com/andreykaipov/goobs/commit/8d28d35408f0e9fb83d8be24a2b75f579c912d0b)
      • Don't panic on unrecognized messages in the OBS eventing loop, e.g. when used against a server version like v5. (https://github.com/andreykaipov/goobs/commit/8ac3b76f74b5bb7eafacc9ece4581b8ceacaf0e4)
      • Broadcast events from OBS are now maintained in order, i.e. the oldest events are now purged if they haven't yet already been consumed, to make room for the latest. (https://github.com/andreykaipov/goobs/commit/87fc692dbbcc0ca1643364de703e0f2f9b121ebf)
      • Gracefully handle the rare case of an eventing issue happening before authentication occurs, e.g. our event loop failed parsing a raw message from the server for whatever reason. (https://github.com/andreykaipov/goobs/commit/f5a9289385aa567a00f1f5fa7def5422acd3ed91)
    • Remove the vendor directory because this isn't big enterprise. (https://github.com/andreykaipov/goobs/issues/26)

    • Use three-valued boolean values (*bools) in request bodies. (https://github.com/andreykaipov/goobs/issues/29 https://github.com/andreykaipov/goobs/issues/30)

      • Otherwise, there's no way to tell the difference between a false value and an unset value for things. See https://github.com/andreykaipov/goobs/issues/27 for issue context.

    Full Changelog: https://github.com/andreykaipov/goobs/compare/v0.7.0...v0.8.0

    Source code(tar.gz)
    Source code(zip)
  • v0.7.1(Aug 29, 2021)

  • v0.7.0(Aug 29, 2021)

    new feature:

    • configurable debug logging, see new options WithDebug(bool) and WithLogger(requests.Logger) (#20)

    maintenance things:

    • CI stuff and e2e tests (#17, #18)
    • documentation stuff (#19, #21)
    Source code(tar.gz)
    Source code(zip)
  • v0.6.0(Jun 21, 2021)


    • Nested anonymous structs are now declared as their own structs, e.g. Font, Scale, StreamSettings, etc. (https://github.com/andreykaipov/goobs/issues/8)
    • Many fields now have the omitempty JSON tag option (https://github.com/andreykaipov/goobs/issues/12) by default

    Thank you to @muesli for helping me test out this library!

    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Jun 14, 2021)

Andrey Kaipov
Andrey Kaipov
a simple shitty project for learn more about websockets

video-transmission A simple shitty project for learn more about websockets. For run this you only need to have docker in your computer and then execut

ranon rat 7 Mar 29, 2022
handling 1M websockets connections in Go

Going Infinite, handling 1M websockets connections in Go This repository holds the complete implementation of the examples seen in Gophercon Israel ta

Eran Yanay 5.3k Jan 1, 2023
Kucoin proxy for freqtrade that is using websockets to maintain candlestick/klines data in memory

Kucoin proxy for freqtrade that is using websockets to maintain candlestick/klines data in memory, thus having great performance and reducing the amount of API calls to the Kucoin API. All other calls are proxied as usual.

Mikalai Konan 95 Dec 5, 2022
A small and basic service to echo requests made via websockets

Ping Service A small and basic service to echo requests made via websockets, can be useful for measuring latency between clients and this service. Run

Linux Foundation Certification 0 Nov 18, 2021
Websockets - Chaotic Web Sockets With Golang

Chaotic Web Sockets The intention of this project is to show the behavior of a s

null 0 Jan 21, 2022
Awesome WebSocket CLient - an interactive command line client for testing websocket servers

Awesome WebSocket CLient - an interactive command line client for testing websocket servers

Morgan 254 Dec 30, 2022
BrisGolang is a Go implementation of the game of briscola using the WebSocket protocol for client/server communication.

BrisGolang BrisGolang is a Go implementation of the game of briscola using the WebSocket protocol for client/server communication. Usage You can play

Calogero Miraglia 0 Nov 1, 2021
API that upgrades connection to use websocket. Contains server and client and testing how they communicate

Websocket Test API How to execute First run server using: make run-server. Then run many client instances with: make run-client. Then start typing in

null 0 Dec 25, 2021
WebSocket Command Line Client written in Go

ws-cli WebSocket Command Line Client written in Go Installation go get github.com/kseo/ws-cli Usage $ ws-cli -url ws://echo.websocket.org connected (

Kwang Yul Seo 17 Nov 12, 2021
A tiny command line websocket client written in Go

wsc A simplistic tool for sending and receiving websocket messages from a command line. Mainly useful to test websocket servers. Getting started: $ go

Raphael Simon 49 Jan 12, 2022
Websocket client sample integration (go) for FairOS.

fairos-websocket-client FairOS websocket clients should be an extension on the FairOS OpenAPI specification, with introduction of events for seamless

Fair Data Society 2 Jul 14, 2022
Client Implementation of eosio state-history websocket.

Client Implementation of eosio state-history websocket.

Sw/eden Golang 0 Dec 6, 2022
Just a PubSub Websocket Server

Eventual Agent Just a PubSub Websocket Server The eventual agent allows cluster local apps to subscribe and publish over network. Goals Provide a WebS

Joshua Tracey 2 Dec 24, 2022
HLive is a server-side WebSocket based dynamic template-less view layer for Go.

HLive HLive is a server-side WebSocket based dynamic template-less view layer for Go. HLive is a fantastic tool for creating complex and dynamic brows

Sam Hennessy 93 Jan 8, 2023
Websocket server, implemented flow Room style

ignite A websocket server module. Require redis to scale to multi nodes. Client/server message follow format type Message struct { Event string

Dong Nguyen 3 Apr 10, 2022
Websocket server. Get data from provider API, clean data and send to websoket, when it's changed.

Описание Сервис получает данные по киберспортивным матчам CS:GO от провайдера, структурирует, очищает от лишнего и отправляет всем активным вебсокет к

null 1 Apr 6, 2022
A simple server to convert ATK-IMU901 serial data into websocket stream

A simple server to convert ATK-IMU901 serial data into WebSocket stream.

SuperMario SuperFans 1 Jan 31, 2022
Go client for an OBS WebSockets server

goobs It's a Go client for Palakis/obs-websocket, allowing us to interact with OBS Studio via Go. disclaimer This project is still a work-in-progress.

Andrey Kaipov 54 Jan 1, 2023
An OBS overlay (browser source) for mumble

Mumble UI An attempt at creating an overlay that could be used inside of OBS to show who is speaking for the DAY[0] Podcast. It is meant to be reasona

DAY[0] 1 Jan 27, 2022
Turn any program that uses STDIN/STDOUT into a WebSocket server. Like inetd, but for WebSockets.

websocketd websocketd is a small command-line tool that will wrap an existing command-line interface program, and allow it to be accessed via a WebSoc

Joe Walnes 16.6k Dec 31, 2022