Quickstart
Shortest path from zero to your first authenticated call against an STX demo environment.
Prerequisites
Section titled “Prerequisites”- .NET 8 SDK or later (
dotnet --version) - An API key created under Account → API Keys, which gives you a key ID and an Ed25519 private key. Save the key to a file, for example
~/.stx/ontario.pem
Walkthrough
Section titled “Walkthrough”Create a project and install the SDK
Section titled “Create a project and install the SDK”dotnet new console -n StxQuickstartcd StxQuickstartdotnet add package STX.Sdkdotnet add package Microsoft.Extensions.HostingVerify the install:
dotnet list package | grep STX.SdkRegister STX services
Section titled “Register STX services”Replace Program.cs with:
using Microsoft.Extensions.DependencyInjection;using Microsoft.Extensions.Hosting;using STX.Sdk;using STX.Sdk.Auth;using STX.Sdk.Services;using STX.Sdk.Settings;
var host = Host.CreateDefaultBuilder(args) .ConfigureServices(services => { services.ConfigureSTXServices( STXEnvironment.OntarioDemo, STXApiKeyCredentials.FromPemFile( Environment.GetEnvironmentVariable("STX_KEY_ID")!, Environment.GetEnvironmentVariable("STX_KEY_PATH")!)); }) .Build();
var identity = host.Services.GetRequiredService<STXIdentityService>();var market = host.Services.GetRequiredService<STXMarketService>();
// No login call. One call to learn who the key belongs to, which channels need later.var me = await identity.GetMeAsync();Console.WriteLine($"Authenticated as {me.UserId} (scope {me.Scope})");
var resp = await market.GetMarketInfosWithCountAsync();
Console.WriteLine($"Got {resp.MarketInfos.Count} of {resp.Count} markets");foreach (var m in resp.MarketInfos.Take(5)){ Console.WriteLine($" {m.MarketId} {m.Status,-10} {m.Title}");}Point at your key and run
Section titled “Point at your key and run”export STX_KEY_ID="your-key-id"export STX_KEY_PATH="$HOME/.stx/ontario.pem"dotnet run$env:STX_KEY_ID = "your-key-id"$env:STX_KEY_PATH = "$HOME\.stx\ontario.pem"dotnet runYou should see something like:
Authenticated as 4f2c... (scope read_write)Got 50 of 217 markets mkt_8f3... open Who wins Game 4 of the NBA Finals? mkt_a12... open LAL @ BOS moneyline mkt_c94... open Total points over/under 214.5 mkt_d70... open First team to 20 points mkt_e55... open Race to 10 reboundsThe first number is the page you were served, the second is the total matching the filter.
If the signature is rejected, check the host clock: the server allows 30 seconds of skew. If you see a HttpRequestException, the host isn’t reachable from your network. If placing an order fails but queries work, your key is probably read_only.
Place your first order
Section titled “Place your first order”After the market fetch, pick a market and place a tiny limit order:
using STX.Sdk.Enums;
var orderService = host.Services.GetRequiredService<STXOrderService>();var targetMarket = resp.MarketInfos.First(m => m.Status == STXMarketStatus.open);
var order = await orderService.ConfirmOrderAsync( price: 10, // cents quantity: 1, marketId: targetMarket.MarketId, action: STXOrderAction.buy, orderType: STXOrderType.limit, cancelOnDisconnect: false); // true requires the active orders channel joined
Console.WriteLine($"Placed order {order.Id} at {order.Price}c × {order.Quantity}");
await orderService.CancelOrderAsync(order.Id);Console.WriteLine($"Cancelled {order.Id}");Run again. The program should print the placed + cancelled order IDs.
Next steps
Section titled “Next steps”AuthenticationAPI keys, signing, scopes.
ConfigurationPer-environment endpoints, DI tips.
TradingCancel-all, batch orders, cancel-on-disconnect.
WebSocketsSubscribe to portfolio, orders, trades, market updates.

