Click or drag to resize
.Net Library For Kite Connect API

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
About This Library
KiteDotNet supports all methods/functions exposed by Kite Connect API and it's a wrapper built around
Kite Connect API.(See the Kite Connect API documentation for the complete list of APIs, supported parameters
and values, and response formats.)This library can be effectively used to build Rich UI applications or
Console Applications or even Build COM library that can be used by external applications like excel etc.

KiteDotNet wraps all the Raw HTTP API calls of Kite Connect in a Simple to Use Function and
and the Json Responses are parsed (Credit:- Newtonsoft.Json/James NK) and returns data that can be directly
used or analysed.

Client needs to Just call the Functions/Methods by passing correct parameters.

To see the Holdings.
Kite.GetHoldings() 'This will return string with comma seperated values and each record seperated by new Line.
You can just save it in Csv format or analyse.

To Cancel a Order
Kite.CancelRegularOrder("160012345656") 'This will cancel the Order
Other then the standard methods, KiteDotNet also comes with some custom functions to make life more easy.

Kite.GetSymbols("NSE") 'This retuns a string with all Trade symbols of NSE seperated by Comma and canbe hooked to ComboBox.
Kite.GetInstToken("NSE","BHEL") 'This returns the Instrument Token for the given parameters.

KiteDotNet also has custom Exceptions that will be raised whenever client passes wrong paramerts.

If client passes 0 as price in a Limit Order,
Unlike the other, where the order request is sent and exception is raised from Kite.Trade,
KiteDotNet will raise exception "InvalidPriceException" within the client and will not send order
request to Kite.Trade.This may little bit reduce load in Kite.Trade

Another good example is
In a Buy SL order, if the client passes Trigger Price higher than the Limit Price,
KiteDotNet will raise Exception "BuySLPriceExeption"

Basically, these are designed to restrict invalid request to reach Kite.Trade

(See KiteDotNet Library documentation for complete list of Exception)
Login Flow
Kite.Login() 'Login to Kite using WebBrowser
This library comes with a WebBrowser control that will be used to Login and the Request token is
automatically set.Client need not to copy the request token and set it manually.

Please Note You should have a valid redirect URL in your Kite App.
If you have own website then Put the fully qualified Url in the Redirect Url
else You can use as a redirect Url.
You can also use (Local Host) as redirect Url.
The most important thing is that you must add your redirect url to
Trusted sites in Internet Options by doing as follows.
Control Panel-->Network and Internet-->Internet Options-->Security-->Trusted Sites-->Add this website
Uncheck Require Server verification
Instruments Downloading
Kite.GetInstruments call will download instruments list in background.
This call will download instruments from Kite.Trade only once perday and at the first login
and stores the data in text files which will be used for Further login.
So First login of the day always take time as it downloads from Kite.Trade and download
time depends on your Network Speed and the time of calling.
Subsequents login will be super fast.

Tip:- Start your client early morning say 7.00 for Just downloading the instruments
and close.
Websocket streaming is made very easy with KiteDotNet (Credit:- WebSocket4Net/Kerry Jiang)
This Library completely removes the headache of unpacking, parsing and casting raw byes into Struct/Formats.
All the heavy load works are done in background and client is provided with actual data that can be readily
used for analysis.

Supports all modes of streaming.Client can seamlessly switch between any mode.
Automatic reconnection of WebSocket if network lost and resubscribes to all symbols that are already subscribed.
Supports Index quotes as well.

KiteDotNet has special event named "QuotesReceivedEvent" which is raised whenever new data arrives from Kite.Trade
Raised with passing "QuotesReceivedEventArgs" class which has properties for all price fields supported by Kite WebSockets.
Client Just get the Required property and use directly.
GitHub Repository
.Net Framework 4.0 and above
Call all methods/Functions in Try....Catch...End Try blcok to catch exceptions raised and for further debugging.
(See KiteDotNet Library documentation for complete list of Exception)
See Also