# Installation

> Install STX.Sdk from NuGet, required .NET version, and dependencies.

Source: https://docs.stxapp.io/sdks/csharp/installation/

## From NuGet

```bash
dotnet add package STX.Sdk
```

Or via Visual Studio's NuGet Package Manager: search for `STX.Sdk`.

Package page: [nuget.org/packages/STX.Sdk](https://www.nuget.org/packages/STX.Sdk).

## Supported runtime

| | |
|---|---|
| **Target frameworks** | `net8.0`, `net10.0` |
| **Minimum .NET SDK** | 8.0 |
| **Platforms** | Windows, macOS, Linux (any platform with .NET 8 or later) |

Older versions of the package target `net7.0`. New projects should start on 8.

## Dependencies

`STX.Sdk` pulls in a small set of battle-tested packages:

| Package | Purpose |
|---|---|
| `GraphQL.Client` + `GraphQL.Client.Serializer.Newtonsoft` | Typed GraphQL transport |
| `Microsoft.Extensions.Hosting.Abstractions` | DI + `BackgroundService` base classes |
| `Microsoft.Extensions.Http` | `HttpClient` factory |
| `Microsoft.Extensions.Logging.Abstractions` | `ILogger<T>` |
| `Microsoft.IdentityModel.Tokens`, `System.IdentityModel.Tokens.Jwt` | JWT parsing |
| `Polly` | Retry + transient-fault handling for GraphQL calls |

You don't need to reference any of these directly; they're transitive through `STX.Sdk`.

## Using the SDK without `Microsoft.Extensions.Hosting`

The canonical pattern uses `Host.CreateDefaultBuilder(...)` because that bootstraps the DI container and runs background services (session keep-alive, geolocation). For small scripts you can roll your own `ServiceCollection`:

```csharp
var services = new ServiceCollection();
services.ConfigureSTXServices(STXEnvironment.OntarioDemo);

var provider = services.BuildServiceProvider();
var login = provider.GetRequiredService<STXLoginService>();
```

Trade-off: background services (`STXSessionBackgroundService`, `STXGeoLocationBackgroundService`) won't start automatically. That is usually fine under API-key authentication, which has no session to keep alive.

## Versioning

`STX.Sdk` follows semantic versioning. Breaking changes bump the major version; new services/methods bump the minor; bug fixes bump the patch. Each release is published to NuGet from a version tag.
