.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,ApiSecretfrom SSIPrivateKeyfor order signing- OTP for the Trading/Stream authentication flows
Installation
dotnet add package SSIDeveloper.FastConnect.SdkOr 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- Create a
Configwithnew Config(clientId). - Initialize
AuthClientwithnew AuthClient(config). - Call
await auth.AuthenticateAsync(otp)— leaveotpblank if only using market data. For Smart OTP (approve in the app), see Approve OTP. - Initialize the client you need (
DataClient,TradingClient,StreamClient) withauth. - For
StreamClient, callawait stream.ConnectAsync()before subscribing. - Use
using/using varforAuthClientandStreamClient(both implementIDisposable) 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"inConfigwhen 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 varforAuthClientandStreamClientto properly release the underlyingHttpClient/WebSocket.