Skip to main content
Shortest path from zero to a working GraphQL call against SportsX staging.
Use staging for anything you’re building. Pointing a new integration at production trades with real balances — exercise your code path on staging first.

Prerequisites

Walkthrough

1

Create a project and install the SDK

dotnet new console -n SportsXQuickstart
cd SportsXQuickstart
dotnet add package STX.Sdk
dotnet add package Microsoft.Extensions.Hosting
Verify the install:
dotnet list package | grep STX.Sdk
2

Register STX services

Replace Program.cs with:
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}");
}
3

Set credentials + run

export STX_EMAIL="you@example.com"
export STX_PASSWORD="your-password"
dotnet run
You should see something like:
Got 217 markets
  mkt_8f3...  open        Who wins Game 4 of the NBA Finals?
  mkt_a12...  open        LAL @ BOS moneyline
  ...
If you see a STXWrongCredentialsException, your email/password is off. If you see a HttpRequestException, the endpoint URL is wrong or the host isn’t reachable from your network.
4

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

Authentication

2FA, keep-session-alive, token refresh.

Configuration

Per-environment endpoints, DI tips.

Trading

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

WebSockets

Subscribe to portfolio, orders, trades, market updates.