Aster.Client.Websocket 1.1.1

dotnet add package Aster.Client.Websocket --version 1.1.1
                    
NuGet\Install-Package Aster.Client.Websocket -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aster.Client.Websocket" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Aster.Client.Websocket" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Aster.Client.Websocket" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Aster.Client.Websocket --version 1.1.1
                    
#r "nuget: Aster.Client.Websocket, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Aster.Client.Websocket@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Aster.Client.Websocket&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Aster.Client.Websocket&version=1.1.1
                    
Install as a Cake Tool

Logo

Aster websocket API client

NuGet version Nuget downloads CI build

This library is a .NET client for the Aster DEX public websocket API found here:

aster-finance-futures-api.md

License:

Apache License 2.0

Highlights

  • available on NuGet as Aster.Client.Websocket
  • covers all documented market-data streams: trades, aggregate trades, kline, mark price, mini tickers, tickers, book tickers, partial and diff order books, liquidation alerts
  • authenticated user streams for margin calls, balance/position updates, order trade updates, and config changes
  • ready for private streams once the authenticated API is published
  • integrates with System.Reactive for composable stream handling
  • targets netstandard2.1, net6, net7, net8

Quick start

var exitEvent = new ManualResetEvent(false);
var url = AsterValues.FuturesApiWebsocketUrl;

using var communicator = new AsterWebsocketCommunicator(url);
using var client = new AsterWebsocketClient(communicator);

client.Streams.TradesStream.Subscribe(resp =>
{
    var trade = resp.Data;
    Console.WriteLine($"[{trade.Symbol}] {trade.Price} x {trade.Quantity}");
});

client.SetSubscriptions(
    new TradeSubscription("btcusdt"),
    new OrderBookPartialSubscription("btcusdt", 20)
);

await communicator.Start();
exitEvent.WaitOne(TimeSpan.FromSeconds(30));

User data streams

Authenticate the websocket communicator with your API key and secret to receive private events. The client refreshes the listen key for you every 55 minutes and exposes dedicated observables for each event category.

var communicator = new AsterWebsocketCommunicator(AsterValues.FuturesApiWebsocketUrl);
await communicator.Authenticate(apiKey, new AsterHmac(apiSecret));

var client = new AsterWebsocketClient(communicator);
client.Streams.AccountUpdateStream.Subscribe(update =>
{
    foreach (var balance in update.Data.Balances)
    {
        Console.WriteLine($"Balance for {balance.Asset}: {balance.WalletBalance}");
    }
});

client.Streams.OrderUpdateStream.Subscribe(evt =>
{
    var order = evt.Order;
    Console.WriteLine($"Order {order.Type} {order.Side} -> status {order.Status}, filled {order.QuantityFilled}");
});

client.Streams.ListenKeyExpiredStream.Subscribe(_ =>
    Console.WriteLine("Listen key expired – call Authenticate() again to obtain a fresh key."));

await communicator.Start();

More samples:

  • console app (link)

Working with streams

  • Raw stream: new Uri("wss://fstream.asterdex.com/ws/btcusdt@aggTrade")
  • Combined stream: call client.SetSubscriptions(...) with the desired subscriptions – the client will build /stream?streams=a/b.
  • Live subscribe/unsubscribe: use client.Send(new { method = "SUBSCRIBE", params = ..., id = ... }). The JSON contracts mirror the official docs.
  • Ping/pong handling is automatic; unsolicited PONG frames are allowed by the server.
  • One connection may subscribe to at most 200 streams, with an inbound limit of 10 messages/sec.

Backtesting support

AsterFileCommunicator replays delimited files and feeds the client with historical data:

var communicator = new AsterFileCommunicator
{
    FileNames = new[] { "data/aster_raw_btcusdt_2018-11-13.txt" },
    Delimiter = ";;"
};

var client = new AsterWebsocketClient(communicator);
client.Streams.AggregateTradesStream.Subscribe(resp =>
{
    // analyse resp.Data
});

await communicator.Start();

The tests look for uncompressed files in the data/ folder and skip automatically if they are missing.

Reconnection strategy

AsterWebsocketCommunicator retries automatically. Tunable properties:

  • ReconnectTimeout – inactivity watchdog (default 1 minute)
  • ErrorReconnectTimeout – cooldown after failures (default 1 minute)
  • DisconnectionHappened / ReconnectionHappened – observables that surface connection status

Multi-threading tips

Every stream is an Rx observable. Use ObserveOn to off-load work:

client.Streams.TradesStream
    .ObserveOn(TaskPoolScheduler.Default)
    .Subscribe(HandleTrade);

To preserve ordering across multiple subscriptions, share a gate:

var gate = new object();
client.Streams.TradesStream
      .ObserveOn(TaskPoolScheduler.Default)
      .Synchronize(gate)
      .Subscribe(HandleTrade);

client.Streams.OrderBookDiffStream
      .ObserveOn(TaskPoolScheduler.Default)
      .Synchronize(gate)
      .Subscribe(HandleBookDiff);

Need help?

Consulting and support are available – contact m@mkotas.cz.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Aster.Client.Websocket:

Package Downloads
Crypto.Websocket.Extensions

Extensions to cryptocurrency websocket clients

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 228 10/20/2025
1.1.0 146 10/20/2025
1.0.1 330 10/14/2025
1.0.0 146 10/14/2025

Enhancements