Offsite order execution

The offsite order execution feature allows you to redirect your users to Kite's exchange approved order page where they place orders and come back to your application seamlessly, like a payment gateway. This way, you do not have to build, maintain, and get exchange approvals for order execution screens. The Kite Publisher program utilises offsite order execution to provide embeddable Javascript+HTML trade buttons that do not require any API integrations.

Initiating orders

Example JSON basket

[{
  "variety": "regular",
  "tradingsymbol": "INFY",
  "exchange": "NSE",
  "transaction_type": "BUY",
  "order_type": "MARKET",
  "quantity": 10,
  "readonly": false
}, {
  "variety": "regular",
  "tradingsymbol": "NIFTY15DECFUT",
  "exchange": "NFO",
  "transaction_type": "SELL",
  "order_type": "LIMIT",
  "price": 7845,
  "quantity": 1,
  "readonly": false
},
{
  "variety": "bo",
  "tradingsymbol": "RELIANCE",
  "exchange": "NSE",
  "transaction_type": "BUY",
  "order_type": "LIMIT",
  "product": "MIS",
  "price": 915.15,
  "quantity": 1,
  "stoploss": 5,
  "squareoff": 7,
  "trailing_stoploss": 1.5,
  "readonly": true
}]

Posting the JSON basket

<form method="post" id="basket-form" action="https://kite.trade/connect/basket">
  <input type="hidden" name="api_key" value="xxx" />
  <input type="hidden" id="basket" name="data" value="" />
</form>

<script>
  document.getElementById("basket").value = your_basket;
  document.getElementById("basket-form").submit();
</script>

It is possible to send multiple orders which the user then confirms on a shopping basket like interface. You should prepare a JSON list of instruments to be traded with the required order parameters and POST it as a form field with the name data along with your api_key to https://kite.trade/connect/basket.

This is a browser / mobile (webview) request and has to happen at the user's end, although the basket preparation can happen in the backend. The easiest way to make the request is to create a hidden form, insert the JSON payload into it and submit it automatically using Javascript.

If you're preparing the basket client side on your web application, you can use the Kite Publisher javascript plugin to make things easier.

Note

You do not have to initiate a login using the login API to do offsite order execution. If a user is not already logged in, he'll be asked to login, otherwise, he'll be taken to the order basket directly. Either way, in the end, you will receive status and request_token at your redirect_url like in the login flow.

Linking offsite execution to Kite Connect

Offsite order execution follows the same flow as login, except for the order basket that appears after the login. Once the user is done placing orders, the basket will redirect back to your registered redirect_login along with a request_key, exactly like login. You are free to use this key to create a new Kite Connect session for further API interactions, or disregard it altogether.

Request parameters

parameter  
variety Order variety (regular, amo, bo, co. Defaults to regular)
tradingsymbol Tradingsymbol of the instrument
exchange Name of the exchange
transaction_type BUY or SELL
order_type Order type (MARKET, LIMIT etc.)
quantity Quantity to transact
product Margin product. More on margin products here.
price For LIMIT orders
trigger_price For SL, SL-M etc.
stoploss Stoploss price (for BO)
squareoff Squareoff price / target price (for BO)
trailing_stoploss Trailing stoploss price (for BO)
disclosed_quantity Quantity to disclose publicly (for equity trades)
validity Order validity
readonly Default is false. If set to true, the UI does not allow the user to edit values such as quantity, price etc., and they can only review and execute.
tag An optional tag to apply to an order to identify it (alphanumeric, max 8 chars)