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.

Market data in the SportsX SDK is split across two services. STXMarketService gives you individual markets and their counts. STXEventService gives you events (a match or game) with their associated markets pre-loaded in a single call.

List markets

Resolve STXMarketService and call GetMarketInfosAsync for a full list of markets:
var markets = serviceProvider.GetRequiredService<STXMarketService>();

var resp = await markets.GetMarketInfosAsync();

foreach (var m in resp.MarketInfos)
{
    Console.WriteLine($"{m.MarketId}  {m.Status}  {m.Title}");
}
For lightweight lookups where you already know the IDs, use GetShortMarketInfosAsync to retrieve a reduced payload:
var ids = new[] { "mkt_abc", "mkt_def" };
var shortMarkets = await markets.GetShortMarketInfosAsync(ids);

Filter markets

STXMarketInfosFilter combines the common filter fields. Pass it to GetMarketInfosAsync or GetMarketInfosWithCountAsync:
FieldTypeNotes
StatusSTXMarketInfosStatusOPEN, CLOSED, etc.
TradingSTXMarketInfosTradingTRUE, FALSE, or ALL
Sportstringe.g. "basketball", "baseball"
Competitionstringe.g. "NBA", "MLB"
EventIdstringOnly markets for a specific event
Limit / OffsetintPagination controls
var filtered = await markets.GetMarketInfosAsync(new STXMarketInfosFilter
{
    Status      = STXMarketInfosStatus.OPEN,
    Trading     = STXMarketInfosTrading.TRUE,
    Sport       = "basketball",
    Competition = "NBA",
});

Pagination

GetMarketInfosWithCountAsync returns both the paginated result and the total count. Use it when you need to display “showing N of M” or drive a full offset/limit scan:
var page = await markets.GetMarketInfosWithCountAsync(new STXMarketInfosFilter
{
    Status  = STXMarketInfosStatus.OPEN,
    Trading = STXMarketInfosTrading.TRUE,
    Limit   = 100,
    Offset  = 0,
});

Console.WriteLine($"Fetched {page.MarketInfos.Count} of {page.Count} total markets");

Browse sports and competitions

GetSportAndCompetitionsAsync returns the full catalog of sports and their associated competitions:
var catalog = await markets.GetSportAndCompetitionsAsync();

foreach (var sport in catalog)
{
    Console.WriteLine(sport.Sport);
    foreach (var competition in sport.Competitions)
        Console.WriteLine($"  {competition}");
}
Use the sport and competition strings from this call as filter values in STXMarketInfosFilter.

Query events

STXEventService bundles an event with its markets in one call — no need to make separate per-event requests:
var events = serviceProvider.GetRequiredService<STXEventService>();

var resp = await events.GetEventInfosAsync(new STXEventInfosFilter
{
    Sport = "basketball",
    EventStatusFilter = new[]
    {
        STXEventStatus.scheduled,
        STXEventStatus.live,
    },
});

foreach (var ev in resp.EventInfos)
{
    Console.WriteLine($"{ev.EventId}  {ev.Title}  ({ev.MarketInfos.Count} markets)");
}

Real-time price updates

REST calls are appropriate for snapshots and catalog browsing. For live price ticks on open markets — where latency matters — subscribe to the STXMarketChannel WebSocket wrapper instead:
var marketChannel = serviceProvider.GetRequiredService<STXMarketChannel>();

marketChannel.OnPriceUpdate += tick =>
{
    Console.WriteLine($"{tick.MarketId}  bid={tick.BestBid}  ask={tick.BestAsk}");
};

await marketChannel.ConnectAsync();
await marketChannel.SubscribeAsync("mkt_abc", "mkt_def");
See WebSockets for the full channel API including subscribe/unsubscribe at runtime.