Quickstart
1. Save your key
Section titled “1. Save your key”Create an API key on the exchange (see Authentication), save its private key as ~/.stx/stx-key.pem, and add a profile to ~/.stx/credentials:
[default]region = usenv = demokey_id = your-key-idkey_file = ~/.stx/stx-key.pem2. Create a project
Section titled “2. Create a project”dotnet new console -n StxQuickstartcd StxQuickstartdotnet add package STX.Sdk3. Replace Program.cs
Section titled “3. Replace Program.cs”using System.Globalization;using STX.Sdk;using STX.Sdk.Models;
using var client = new STXClient();
// 1. Who is this key?var me = await client.GetMeAsync();Console.WriteLine($"Key {me.KeyId} belongs to user {me.UserId} (scope {me.Scope})");
// 2. Markets: amounts are strings, exactly as the API sends them.foreach (var m in await client.GetMarketsAsync(status: ["open"], trading: true, limit: 3)) Console.WriteLine($" {m.Symbol} bid {m.Bids?.FirstOrDefault()?.Price ?? "-"} offer {m.Offers?.LastOrDefault()?.Price ?? "-"}");
// 3. Balance.var balance = await client.GetBalanceAsync();Console.WriteLine($"Available balance: {balance.AvailableBalance}");
// 4. A 1-cent limit buy on a market whose event has not started, then cancel it.Market? market = null;await foreach (var m in client.GetAllMarketsAsync(status: ["open"], trading: true, sortBy: "event_start", sortDirection: "desc")){ if (m.EventStatus == "scheduled") { market = m; break; }}if (market is not null){ var order = await client.PlaceOrderAsync(market.MarketId!, STXOrderAction.Buy, STXOrderType.Limit, quantity: "1", price: "0.01"); Console.WriteLine($"Placed {order.Id} on {market.Symbol}: {order.Status} {order.Quantity} @ {order.Price}"); var cancelled = await client.CancelOrderAsync(order.Id!); Console.WriteLine($"Cancelled: {cancelled.Status}");}4. Run it
Section titled “4. Run it”dotnet runKey e3f958aaee8d84e7de93053a2bc60f29 belongs to user bc2d4b34-5d21-4a2a-8af6-d1ad3846ac3f (scope read_write) STXNHL-26OCT221900FLAPIT-GAMEFLA bid 0.4600 offer 0.5100 STXNBA-26OCT221900CLEPHI-GAMEPHI bid 0.4800 offer 0.5200 STXNCAAF-26OCT221900LIBKENN-GAMEKENN bid 0.4800 offer 0.5200Available balance: 10019994.0700Placed 49c15a69-791c-4480-8719-9b222e4e0a5a on STXNCAAF-26OCT272000SHSUMOST-GAMEMOST: accepted 1.00 @ 0.0100Cancelled: cancelledThe example apps do the same and also stream the order book and your account.
Docs version v1.10.5

