Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.sportsxapp.com/llms.txt

Use this file to discover all available pages before exploring further.

This guide walks you from an empty .NET 8 console project to a working SportsX integration: install the NuGet package, wire up dependency injection, authenticate against staging, fetch live markets, and place a resting limit order.
Use the staging endpoints while you are developing. Switching to the production URLs routes requests to the live exchange and trades with real balances. Do not point a new integration at production until you have fully tested it on staging.

Before you begin

Walkthrough

1

Create a project and install the SDK

Create a new console project and add the STX.Sdk NuGet package along with the hosting package needed for dependency injection:
dotnet new console -n SportsXQuickstart
cd SportsXQuickstart
dotnet add package STX.Sdk
dotnet add package Microsoft.Extensions.Hosting
Confirm the package resolved correctly:
dotnet list package | grep STX.Sdk
You should see STX.Sdk listed with its version number.
2

Register STX services

STX.Sdk integrates with the standard .NET DI container through a single extension method, ConfigureSTXServices. It registers every service the SDK provides — GraphQL clients, Phoenix channel classes, user storage, and background workers for session keep-alive and geolocation.Replace Program.cs with the following:
Program.cs
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using STX.Sdk;
using STX.Sdk.Services;

var host = Host.CreateDefaultBuilder(args)
    .ConfigureServices(services =>
    {
        services.ConfigureSTXServices(
            graphQLUri:  "https://in-api-staging.stxapp.io/graphiql",
            channelsUri: "wss://in-api-staging.stxapp.io/socket/websocket?token={0}&vsn=2.0.0");
    })
    .Build();

var login  = host.Services.GetRequiredService<STXLoginService>();
var market = host.Services.GetRequiredService<STXMarketService>();

await login.LoginAsync(
    email:    Environment.GetEnvironmentVariable("STX_EMAIL")!,
    password: Environment.GetEnvironmentVariable("STX_PASSWORD")!);

var resp = await market.GetMarketInfosAsync();

Console.WriteLine($"Got {resp.MarketInfos.Count} markets");
foreach (var m in resp.MarketInfos.Take(5))
{
    Console.WriteLine($"  {m.MarketId}  {m.Status,-10}  {m.Title}");
}
The {0} placeholder in channelsUri is intentional — the SDK substitutes your JWT before opening the WebSocket connection.
3

Set credentials and run

Export your staging account credentials, then run the project:
export STX_EMAIL="you@example.com"
export STX_PASSWORD="your-password"
dotnet run
Expected output:
Got 217 markets
  mkt_8f3...  open        Who wins Game 4 of the NBA Finals?
  mkt_a12...  open        LAL @ BOS moneyline
  ...
Your email or password is incorrect for the staging environment. Staging and production accounts are separate — confirm you can log in at app-staging.on.sportsxapp.com with the same credentials.
The endpoint URL is unreachable. Check that graphQLUri is set to the staging URL above and that your network allows outbound HTTPS to in-api-staging.stxapp.io.
4

Place a resting order and cancel it

After the market fetch, pick an open market and submit a small limit order. The price of 10¢ is deliberately low so the order rests in the book without matching, letting you test the full placement and cancellation flow without taking a real position.Add the following after your market-fetch code in Program.cs:
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);

Console.WriteLine($"Placed:    {order.Id} at {order.Price}c × {order.Quantity}");

await orderService.CancelOrderAsync(order.Id);
Console.WriteLine($"Cancelled: {order.Id}");
Run the project again — you should see both the placed and cancelled order IDs printed to the console.
Set cancelOnDisconnect: true to have the exchange automatically cancel the order if your process loses its WebSocket connection. This requires the active orders channel to be joined first. See Trading for details.

What you just did

  • Created a .NET 8 console project and installed STX.Sdk from NuGet.
  • Registered all SDK services in one call with ConfigureSTXServices, pointing at the staging endpoints.
  • Authenticated with STXLoginService.LoginAsync — the token is automatically stored in STXUserStorage and attached to every subsequent request.
  • Fetched live market data with STXMarketService.GetMarketInfosAsync.
  • Placed and cancelled a resting limit order using STXOrderService.

Next steps

Authentication

2FA, keep-session-alive background service, and manual token refresh.

Configuration

Per-environment endpoints, pulling URIs from appsettings.json, and DI tips.

Trading

Cancel-all, batch orders, and cancel-on-disconnect.

WebSockets

Subscribe to portfolio, order status, trade tape, and market updates.