Skip to content

STXClient

public sealed class STXClient : IDisposable
public STXClient(STXClientOptions? options = null)

The client is thread-safe; share one per exchange. Every method is async and takes an optional CancellationToken ct as its last parameter.

Property Type Default
Region, Environment STXRegion?, STXEnvironment? from STX_REGION, STX_ENV or the profile
Host string? from STX_HOST or the profile; overrides Region and Environment
KeyId string? from STX_KEY_ID or the profile
PrivateKey string?: PEM text or a path from STX_PRIVATE_KEY or the profile
Signer Func<byte[], byte[]>? instead of PrivateKey
ClientId, ClientSecret string?: an OAuth app from STX_OAUTH_CLIENT_ID, STX_OAUTH_CLIENT_SECRET or the profile
Scope string?: the app token’s scopes, space-separated every app scope the app is allowed
Profile string? STX_PROFILE, then default
VerifyTls bool? true
Retry STXRetryPolicy STXRetryPolicy.Default
Timeout TimeSpan 30 seconds
OnResponse Action<STXResponseEvent>? none
LoggerFactory ILoggerFactory? none
HttpHandler HttpMessageHandler? a pooled SocketsHttpHandler
UseEnvironment bool true: read STX_* variables and the credentials file

Properties: BaseUrl, SocketUrl, Host, Credentials (STXApiKeyCredentials?), AppToken (STXAppToken?), Options; static UserAgent.

Method Returns
GetMeAsync() Me: UserId, AccountId, KeyId, Scope
GetUserIdAsync() string, cached after the first call
Method Returns
GetMarketsAsync(marketIds, eventIds, status, trading, sports, competitions, sortBy, sortDirection, limit, cursor) STXPage<Market>
GetAllMarketsAsync(...) (same filters, no cursor) IAsyncEnumerable<Market>
GetMarketAsync(marketId) Market, or STXNotFoundException
GetEventsAsync(eventIds, sports, competitions, eventTypes, title, status, promoted, sortBy, sortDirection, limit, cursor) STXPage<Event>
GetAllEventsAsync(...) IAsyncEnumerable<Event>
GetEventPlayersAsync(eventId) EventPlayers: Teams, Stats
GetMarketTypesAsync() IReadOnlyDictionary<string, MarketType>, keyed by rule
CreateMarketsAsync(eventId, IEnumerable<STXNewMarket> markets, dryRun, validate) IReadOnlyList<STXCreateMarketResult>: Index, Status, MarketId, Reason, Market; see Create markets
GetCapabilitiesAsync(refresh, probeChannels) STXCapabilities; see What you can do

List filters take any IEnumerable<string>, e.g. status: ["open", "pre_open"].

Method Returns
PlaceOrderAsync(marketId, action, orderType, quantity, price, clientOrderId, expiration, expirationTime, cancelOnDisconnect) Order
PlaceOrderAsync(STXOrderRequest order) Order
PlaceOrdersAsync(IEnumerable<STXOrderRequest> orders) IReadOnlyList<STXBatchOrderResult>: Order or Errors, Ok
CancelOrderAsync(orderId) Cancellation: OrderId, Status
CancelOrdersAsync(IEnumerable<string> orderIds) IReadOnlyList<Cancellation>
CancelAllOrdersAsync() IReadOnlyList<Cancellation>
GetOrdersAsync(orderIds, clientOrderIds, marketIds, status, limit, cursor) STXPage<Order>
GetAllOrdersAsync(...) IAsyncEnumerable<Order>
GetOrderAsync(orderId) Order

STXOrderAction.Buy, STXOrderAction.Sell, STXOrderType.Limit and STXOrderType.Market name the wire values.

Method Returns
GetBalanceAsync() Balance
GetPositionsAsync(marketIds) IReadOnlyList<Position>
GetFillsAsync(marketIds, orderIds, status, limit, cursor) / GetAllFillsAsync STXPage<Fill> / IAsyncEnumerable<Fill>
GetAccountMarketStatsAsync(marketIds, eventIds, excludeZeroSettlements, fromTime, toTime, sports, competitions, limit, cursor, unsettledOnly) / GetAllAccountMarketStatsAsync STXPage<MarketStat> / IAsyncEnumerable<MarketStat>
GetSettlementsAsync(marketIds, type, limit, cursor) / GetAllSettlementsAsync STXPage<Settlement> / IAsyncEnumerable<Settlement>
GetDepositsAsync, GetWithdrawalsAsync, GetAdjustmentsAsync (limit, cursor) and their GetAll twins PaymentTransaction pages
GetFeesAsync / GetAllFeesAsync FeeTransaction pages
GetLoyaltyAsync / GetAllLoyaltyAsync Transaction pages
AcceptTermsAsync(acceptTerms, acceptPrivacy, acceptHouseRules) string: the exchange’s message
GetLeaderboardAsync(period, category, metric, limit) Leaderboard
GetLeaderboardStandingAsync(period, category) LeaderboardStanding
UpdateProfileAsync(handle, avatar, leaderboardOptIn) Me
Method Returns
CreateWebSocket(STXWebSocketOptions? options) STXWebSocket; see STXWebSocket

IReadOnlyList<T> plus Cursor (string?, null on the last page) and HasMore.

A record: MaxAttempts (3), InitialBackoff (0.5 s), MaxBackoff (30 s), Jitter (true). STXRetryPolicy.Default, STXRetryPolicy.None; change one with with { MaxAttempts = 5 }.

Method, Path, Status (null when no answer arrived), Attempt, Duration, RequestBody, ResponseBody.

new STXApiKeyCredentials(keyId, privateKey) (PEM text or path) or new STXApiKeyCredentials(keyId, signer). Headers(method, path) returns the three signed headers for one request; BuildMessage(timestampMs, method, path) the string that is signed.