Kotak.NeoTradeApi 0.1.0-ci1

This is a prerelease version of Kotak.NeoTradeApi.
dotnet add package Kotak.NeoTradeApi --version 0.1.0-ci1
                    
NuGet\Install-Package Kotak.NeoTradeApi -Version 0.1.0-ci1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Kotak.NeoTradeApi" Version="0.1.0-ci1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Kotak.NeoTradeApi" Version="0.1.0-ci1" />
                    
Directory.Packages.props
<PackageReference Include="Kotak.NeoTradeApi" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Kotak.NeoTradeApi --version 0.1.0-ci1
                    
#r "nuget: Kotak.NeoTradeApi, 0.1.0-ci1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Kotak.NeoTradeApi@0.1.0-ci1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Kotak.NeoTradeApi&version=0.1.0-ci1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Kotak.NeoTradeApi&version=0.1.0-ci1&prerelease
                    
Install as a Cake Tool

Kotak NeoTrade API .NET SDK

Client SDK for the Kotak Securities NeoTrade APIs generated with Kiota. It targets .NET 10.0 and exposes a single entry point, NeoTradeApiClient, that fans out to request builders for login, portfolio, quick orders, user data, and script details.

Requirements

  • .NET 10.0
  • The SDK depends on the Kiota Http client and serializers declared in the project file.
  • The default base URL is https://mis.kotaksecurities.com as set in src/Kotak.NeoTradeApi/NeoTradeApiClient.cs. You can override it per the login response.

Installation

Install from NuGet once published:

dotnet add package Kotak.NeoTradeApi

Creating a client

using Kotak.NeoTradeApi;
using Microsoft.Kiota.Abstractions.Authentication;
using Microsoft.Kiota.Http.HttpClientLibrary;

// Use anonymous auth for unauthenticated calls; supply headers manually for authed calls.
var authProvider = new AnonymousAuthenticationProvider();
var adapter = new HttpClientRequestAdapter(authProvider)
{
    BaseUrl = "https://mis.kotaksecurities.com"
};

var client = new NeoTradeApiClient(adapter);

Authentication flow (TOTP + MPIN)

  1. Validate TOTP:
using Kotak.NeoTradeApi.Models;

var totpResponse = await client.Login.OneZero.TradeApiLogin.PostAsync(
    new TOTPValidateRequest
    {
        Ucc = "UCC12345",
        MobileNumber = "9876543210",
        Totp = "123456"
    });

var preAuthToken = totpResponse?.Data?.Token;
var preAuthSid = totpResponse?.Data?.Sid;
  1. Validate MPIN to get the session token and base URL:
var mpinResponse = await client.Login.OneZero.TradeApiValidate.PostAsync(
    new MPINValidateRequest { Mpin = "000000" },
    config =>
    {
        // If Kotak requires headers from the TOTP step, add them here.
        if (!string.IsNullOrEmpty(preAuthToken))
        {
            config.Headers.Add("Authorization", $"Bearer {preAuthToken}");
        }
        if (!string.IsNullOrEmpty(preAuthSid))
        {
            config.Headers.Add("sid", preAuthSid);
        }
    });

var sessionToken = mpinResponse?.Data?.Token;
var sessionSid = mpinResponse?.Data?.Sid; // present if the API returns it
var nextBaseUrl = mpinResponse?.Data?.BaseUrl;
if (!string.IsNullOrEmpty(nextBaseUrl))
{
    adapter.BaseUrl = nextBaseUrl;
}

Use sessionToken (and sessionSid if required) as headers on subsequent calls.

Example calls

Get portfolio holdings

using System.IO;

using var stream = await client.Portfolio.V1.Holdings.GetAsync(config =>
{
    config.Headers.Add("Authorization", $"Bearer {sessionToken}");
    if (!string.IsNullOrEmpty(sessionSid))
    {
        config.Headers.Add("sid", sessionSid);
    }
});

var holdingsJson = await new StreamReader(stream!).ReadToEndAsync();

Place an order

PlacePostRequestBody expects jData, a JSON string containing the Kotak order payload for multi-symbol rules. Replace the fields with values allowed by the Kotak Order API.

using Kotak.NeoTradeApi.Quick.Order.Rule.Ms.Place;

var orderPayload = new
{
    uid = "UCC12345",
    actID = "UCC12345",
    exch = "NSE",
    tradingSymbol = "INFY-EQ",
    transactionType = "BUY", // BUY or SELL
    product = "MIS",
    orderType = "LIMIT",
    quantity = 1,
    price = 1530.50,
    validity = "DAY"
};

var placeResponse = await client.Quick.Order.Rule.Ms.Place.PostAsync(
    new PlacePostRequestBody { JData = System.Text.Json.JsonSerializer.Serialize(orderPayload) },
    config => config.Headers.Add("Authorization", $"Bearer {sessionToken}"));

var orderNumber = placeResponse?.NOrdNo;

Check open orders, positions, and trades

var ordersStream = await client.Quick.User.Orders.GetAsync(cfg => cfg.Headers.Add("Authorization", $"Bearer {sessionToken}"));
var ordersJson = await new StreamReader(ordersStream!).ReadToEndAsync();

var positionsStream = await client.Quick.User.Positions.GetAsync(cfg => cfg.Headers.Add("Authorization", $"Bearer {sessionToken}"));
var positionsJson = await new StreamReader(positionsStream!).ReadToEndAsync();

var tradesStream = await client.Quick.User.Trades.GetAsync(cfg => cfg.Headers.Add("Authorization", $"Bearer {sessionToken}"));
var tradesJson = await new StreamReader(tradesStream!).ReadToEndAsync();

Cancel or modify an order

using Kotak.NeoTradeApi.Quick.Order.Cancel;
using Kotak.NeoTradeApi.Quick.Order.Vr.Modify;

// Cancel
var cancelBody = new CancelPostRequestBody
{
    // Populate fields required by the Kotak cancel API (e.g., order number, exchange, etc.).
};
await client.Quick.Order.Cancel.PostAsync(cancelBody, cfg => cfg.Headers.Add("Authorization", $"Bearer {sessionToken}"));

// Modify
var modifyBody = new ModifyPostRequestBody
{
    // Populate the form fields expected by the modify endpoint.
};
await client.Quick.Order.Vr.Modify.PostAsync(modifyBody, cfg => cfg.Headers.Add("Authorization", $"Bearer {sessionToken}"));

Order history

using Kotak.NeoTradeApi.Quick.Order.History;

var historyBody = new HistoryPostRequestBody
{
    // Provide the order identifier fields as required by the API.
};
var historyStream = await client.Quick.Order.History.PostAsync(historyBody, cfg => cfg.Headers.Add("Authorization", $"Bearer {sessionToken}"));
var historyJson = await new StreamReader(historyStream!).ReadToEndAsync();

API surface

  • client.Login.OneZero.TradeApiLogin – validate TOTP and get a pre-auth token.
  • client.Login.OneZero.TradeApiValidate – validate MPIN and obtain the session token and base URL.
  • client.Portfolio.V1.Holdings – fetch holdings (stream response).
  • client.Quick.Order.Rule.Ms.Place – place orders using jData form payload.
  • client.Quick.Order.Cancel – cancel orders.
  • client.Quick.Order.Vr.Modify – modify orders.
  • client.Quick.Order.History – fetch order history.
  • client.Quick.User.Orders – list orders.
  • client.Quick.User.Positions – list positions.
  • client.Quick.User.Trades – list trades.
  • client.ScriptDetails – access script/master data and quotes (see generated request builders for available subpaths).

Tips

  • All request methods accept a RequestConfiguration callback so you can add headers, query parameters, or middleware options per call.
  • Many endpoints return Stream; deserialize or read to text as needed.
  • If the login response returns a different baseUrl, set adapter.BaseUrl before making portfolio or order calls.
  • Handle tokens securely and refresh them according to Kotak Securities’ guidance.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0-ci1 108 1/24/2026