.NET

Installation & Setup

Installation and setup guide for the .NET SDK

Environment Requirements

  • .NET >=8.0
  • Network access to REST API and WebSocket endpoints
  • ClientId, ApiKey, ApiSecret from SSI
  • PrivateKey for order signing
  • OTP for the Trading/Stream authentication flows

Installation

dotnet add package SSIDeveloper.FastConnect.Sdk

Or add it directly to your .csproj file:

<ItemGroup>
  <PackageReference Include="SSIDeveloper.FastConnect.Sdk" Version="3.3.2" />
</ItemGroup>

Configuration

Create a Config object with your credentials:

using SsiSdk;

var config = new Config("YOUR_CLIENT_ID")
{
    ApiKey = "YOUR_API_KEY",
    ApiSecret = "YOUR_API_SECRET",
    PrivateKey = "YOUR_PRIVATE_KEY",
};

Initialization Flow

Config → AuthClient → AuthenticateAsync(otp) → DataClient / TradingClient / StreamClient
  1. Create a Config with new Config(clientId).
  2. Initialize AuthClient with new AuthClient(config).
  3. Call await auth.AuthenticateAsync(otp) — leave otp blank if only using market data. For Smart OTP (approve in the app), see Approve OTP.
  4. Initialize the client you need (DataClient, TradingClient, StreamClient) with auth.
  5. For StreamClient, call await stream.ConnectAsync() before subscribing.
  6. Use using/using var for AuthClient and StreamClient (both implement IDisposable) to release resources properly.

Example Setup by Use Case

Market data only (no OTP needed)

using SsiSdk;

var config = new Config("YOUR_CLIENT_ID")
{
    ApiKey = "YOUR_API_KEY",
    ApiSecret = "YOUR_API_SECRET",
};

using var auth = new AuthClient(config);
await auth.AuthenticateAsync(); // No OTP needed

var data = new DataClient(auth);
var ohlc = await data.MarketData.GetOhlc1MinuteAsync("SSI");
Console.WriteLine($"Candles: {ohlc.Count}");

Trading (OTP required)

using SsiSdk;

var config = new Config("YOUR_CLIENT_ID")
{
    ApiKey = "YOUR_API_KEY",
    ApiSecret = "YOUR_API_SECRET",
    PrivateKey = "YOUR_PRIVATE_KEY",
};

using var auth = new AuthClient(config);
await auth.AuthenticateAsync("YOUR_OTP");

var trading = new TradingClient(auth);
var accounts = await trading.Account.GetAccountInfoAsync();
Console.WriteLine($"Accounts: {accounts.Count}");

Realtime streaming (OTP required)

using SsiSdk;

var config = new Config("YOUR_CLIENT_ID")
{
    ApiKey = "YOUR_API_KEY",
    ApiSecret = "YOUR_API_SECRET",
    PrivateKey = "YOUR_PRIVATE_KEY",
};

using var auth = new AuthClient(config);
await auth.AuthenticateAsync("YOUR_OTP");

using var stream = new StreamClient(auth);
await stream.ConnectAsync();
stream.Streaming.SetOnData(msg => Console.WriteLine(msg));
await stream.Streaming.SubscribeSymbolTradeAsync(["SSI"]);
await stream.WaitAsync();

Tips

  • Authenticate before calling any token-protected API.
  • For streaming, call ConnectAsync() only after authentication succeeds.
  • Set LogLevel = "DEBUG" in Config when you need to troubleshoot.
  • Keep credentials (ApiKey, ApiSecret, PrivateKey) in environment variables or a secret manager (Azure Key Vault, AWS Secrets Manager, etc.) — never hardcode them.
  • Always use using/using var for AuthClient and StreamClient to properly release the underlying HttpClient/WebSocket.

On this page