Tech.Zerodha.KiteConnect
3.0.9
See the version list below for details.
dotnet add package Tech.Zerodha.KiteConnect --version 3.0.9
NuGet\Install-Package Tech.Zerodha.KiteConnect -Version 3.0.9
<PackageReference Include="Tech.Zerodha.KiteConnect" Version="3.0.9" />
paket add Tech.Zerodha.KiteConnect --version 3.0.9
#r "nuget: Tech.Zerodha.KiteConnect, 3.0.9"
// Install Tech.Zerodha.KiteConnect as a Cake Addin #addin nuget:?package=Tech.Zerodha.KiteConnect&version=3.0.9 // Install Tech.Zerodha.KiteConnect as a Cake Tool #tool nuget:?package=Tech.Zerodha.KiteConnect&version=3.0.9
Kite Connect .Net library
The official .Net client for communicating with Kite Connect API.
Kite Connect is a set of REST-like APIs that expose many capabilities required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (WebSockets), and more, with the simple HTTP API collection.
Zerodha Technology Pvt. Ltd. © 2021. Licensed under the MIT License.
Requirements
KiteConnect targets netstandard2.0
. Minimum project target is .NET Framework 4.6.1 or .NET Core 2.0.
Documentation
Install Client Library
Using NuGet
Execute in Tools » NuGet Package Manager » Package Manager Console
Install-Package Tech.Zerodha.KiteConnect
Using .Net CLI
dotnet add package Tech.Zerodha.KiteConnect
Getting started
// Import library
using KiteConnect;
// Initialize Kiteconnect using apiKey. Enabling Debug will give logs of requests and responses
Kite kite = new Kite(MyAPIKey, Debug: true);
// Collect login url to authenticate user. Load this URL in browser or WebView.
// After successful authentication this will redirect to your redirect url with request token.
kite.GetLoginURL();
// Collect tokens and user details using the request token
User user = kite.GenerateSession(RequestToken, MySecret);
// Persist these tokens in database or settings
string MyAccessToken = user.AccessToken;
string MyPublicToken = user.PublicToken;
// Initialize Kite APIs with access token
kite.SetAccessToken(MyAccessToken);
// Set session expiry callback. Method can be separate function also.
kite.SetSessionExpiryHook(() => Console.WriteLine("Need to login again"));
// Example call for functions like "PlaceOrder" that returns Dictionary
Dictionary<string, dynamic> response = kite.PlaceOrder(
Exchange: Constants.EXCHANGE_CDS,
TradingSymbol: "USDINR17AUGFUT",
TransactionType: Constants.TRANSACTION_TYPE_SELL,
Quantity: 1,
Price: 64.0000m,
OrderType: Constants.ORDER_TYPE_MARKET,
Product: Constants.PRODUCT_MIS
);
Console.WriteLine("Order Id: " + response["data"]["order_id"]);
// Example call for functions like "GetHoldings" that returns a data structure
List<Holding> holdings = kite.GetHoldings();
Console.WriteLine(holdings[0].AveragePrice);
For more examples, take a look at Program.cs of KiteConnect Sample project in this repository.
WebSocket live streaming data
This library uses Events to get ticks. These events are non blocking and can be used without additional threads. Create event handlers and attach it to Ticker instance as shown in the example below.
/*
To get live price use KiteTicker websocket connection.
It is recommended to use only one websocket connection at any point of time and make sure you stop connection,
once user goes out of app.
*/
// Create a new Ticker instance
Ticker ticker = new Ticker(MyAPIKey, MyAccessToken);
// Add handlers to events
ticker.OnTick += onTick;
ticker.OnOrderUpdate += OnOrderUpdate;
ticker.OnReconnect += onReconnect;
ticker.OnNoReconnect += oNoReconnect;
ticker.OnError += onError;
ticker.OnClose += onClose;
ticker.OnConnect += onConnect;
// Engage reconnection mechanism and connect to ticker
ticker.EnableReconnect(Interval: 5,Retries: 50);
ticker.Connect();
// Subscribing to NIFTY50 and setting mode to LTP
ticker.Subscribe(Tokens: new UInt32[] { 256265 });
ticker.SetMode(Tokens: new UInt32[] { 256265 }, Mode: Constants.MODE_LTP);
// Example onTick handler
private static void onTick(Tick TickData)
{
Console.WriteLine("LTP: " + TickData.LastPrice);
}
private static void OnOrderUpdate(Order OrderData)
{
Console.WriteLine("OrderUpdate " + Utils.JsonSerialize(OrderData));
}
// Disconnect ticker before closing the application
ticker.Close();
For more details about different mode of quotes and subscribing for them, take a look at KiteConnect Sample project in this repository and Kite Connect HTTP API documentation.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- CsvTextFieldParser (>= 1.2.1)
- Microsoft.CSharp (>= 4.7.0)
- System.Text.Json (>= 4.7.1)
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 |
---|---|---|
4.3.0 | 757 | 7/3/2024 |
4.2.1 | 2,564 | 12/7/2023 |
4.2.0 | 935 | 8/21/2023 |
4.1.1 | 1,947 | 1/24/2023 |
4.1.0 | 404 | 1/13/2023 |
4.0.1 | 1,622 | 10/18/2022 |
4.0.0-pre | 181 | 8/22/2022 |
3.1.0 | 1,434 | 6/1/2022 |
3.0.9 | 1,149 | 10/5/2021 |
3.0.8 | 1,053 | 7/28/2021 |
3.0.7 | 4,967 | 11/3/2020 |
3.0.6 | 727 | 8/21/2020 |
3.0.5 | 575 | 7/23/2020 |
3.0.4 | 1,198 | 2/20/2020 |
3.0.3.1 | 722 | 12/6/2019 |
3.0.2 | 568 | 11/25/2019 |
3.0.1 | 1,452 | 7/24/2018 |
3.0.0 | 1,113 | 3/8/2018 |
1.1.2 | 1,121 | 12/19/2017 |
1.1.1 | 993 | 10/31/2017 |
1.1.0 | 895 | 10/10/2017 |
1.0.2 | 1,129 | 8/18/2017 |
1.0.1 | 1,026 | 8/16/2017 |
1.0.0 | 1,043 | 8/16/2017 |
Release