> ## 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 service — SportsX C# SDK

> Complete method reference for STXMarketService and STXEventService, including filter shapes, response models, and C# usage examples.

The market data services give you access to the full SportsX market and event catalog. `STXMarketService` handles everything market-related — from paginated listings to lightweight ID-based lookups — while `STXEventService` lets you fetch events together with their nested markets in a single call. Both services are registered as transient, so you can resolve them anywhere you inject dependencies. For task-oriented examples, see the [Markets guide](/sdks/csharp/markets).

***

## GetMarketInfosAsync

Returns a paginated list of full `STXMarketInfo` objects. Use `STXMarketInfosFilter` to narrow results by status, sport, competition, or event.

**Return type:** `Task<STXMarketInfosResponse<STXMarketInfo>>`

### Parameters

| Name     | Type                   | Required | Description                                                                      |
| -------- | ---------------------- | -------- | -------------------------------------------------------------------------------- |
| `filter` | `STXMarketInfosFilter` | No       | Filter and pagination options. Omit to retrieve the default page of all markets. |

### Example

```csharp theme={null}
var filter = new STXMarketInfosFilter
{
    Sport = "basketball",
    Status = STXMarketInfosStatus.OPEN,
    Limit = 20,
    Offset = 0
};

STXMarketInfosResponse<STXMarketInfo> response =
    await _marketService.GetMarketInfosAsync(filter);

foreach (var market in response.MarketInfos)
{
    Console.WriteLine($"{market.MarketId}: {market.Title}");
}
```

***

## GetMarketInfosWithCountAsync

Identical to `GetMarketInfosAsync` but the response includes a `TotalCount` field, which is useful when you need to render pagination controls.

**Return type:** `Task<STXMarketInfosWithCountResponse<STXMarketInfo>>`

### Parameters

| Name     | Type                   | Required | Description                    |
| -------- | ---------------------- | -------- | ------------------------------ |
| `filter` | `STXMarketInfosFilter` | No       | Filter and pagination options. |

### Example

```csharp theme={null}
var filter = new STXMarketInfosFilter { Limit = 10, Offset = 0 };

STXMarketInfosWithCountResponse<STXMarketInfo> response =
    await _marketService.GetMarketInfosWithCountAsync(filter);

Console.WriteLine($"Showing {response.MarketInfos.Count} of {response.TotalCount} markets");
```

***

## GetMarketInfosAsync (generic)

A generic overload that lets you project the response into your own model type `T`. Use this when you only need a subset of market fields and want to avoid deserializing the full `STXMarketInfo`.

**Return type:** `Task<STXMarketInfosResponse<T>>`

### Parameters

| Name     | Type                   | Required | Description                    |
| -------- | ---------------------- | -------- | ------------------------------ |
| `filter` | `STXMarketInfosFilter` | No       | Filter and pagination options. |

### Example

```csharp theme={null}
// Only deserialize the fields your model defines
public record SlimMarket(string MarketId, string Title, string Status);

var response = await _marketService.GetMarketInfosAsync<SlimMarket>(filter);
```

***

## GetMarketInfosWithCountAsync (generic)

Generic overload of `GetMarketInfosWithCountAsync`. Returns total count alongside your projected model.

**Return type:** `Task<STXMarketInfosWithCountResponse<T>>`

### Parameters

| Name     | Type                   | Required | Description                    |
| -------- | ---------------------- | -------- | ------------------------------ |
| `filter` | `STXMarketInfosFilter` | No       | Filter and pagination options. |

***

## GetShortMarketInfosAsync

Fetches lightweight market data — only ID, status, and title — for a specific list of market IDs. Use this when you already know the IDs you want and don't need the full market payload.

**Return type:** `Task<STXMarketInfosResponse<STXShortMarketInfo>>`

### Parameters

| Name        | Type                  | Required | Description                        |
| ----------- | --------------------- | -------- | ---------------------------------- |
| `marketIds` | `IEnumerable<string>` | Yes      | One or more market IDs to look up. |

### Example

```csharp theme={null}
var ids = new[] { "market-abc123", "market-def456" };

STXMarketInfosResponse<STXShortMarketInfo> response =
    await _marketService.GetShortMarketInfosAsync(ids);
```

***

## GetShortMarketInfosWithLimitAsync

Same as `GetShortMarketInfosAsync` but enforces a server-side result limit, guarding against oversized ID lists.

**Return type:** `Task<STXMarketInfosResponse<STXShortMarketInfo>>`

### Parameters

| Name        | Type                  | Required | Description                                            |
| ----------- | --------------------- | -------- | ------------------------------------------------------ |
| `marketIds` | `IEnumerable<string>` | Yes      | Market IDs to look up. The server caps the result set. |

***

## GetShortMarketInfosWithCountAsync

Returns short market info plus a `TotalCount` for the supplied ID list.

**Return type:** `Task<STXMarketInfosWithCountResponse<STXShortMarketInfo>>`

### Parameters

| Name        | Type                  | Required | Description            |
| ----------- | --------------------- | -------- | ---------------------- |
| `marketIds` | `IEnumerable<string>` | Yes      | Market IDs to look up. |

***

## GetShortMarketInfosWithCountWithLimitAsync

Combines the server-side limit of `GetShortMarketInfosWithLimitAsync` with the count field of `GetShortMarketInfosWithCountAsync`.

**Return type:** `Task<STXMarketInfosWithCountResponse<STXShortMarketInfo>>`

### Parameters

| Name        | Type                  | Required | Description            |
| ----------- | --------------------- | -------- | ---------------------- |
| `marketIds` | `IEnumerable<string>` | Yes      | Market IDs to look up. |

***

## GetSportAndCompetitionsAsync

Returns the complete sports and competitions catalog. Use this to populate sport/competition pickers or to discover valid filter values for `STXMarketInfosFilter`.

**Return type:** `Task<List<STXSportAndCompetitions>>`

### Parameters

This method takes no parameters.

### Example

```csharp theme={null}
List<STXSportAndCompetitions> catalog =
    await _marketService.GetSportAndCompetitionsAsync();

foreach (var sport in catalog)
{
    Console.WriteLine($"{sport.Sport}: {string.Join(", ", sport.Competitions)}");
}
```

***

## GetEventInfosAsync

Returns a list of events, each containing the nested `STXMarketInfo` objects that belong to it. Use `STXEventInfosFilter` to scope by sport, competition, status, or date window.

**Return type:** `Task<STXEventInfosResponse>`

### Parameters

| Name     | Type                  | Required | Description                                                           |
| -------- | --------------------- | -------- | --------------------------------------------------------------------- |
| `filter` | `STXEventInfosFilter` | No       | Filter options. Omit to retrieve the default page of upcoming events. |

### Example

```csharp theme={null}
var filter = new STXEventInfosFilter
{
    Sport = "basketball",
    EventStatusFilter = new[] { STXEventStatus.UPCOMING, STXEventStatus.LIVE },
    EventStartFrom = DateTime.UtcNow,
    EventStartTo = DateTime.UtcNow.AddDays(7),
    Limit = 50
};

STXEventInfosResponse response =
    await _eventService.GetEventInfosAsync(filter);

foreach (STXEventInfo evt in response.EventInfos)
{
    Console.WriteLine($"{evt.Title} — {evt.MarketInfos.Count} markets");
}
```

***

## Filter and model reference

### STXMarketInfosFilter

Use this class to control which markets are returned and how results are paginated.

```csharp theme={null}
public class STXMarketInfosFilter
{
    public STXMarketInfosStatus? Status { get; set; }   // OPEN, CLOSED, SETTLED, …
    public STXMarketInfosTrading? Trading { get; set; } // TRUE, FALSE, ALL
    public string Sport { get; set; }
    public string Competition { get; set; }
    public string EventId { get; set; }
    public int? Limit { get; set; }
    public int? Offset { get; set; }
}
```

Enum values for `Status` and `Trading` are defined in `STX.Sdk.Enums`. See the [GitHub source](https://github.com/betstackai/cssdk/tree/main/STX.Sdk/STX.Sdk/Enums) for the complete list.

### STXMarketInfo — key fields

| Field                           | Description                                                          |
| ------------------------------- | -------------------------------------------------------------------- |
| `MarketId`                      | Unique market identifier                                             |
| `EventId`                       | ID of the parent event                                               |
| `Status`                        | `open`, `closed`, `settled`, or similar                              |
| `Sport`, `Competition`, `Title` | Human-readable descriptors                                           |
| `Rules`                         | Market type — `PLAYER_STAT_LINE`, `SPREAD`, `OVER_UNDER`, and others |
| `Specifier`                     | Line value, e.g. `7.5` or `"Player Name\|id\|STAT\|value"`           |
| `MaxPrice`                      | Settlement maximum in cents                                          |
| `Participants`                  | Teams or players involved in the market                              |

### STXEventInfosFilter

```csharp theme={null}
public class STXEventInfosFilter
{
    public string Sport { get; set; }
    public string Competition { get; set; }
    public STXEventStatus[] EventStatusFilter { get; set; }
    public DateTime? EventStartFrom { get; set; }
    public DateTime? EventStartTo { get; set; }
    public int? Limit { get; set; }
}
```

### STXEventInfo

```csharp theme={null}
public class STXEventInfo
{
    public string EventId { get; set; }
    public string Title { get; set; }
    public string Sport { get; set; }
    public string Competition { get; set; }
    public STXEventStatus Status { get; set; }
    public DateTime EventStart { get; set; }
    public List<STXMarketInfo> MarketInfos { get; set; }
}
```
