Unofficial C# client library for the Streamlabs socket API. Allows you to receive events from Streamlabs in real-time.
dotnet add package Streamlabs.SocketClient
If you use Dependency Injection, you can use the Streamlabs.SocketClient.Extensions package for easier setup.
dotnet add package Streamlabs.SocketClient.Extensions
// provide the token directly
builder.Services.AddStreamlabsClient(options => options.Token = "store your token somewhere safe");
// or use a configuration section
builder.Services.AddStreamlabsClient(configuration.GetSection("Streamlabs"));
// automatically connect and disconnect the client
builder.Services.AddHostedService<StreamlabsStartStopWorker>();
// get the client via DI and use it
var client = serviceProvider.GetRequiredService<IStreamlabsClient>();
client.OnDonation += (sender, message) => Console.WriteLine($"Donation Received: {message.FormattedAmount}");
First, you'll need to grab your Socket API Token
from the Streamlabs Dashboard.
Open the Dashboard, then navigate to Avatar Menu
→ Account Settings
→ API Settings
→ API Tokens
.
You will find the token in the field Your Socket API Token
.
Now you're ready to set up the client. These examples show how to set up the client and listen for events:
Pull requests are welcome. Please use Conventional Commits to keep commit messages consistent.
When reporting bugs, please include the raw JSON payload of the event that caused the issue. You can find it attached to
the error message or by enabling debug logging and looking for Streamlabs: Event received - [json]
.
Alternatively, you can use the Event Capture
tool to capture events and save them to a file.
- Streamlabs API Documentation
- SocketIOClient by @doghappy is a great library for working with SocketIO servers in C#.
- Streamlabs-Events-Receiver by @ocgineer is a similar project that served as inspiration for this one.
Distributed under the MIT License. See LICENSE
for more information.