### Funds and Margins Response Example
Source: https://kite.trade/docs/connect/v3/user
Example JSON response detailing equity and commodity funds, cash, and margin information.
```json
{
"status": "success",
"data": {
"equity": {
"enabled": true,
"net": 99725.05000000002,
"available": {
"adhoc_margin": 0,
"cash": 245431.6,
"opening_balance": 245431.6,
"live_balance": 99725.05000000002,
"collateral": 0,
"intraday_payin": 0
},
"utilised": {
"debits": 145706.55,
"exposure": 38981.25,
"m2m_realised": 761.7,
"m2m_unrealised": 0,
"option_premium": 0,
"payout": 0,
"span": 101989,
"holding_sales": 0,
"turnover": 0,
"liquid_collateral": 0,
"stock_collateral": 0,
"delivery": 0
}
},
"commodity": {
"enabled": true,
"net": 100661.7,
"available": {
"adhoc_margin": 0,
"cash": 100661.7,
"opening_balance": 100661.7,
"live_balance": 100661.7,
"collateral": 0,
"intraday_payin": 0
},
"utilised": {
"debits": 0,
"exposure": 0,
"m2m_realised": 0,
"m2m_unrealised": 0,
"option_premium": 0,
"payout": 0,
"span": 0,
"holding_sales": 0,
"turnover": 0,
"liquid_collateral": 0,
"stock_collateral": 0,
"delivery": 0
}
}
}
}
}
```
--------------------------------
### User Profile Response Example
Source: https://kite.trade/docs/connect/v3/user
Example JSON response structure for a successful user profile retrieval.
```json
{
"status": "success",
"data": {
"user_id": "AB1234",
"user_type": "individual",
"email": "xxxyyy@gmail.com",
"user_name": "AxAx Bxx",
"user_shortname": "AxAx",
"broker": "ZERODHA",
"exchanges": [
"BFO",
"MCX",
"NSE",
"CDS",
"BSE",
"BCD",
"MF",
"NFO"
],
"products": [
"CNC",
"NRML",
"MIS",
"BO",
"CO"
],
"order_types": [
"MARKET",
"LIMIT",
"SL",
"SL-M"
],
"avatar_url": null,
"meta": {
"demat_consent": "physical"
}
}
}
```
--------------------------------
### Example JSON Basket for Orders
Source: https://kite.trade/docs/connect/v3/basket
Prepare a JSON list of instruments with required order parameters for offsite execution. This format is used to POST multiple orders.
```json
[
{
"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": "co",
"tradingsymbol": "RELIANCE",
"exchange": "NSE",
"transaction_type": "BUY",
"order_type": "LIMIT",
"product": "MIS",
"price": 915.15,
"quantity": 1,
"trigger_price": 910,
"readonly": true
}
]
```
--------------------------------
### Instrument List CSV Format Example
Source: https://kite.trade/docs/connect/v3/market-quotes
This is an example of the CSV data structure returned by the instruments API. Note that `last_price` is not real-time. Use `exchange` and `tradingsymbol` as a unique key for storage.
```csv
instrument_token, exchange_token, tradingsymbol, name, last_price, expiry, strike, tick_size, lot_size, instrument_type, segment, exchange
408065,1594,INFY,INFOSYS,0,,,0.05,1,EQ,NSE,NSE
5720322,22345,NIFTY15DECFUT,,78.0,2015-12-31,,0.05,75,FUT,NFO-FUT,NFO
5720578,22346,NIFTY159500CE,,23.0,2015-12-31,9500,0.05,75,CE,NFO-OPT,NFO
645639,SILVER15DECFUT,,7800.0,2015-12-31,,1,1,FUT,MCX,MCX
```
--------------------------------
### Create an ATO Alert
Source: https://kite.trade/docs/connect/v3/alerts
This example demonstrates how to create an ATO (Alert Triggers Order) alert, which automatically places an order when triggered. It requires a 'basket' parameter containing the order details.
```curl
curl https://api.kite.trade/alerts \
-H 'X-Kite-Version: 3' \
-H 'Authorization: token api_key:access_token' \
-d 'name=NIFTY 50' \
-d 'lhs_exchange=INDICES' \
-d 'lhs_tradingsymbol=NIFTY 50' \
-d 'lhs_attribute=LastTradedPrice' \
-d 'operator=>=' \
-d 'rhs_type=constant' \
-d 'type=ato' \
-d 'rhs_constant=27000' \
-d 'basket={"name":"alerts-basket","type":"alert","tags":[],"items":[{"type":"insert","tradingsymbol":"RELIANCE","exchange":"NSE","weight":10000,"params":{"transaction_type":"BUY","product":"CNC","order_type":"MARKET","validity":"DAY","validity_ttl":1,"quantity":1,"price":0,"trigger_price":0,"disclosed_quantity":0,"last_price":0,"variety":"regular","tags":[],"squareoff":0,"stoploss":0,"trailing_stoploss":0,"iceberg_legs":0,"market_protection":0}}]}'
```
```json
{
"status": "success",
"data": {
"type": "ato",
"user_id": "AB1234",
"uuid": "a5a2b03d-4851-44b3-9d85-0123baa4a273",
"name": "NIFTY 50",
"status": "enabled",
"disabled_reason": "",
"lhs_attribute": "LastTradedPrice",
"lhs_exchange": "INDICES",
"lhs_tradingsymbol": "NIFTY 50",
"operator": ">=",
"rhs_type": "constant",
"rhs_attribute": "",
"rhs_exchange": "",
"rhs_tradingsymbol": "",
"rhs_constant": 27000,
"alert_count": 0,
"created_at": "2025-05-26 12:09:26",
"updated_at": "2025-05-26 12:09:26"
}
}
```
--------------------------------
### Example Order Response (Success)
Source: https://kite.trade/docs/connect/v3/orders
This JSON object represents a successful retrieval of order data. It includes details for cancelled, complete, and rejected orders, along with their respective statuses and quantities.
```json
{
"status": "success",
"data": [
{
"placed_by": "XXXXXX",
"order_id": "100000000000000",
"exchange_order_id": "200000000000000",
"parent_order_id": null,
"status": "CANCELLED",
"status_message": null,
"status_message_raw": null,
"order_timestamp": "2021-05-31 09:18:57",
"exchange_update_timestamp": "2021-05-31 09:18:58",
"exchange_timestamp": "2021-05-31 09:15:38",
"variety": "regular",
"modified": false,
"exchange": "CDS",
"tradingsymbol": "USDINR21JUNFUT",
"instrument_token": 412675,
"order_type": "LIMIT",
"transaction_type": "BUY",
"validity": "DAY",
"product": "NRML",
"quantity": 1,
"disclosed_quantity": 0,
"price": 72,
"trigger_price": 0,
"average_price": 0,
"filled_quantity": 0,
"pending_quantity": 1,
"cancelled_quantity": 1,
"market_protection": 0,
"meta": {},
"tag": null,
"guid": "XXXXX"
},
{
"placed_by": "XXXXXX",
"order_id": "300000000000000",
"exchange_order_id": "400000000000000",
"parent_order_id": null,
"status": "COMPLETE",
"status_message": null,
"status_message_raw": null,
"order_timestamp": "2021-05-31 15:20:28",
"exchange_update_timestamp": "2021-05-31 15:20:28",
"exchange_timestamp": "2021-05-31 15:20:28",
"variety": "regular",
"modified": false,
"exchange": "NSE",
"tradingsymbol": "IOC",
"instrument_token": 415745,
"order_type": "LIMIT",
"transaction_type": "BUY",
"validity": "DAY",
"product": "CNC",
"quantity": 1,
"disclosed_quantity": 0,
"price": 109.4,
"trigger_price": 0,
"average_price": 109.4,
"filled_quantity": 1,
"pending_quantity": 0,
"cancelled_quantity": 0,
"market_protection": 0,
"meta": {},
"tag": null,
"guid": "XXXXXX"
},
{
"placed_by": "XXXXXX",
"order_id": "500000000000000",
"exchange_order_id": "600000000000000",
"parent_order_id": null,
"status": "COMPLETE",
"status_message": null,
"status_message_raw": null,
"order_timestamp": "2021-05-31 15:20:51",
"exchange_update_timestamp": "2021-05-31 15:20:52",
"exchange_timestamp": "2021-05-31 15:20:52",
"variety": "regular",
"modified": false,
"exchange": "NSE",
"tradingsymbol": "IOC",
"instrument_token": 415745,
"order_type": "MARKET",
"transaction_type": "SELL",
"validity": "DAY",
"product": "CNC",
"quantity": 1,
"disclosed_quantity": 0,
"price": 0,
"trigger_price": 0,
"average_price": 109.35,
"filled_quantity": 1,
"pending_quantity": 0,
"cancelled_quantity": 0,
"market_protection": 0,
"meta": {},
"tag": null,
"guid": "XXXX"
},
{
"placed_by": "XXXXXX",
"order_id": "220524001859672",
"exchange_order_id": null,
"parent_order_id": null,
"status": "REJECTED",
"status_message": "Insufficient funds. Required margin is 95417.84 but available margin is 74251.80. Check the orderbook for open orders.",
"status_message_raw": "RMS:Margin Exceeds,Required:95417.84, Available:74251.80 for entity account-XXXXX across exchange across segment across product ",
"order_timestamp": "2022-05-24 12:26:52",
"exchange_update_timestamp": null,
"exchange_timestamp": null,
"variety": "iceberg",
"modified": false,
"exchange": "NSE",
"tradingsymbol": "SBIN",
"instrument_token": 779521,
"order_type": "LIMIT",
"transaction_type": "BUY",
"validity": "TTL",
"validity_ttl": 2,
"product": "CNC",
"quantity": 200,
"disclosed_quantity": 0,
"price": 463,
"trigger_price": 0,
"average_price": 0,
"filled_quantity": 0,
"pending_quantity": 0,
"cancelled_quantity": 0,
"market_protection": 0,
"meta": {
"iceberg": {
"leg": 1,
"legs": 5,
"leg_quantity": 200,
"total_quantity": 1000,
"remaining_quantity": 800
}
},
"tag": "icebergord",
"tags": [
"icebergord"
],
"guid": "XXXXXX"
},
{
"placed_by": "XXXXXX",
"order_id": "700000000000000",
"exchange_order_id": "800000000000000",
"parent_order_id": null,
"status": "COMPLETE",
"status_message": null,
"status_message_raw": null,
"order_timestamp": "2021-05-31 16:00:36",
```
--------------------------------
### Order Margins Response Structure
Source: https://kite.trade/docs/connect/v3/margins
This is an example response structure for order margin calculations, detailing various margin components and charges.
```json
{
"status": "success",
"data": [
{
"type": "equity",
"tradingsymbol": "INFY",
"exchange": "NSE",
"span": 0,
"exposure": 0,
"option_premium": 0,
"additional": 0,
"bo": 0,
"cash": 0,
"var": 1498,
"pnl": {
"realised": 0,
"unrealised": 0
},
"leverage": 1,
"charges": {
"transaction_tax": 1.498,
"transaction_tax_type": "stt",
"exchange_turnover_charge": 0.051681,
"sebi_turnover_charge": 0.001498,
"brokerage": 0.01,
"stamp_duty": 0.22,
"gst": {
"igst": 0.011372219999999999,
"cgst": 0,
"sgst": 0,
"total": 0.011372219999999999
},
"total": 1.79255122
},
"total": 1498
}
]
}
```
--------------------------------
### Retrieve Funds and Margins
Source: https://kite.trade/docs/connect/v3/user
Get overall funds and margin information for both equity and commodity segments using the /user/margins endpoint. Requires X-Kite-Version header set to 3.
```shell
curl "https://api.kite.trade/user/margins" \
-H "X-Kite-Version: 3" \
-H "Authorization: token api_key:access_token"
```
--------------------------------
### Example Position Data Structure
Source: https://kite.trade/docs/connect/v3/portfolio
This JSON structure represents a single position. It includes details such as tradingsymbol, exchange, instrument_token, product type, quantities, prices, and PnL.
```json
{
"tradingsymbol": "LEADMINI17DECFUT",
"exchange": "MCX",
"instrument_token": 53496327,
"product": "NRML",
"quantity": 1,
"overnight_quantity": 0,
"multiplier": 1000,
"average_price": 161.05,
"close_price": 0,
"last_price": 161.05,
"value": -161050,
"pnl": 0,
"m2m": 0,
"unrealised": 0,
"realised": 0,
"buy_quantity": 1,
"buy_price": 161.05,
"buy_value": 161050,
"buy_m2m": 161050,
"sell_quantity": 0,
"sell_price": 0,
"sell_value": 0,
"sell_m2m": 0,
"day_buy_quantity": 1,
"day_buy_price": 161.05,
"day_buy_value": 161050,
"day_sell_quantity": 0,
"day_sell_price": 0,
"day_sell_value": 0
}
```
```json
{
"tradingsymbol": "SBIN",
"exchange": "NSE",
"instrument_token": 779521,
"product": "CO",
"quantity": 0,
"overnight_quantity": 0,
"multiplier": 1,
"average_price": 0,
"close_price": 0,
"last_price": 308.4,
"value": -2,
"pnl": -2,
"m2m": -2,
"unrealised": -2,
"realised": 0,
"buy_quantity": 1,
"buy_price": 311,
"buy_value": 311,
"buy_m2m": 311,
"sell_quantity": 1,
"sell_price": 309,
"sell_value": 309,
"sell_m2m": 309,
"day_buy_quantity": 1,
"day_buy_price": 311,
"day_buy_value": 311,
"day_sell_quantity": 1,
"day_sell_price": 309,
"day_sell_value": 309
}
```
--------------------------------
### Response for Retrieving All Alerts
Source: https://kite.trade/docs/connect/v3/alerts
Example JSON response when retrieving all alerts. It includes details for both 'simple' and 'ato' alert types, such as user ID, UUID, name, status, and specific alert conditions.
```json
{
"status": "success",
"data": [
{
"type": "simple",
"user_id": "AB1234",
"uuid": "550e8400-e29b-41d4-a716-446655440000",
"name": "NIFTY 50",
"status": "enabled",
"disabled_reason": "",
"lhs_attribute": "LastTradedPrice",
"lhs_exchange": "INDICES",
"lhs_tradingsymbol": "NIFTY 50",
"operator": ">=",
"rhs_type": "constant",
"rhs_attribute": "",
"rhs_exchange": "",
"rhs_tradingsymbol": "",
"rhs_constant": 27000,
"alert_count": 0,
"created_at": "2025-05-26 12:07:50",
"updated_at": "2025-05-26 12:07:50"
},
{
"type": "ato",
"user_id": "AB1234",
"uuid": "e888ed4a-6801-406f-bdc2-002db5a8411d",
"name": "buy gold",
"status": "disabled",
"disabled_reason": "",
"basket": {
"items": [
{
"id": 275218517,
"tradingsymbol": "GOLDBEES",
"exchange": "NSE",
"instrument_token": 3693569,
"weight": 10000,
"params": {
"validity": "DAY",
"validity_ttl": 0,
"variety": "regular",
"product": "CNC",
"order_type": "LIMIT",
"transaction_type": "BUY",
"quantity": 10000,
"disclosed_quantity": 0,
"price": 72.22,
"trigger_price": 0,
"squareoff": 0,
"stoploss": 0,
"trailing_stoploss": 0,
"gtt": {
"target": 0,
"stoploss": 0
},
"tags": []
}
}
]
},
"lhs_attribute": "LastTradedPrice",
"lhs_exchange": "NSE",
"lhs_tradingsymbol": "GOLDBEES",
"operator": "<=",
"rhs_type": "constant",
"rhs_attribute": "",
"rhs_exchange": "",
"rhs_tradingsymbol": "",
"rhs_constant": 71.8,
"alert_count": 1,
"created_at": "2025-02-17 08:24:10",
"updated_at": "2025-02-17 09:15:20"
}
]
}
```
--------------------------------
### Custom HTML5 Link for Buy Order
Source: https://kite.trade/docs/connect/v3/publisher
Transform a standard HTML `` tag into a trade button by adding Kite-specific data attributes. This example creates a link to initiate a market buy order for SBIN.
```html
Buy SBI stock
```
--------------------------------
### Auto Slice Order Response Example
Source: https://kite.trade/docs/connect/v3/orders
This JSON response illustrates the outcome of an auto-sliced order, showing both successfully placed slices with order IDs and failed slices with error details.
```json
{
"status": "success",
"data": [
{
"order_id": "1914227164488687616"
},
{
"order_id": "1914227164534824960"
},
{
"order_id": "1914227164580962304"
},
{
"error": {
"code": 400,
"error_type": "MarginException",
"message": "Insufficient funds. Required margin is 228365.92 but available margin is 228358.50.",
"data": null
}
},
{
"order_id": "1914227164681625600"
}
]
}
```
--------------------------------
### Custom HTML5 Button for Cover Order
Source: https://kite.trade/docs/connect/v3/publisher
Configure an HTML button to initiate a Cover Order (CO) by specifying the `data-variety` attribute. This example sets up a limit buy order for RELIANCE with CO parameters.
```html
```
--------------------------------
### Get Positions
Source: https://kite.trade/docs/connect/v3/portfolio
Retrieves the user's current net positions and daily trading activity. The 'net' data represents the overall portfolio, while 'day' provides a snapshot of intraday transactions.
```APIDOC
## GET /portfolio/positions
### Description
Retrieves the user's current net positions and daily trading activity. The 'net' data represents the overall portfolio, while 'day' provides a snapshot of intraday transactions.
### Method
GET
### Endpoint
/portfolio/positions
### Headers
- X-Kite-Version: 3
- Authorization: token api_key:access_token
### Response
#### Success Response (200)
- **status** (string) - Indicates the success of the request.
- **data** (object) - Contains the portfolio data.
- **net** (array) - Array of net position objects.
- **tradingsymbol** (string) - Trading symbol of the instrument.
- **exchange** (string) - Exchange where the instrument is traded.
- **instrument_token** (integer) - Unique identifier for the instrument.
- **product** (string) - Product type (e.g., NRML, CO).
- **quantity** (integer) - Current net quantity.
- **overnight_quantity** (integer) - Quantity carried over from previous day.
- **multiplier** (integer) - Multiplier for the instrument.
- **average_price** (float) - Average buy price.
- **close_price** (float) - Closing price of the instrument.
- **last_price** (float) - Last traded price.
- **value** (float) - Total value of the position.
- **pnl** (float) - Profit or loss.
- **m2m** (float) - Mark-to-market value.
- **unrealised** (float) - Unrealised profit or loss.
- **realised** (float) - Realised profit or loss.
- **buy_quantity** (integer) - Total buy quantity.
- **buy_price** (float) - Average buy price.
- **buy_value** (float) - Total value of buy orders.
- **buy_m2m** (float) - Mark-to-market value for buy orders.
- **sell_quantity** (integer) - Total sell quantity.
- **sell_price** (float) - Average sell price.
- **sell_value** (float) - Total value of sell orders.
- **sell_m2m** (float) - Mark-to-market value for sell orders.
- **day_buy_quantity** (integer) - Intraday buy quantity.
- **day_buy_price** (float) - Intraday average buy price.
- **day_buy_value** (float) - Intraday total value of buy orders.
- **day_sell_quantity** (integer) - Intraday sell quantity.
- **day_sell_price** (float) - Intraday average sell price.
- **day_sell_value** (float) - Intraday total value of sell orders.
- **day** (array) - Array of daily position objects (same structure as net).
### Request Example
```bash
curl "https://api.kite.trade/portfolio/positions" \
-H "X-Kite-Version: 3" \
-H "Authorization: token api_key:access_token"
```
### Response Example
```json
{
"status": "success",
"data": {
"net": [
{
"tradingsymbol": "LEADMINI17DECFUT",
"exchange": "MCX",
"instrument_token": 53496327,
"product": "NRML",
"quantity": 1,
"overnight_quantity": 0,
"multiplier": 1000,
"average_price": 161.05,
"close_price": 0,
"last_price": 161.05,
"value": -161050,
"pnl": 0,
"m2m": 0,
"unrealised": 0,
"realised": 0,
"buy_quantity": 1,
"buy_price": 161.05,
"buy_value": 161050,
"buy_m2m": 161050,
"sell_quantity": 0,
"sell_price": 0,
"sell_value": 0,
"sell_m2m": 0,
"day_buy_quantity": 1,
"day_buy_price": 161.05,
"day_buy_value": 161050,
"day_sell_quantity": 0,
"day_sell_price": 0,
"day_sell_value": 0
}
],
"day": [
{
"tradingsymbol": "GOLDGUINEA17DECFUT",
"exchange": "MCX",
"instrument_token": 53505799,
"product": "NRML",
"quantity": -3,
"overnight_quantity": 0,
"multiplier": 1,
"average_price": 23340,
"close_price": 23232,
"last_price": 23355,
"value": 69972,
"pnl": -93,
"m2m": -93,
"unrealised": -93,
"realised": 0,
"buy_quantity": 1,
"buy_price": 23388,
"buy_value": 23388,
"buy_m2m": 23388,
"sell_quantity": 4,
"sell_price": 23340,
"sell_value": 93360,
"sell_m2m": 93360,
"day_buy_quantity": 1,
"day_buy_price": 23388,
"day_buy_value": 23388,
"day_sell_quantity": 4,
"day_sell_price": 23340,
"day_sell_value": 93360
}
]
}
}
```
```
--------------------------------
### Custom HTML5 Button for Sell Order
Source: https://kite.trade/docs/connect/v3/publisher
Utilize a standard HTML `