Skip to content

Quickstart

Shortest path from zero to your first authenticated call against an STX demo environment.

  • .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
dotnet new console -n StxQuickstart
cd StxQuickstart
dotnet add package STX.Sdk
dotnet add package Microsoft.Extensions.Hosting

Verify the install:

dotnet list package | grep STX.Sdk

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}");
}
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 run

You 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 rebounds

The 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.

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.

v1.5.9Changelogllms.txtllms-full.txt