Introduction
The Breeze API is a powerful API through which you can fetch live/historical data, automate your trading strategies, and monitor your portfolio in real time.
An AppKey and secret_key pair is issued that allows you to connect to the server. You have to register a redirect url where you will be sent after the login.
Breeze API is designed to accept 100 API calls per minute and 5000 API calls per day.
All inputs are form-encoded parameters and responses are in the form of JSON. The success and the error states are indicated by standard HTTP codes and are accompanied by JSON data.
Asset Class | NSE |
---|---|
Equity | Yes |
Equity Futures | Yes |
Equity Options | Yes |
Currently, securities listed on BSE, MSEI and NCDEX are not available on Breeze API.
How To Navigate
The documentation specifies various API endpoints which can be used to perform many functions as stated above.
In this documentation, you will find about the following:
- The computation of the checksum
- Sending the common request headers
- API Parameters, its data type and description
- Language specific guides
- Sample JSON Response
Checksum Computation & Login
Registration
Authentication is done following the OAuth2.0 protocol. It ensures that all the fields in the request are safe from tampering.
Visit the Breeze API portal to register an app by providing the following information:
- App Name
- Redirect URL
After the app is successfully registered, you should create the AppKey and secret_key pair. These keys will be unique to the app registered. The AppKey is the identity of the app for the API system and secret_key is used to encrypt messages sent to the API system by the client system.
All requests must contain:
- App Key
- Secret Key
- Session Token
- Checksum
- Timestamp
Checksum Computation
- Checksum is computed via SHA256 hash (Time Stamp + JSON Post Data + secret_key)
- All JSON Data should be stringified before sending it to the I-Direct system.
Login
Navigate to the Breeze API Login with your URL-encoded AppKey to initiate the login flow. https://api.icicidirect.com/apiuser/login?api_key=AppKey
YouTube Link: https://youtu.be/BE877n6TURM?si=1wrcnpxUe7S_a101
Upon successful login you will have an API_Session in the address bar. Use this API_Session value against key named SessionToken in the CustomerDetails API to obtain a session_token value, which is then used as SessionToken for signing all subsequent requests.
Request Headers
Key | Value | Description |
---|---|---|
X-Checksum | -- | Token followed by combination of ((ISO8601 UTC DateTime Format with 0 milliseconds) + JSONPostData + secret_key ) |
X-Timestamp | 2024-06-01T10:23:56.000Z | ISO8601 UTC DateTime Format with 0 milliseconds |
X-AppKey | -- | AppKey which is received during registration |
X-SessionToken | -- | SessionToken value is received in CustomerDetails API |
Errors
Exceptions and Errors
The API server generates name of the exception for error responses. While writing your code, you can raise corresponding exceptions after defining them in your language/library. The table below shows the list of exceptions and common error codes.
Error Code | Error Type |
---|---|
400 | Bad Request |
401 | Unauthorized |
403 | Forbidden |
404 | Non Found |
408 | Request Timeout |
200 | OK |
Instruments
You can download the Security Master file for token mapping at your end here. It is generated/updated daily at 8:00 AM.
CustomerDetails
CustomerDetails
var axios = require('axios');
var data = JSON.stringify({
"SessionToken": "58593",
"AppKey": "8g791^N029R47I831B8153=^O2f#7u8g"
});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/customerdetails',
headers: {
'Content-Type': 'application/json'
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
payload = json.dumps({
"SessionToken": "Your Session_token goes here",
"AppKey": "Your App_Key goes here"
})
headers = {
'Content-Type': 'application/json',
}
response = requests.request("GET", url, headers=headers, data=payload)
data = json.loads(response.text)
print(data)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/customerdetails")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/customerdetails");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
var body = @"{
" + "\n" +
@" ""SessionToken"": ""58593"",
" + "\n" +
@" ""AppKey"": ""8g791^N029R47I831B8153=^O2f#7u8g""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success':
{'exg_trade_date': {'NSE': '04-Feb-2025',
'BSE': '04-Feb-2025',
'FNO': '04-Feb-2025',
'NDX': '04-Feb-2025'},
'exg_status': {'NSE': 'C', 'BSE': 'C', 'FNO': 'Y', 'NDX': 'C'},
'segments_allowed': {'Trading': 'Y',
'Equity': 'Y',
'Derivatives': 'Y',
'Currency': 'N'},
'idirect_userid': 'XY123456',
'idirect_user_name': 'John Smith',
'idirect_ORD_TYP': 'N',
'idirect_lastlogin_time': '04-Feb-2025 08:52:03',
'mf_holding_mode_popup_flg': 'N',
'commodity_exchange_status': 'N',
'commodity_trade_date': '04-Feb-2025',
'commodity_allowed': 'C'},
'Status': 200,
'Error': None
}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/customerdetails |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
SessionToken | String | SessionKey is received after logging into the breeze website | Yes |
AppKey | String | AppKey is received during registration | Yes |
DematHoldings
GetDematHoldings
var axios = require('axios');
var data = JSON.stringify({});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/dematholdings',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/dematholdings"
payload = json.dumps({})
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/dematholdings")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/dematholdings");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success':
[{'stock_code': 'UNITEC',
'stock_ISIN': 'INE694A01020',
'quantity': '1',
'demat_total_bulk_quantity': '1',
'demat_avail_quantity': '0',
'blocked_quantity': '0',
'demat_allocated_quantity': '1'
}],
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/dematholdings |
Body Parameters
Note: Demat Holdings API does not require body parameters
Funds
GetFunds
var axios = require('axios');
var data = JSON.stringify({});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/funds',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/funds"
payload = json.dumps({})
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/funds")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/funds");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success':
{'bank_account': '123456789012',
'total_bank_balance': 800000000.0,
'allocated_equity': 200000000.0,
'allocated_fno': 200000000.0,
'allocated_commodity': 200000000.0,
'allocated_currency': 200000000.0,
'block_by_trade_equity': 0.0,
'block_by_trade_fno': 12500000.53,
'block_by_trade_commodity': 0.0,
'block_by_trade_currency': 0.0,
'block_by_trade_balance': 15500000,
'unallocated_balance': '87500000'},
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/funds |
Body Parameters
Note: Get Funds API does not require body parameters
SetFunds
var axios = require('axios');
var data = JSON.stringify({
"transaction_type": "Credit",
"amount": "10000",
"segment": "FNO"
});
var config = {
method: 'post',
url: 'https://api.icicidirect.com/breezeapi/api/v1/funds',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here",
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/funds"
payload = json.dumps({
"transaction_type": "credit",
"amount": "200",
"segment": "Equity"
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"transaction_type\": \"Credit\",\r\n \"amount\": \"10000\",\r\n \"segment\": \"FNO\"\r\n}");
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/funds")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/funds");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""transaction_type"": ""Credit"",
" + "\n" +
@" ""amount"": ""10000"",
" + "\n" +
@" ""segment"": ""FNO""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{
"Success": {
"status": "Success"
},
"Status": 200,
"Error": null
}
Request Information
Category | Value |
---|---|
HTTP Request | POST |
URL | https://api.icicidirect.com/breezeapi/api/v1/funds |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
transaction_type | String | "Debit", "Credit" | Yes |
amount | String | Numeric string of Currency | Yes |
segment | String | "Equity", "FNO" | Yes |
HistoricalCharts
GetHistoricalChartsList
var axios = require('axios');
var data = JSON.stringify({
"interval": "day",
"from_date": "2022-05-02T07:00:00.000Z",
"to_date": "2022-05-03T07:00:00.000Z",
"stock_code": "ITC",
"exchange_code": "NSE",
"product_type": "Cash"
});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/historicalcharts',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/historicalcharts"
payload = json.dumps({
"interval": "day",
"from_date": "2025-02-03T09:20:00.000Z",
"to_date": "2025-02-03T09:20:00.000Z",
"stock_code": "ITC",
"exchange_code": "NSE",
"product_type": "Cash"
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/historicalcharts")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/historicalcharts");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""interval"": ""day"",
" + "\n" +
@" ""from_date"": ""2022-05-02T07:00:00.000Z"",
" + "\n" +
@" ""to_date"": ""2022-05-03T07:00:00.000Z"",
" + "\n" +
@" ""stock_code"": ""ITC"",
" + "\n" +
@" ""exchange_code"": ""NSE"",
" + "\n" +
@" ""product_type"": ""Cash""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success': [
{'datetime': '2025-02-03 09:21:00',
'stock_code': 'RELIND',
'exchange_code': 'NSE',
'product_type': None,
'expiry_date': None,
'right': None,
'strike_price': None,
'open': '1249.85',
'high': '1250.75',
'low': '1248.95',
'close': '1249.95',
'volume': '1951',
'open_interest': None,
'count': 7},
{'datetime': '2025-02-03 09:22:00',
'stock_code': 'RELIND',
'exchange_code': 'NSE',
'product_type': None,
'expiry_date': None,
'right': None,
'strike_price': None,
'open': '1249.75',
'high': '1250.5',
'low': '1247.95',
'close': '1249',
'volume': '1810',
'open_interest': None,
'count': 8}],
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/historicalcharts |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
interval | String | "1minute","5minute","30minute","1day" | Yes |
from_date | String | ISO 8601 | Yes |
to_date | String | ISO 8601 | Yes |
stock_code | String | "AXIBAN", "TATMOT" | Yes |
exchange_code | String | "NSE", "NFO" | Yes |
product_type | String | "futures","options","optionplus","cash","btst","margin" | Yes |
expiry_date | String | ISO 8601 | Yes |
right | String | "call","put","others" | Yes |
strike_price | String | Numeric String of Currency | Yes |
Note: For product_type cash,btst and margin; the expiry_date, right and strike_price are optional.
Margin Calculator
margin calculator
var axios = require('axios');
var data = JSON.stringify({
"list_of_positions": [
{
"strike_price": "0",
"quantity": "15",
"right": "others",
"product": "futures",
"action": "buy",
"price": "46230.85",
"expiry_date": "31-Aug-2023",
"stock_code": "CNXBAN",
"cover_order_flow": "N",
"fresh_order_type": "N",
"cover_limit_rate": "0",
"cover_sltp_price": "0",
"fresh_limit_rate": "0",
"open_quantity": "0"
},
{
"strike_price": "37000",
"quantity": "15",
"right": "Call",
"product": "options",
"action": "buy",
"price": "9100",
"expiry_date": "27-Jul-2023",
"stock_code": "CNXBAN",
"cover_order_flow": "N",
"fresh_order_type": "N",
"cover_limit_rate": "0",
"cover_sltp_price": "0",
"fresh_limit_rate": "0",
"open_quantity": "0"
},
{
"strike_price": "0",
"quantity": "50",
"right": "others",
"product": "futureplus",
"action": "buy",
"price": "19800",
"expiry_date": "27-Jul-2023",
"stock_code": "NIFTY",
"cover_order_flow": "N",
"fresh_order_type": "N",
"cover_limit_rate": "0",
"cover_sltp_price": "0",
"fresh_limit_rate": "0",
"open_quantity": "0"
},
{
"strike_price": "19600",
"quantity": "50",
"right": "call",
"product": "optionplus",
"action": "buy",
"price": "245.05",
"expiry_date": "27-Jul-2023",
"stock_code": "NIFTY",
"cover_order_flow": "sell",
"fresh_order_type": "limit",
"cover_limit_rate": "180.00",
"cover_sltp_price": "200.00",
"fresh_limit_rate": "245.05",
"open_quantity": "50"
}
],
"exchange_code": "NFO"
});
var config = {
method: 'post',
url: 'https://api.icicidirect.com/breezeapi/api/v1/margincalculator',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/margincalculator"
payload = json.dumps({
"list_of_positions":[{
"strike_price": "0",
"quantity": "30",
"right": "others",
"product": "futures",
"action": "buy",
"price": "49500",
"expiry_date": "27-Feb-2025",
"stock_code": "CNXBAN",
"cover_order_flow": "N",
"fresh_order_type": "N",
"cover_limit_rate": "0",
"cover_sltp_price": "0",
"fresh_limit_rate": "0",
"open_quantity": "0"
},
{
"strike_price": "50000",
"quantity": "30",
"right": "Call",
"product": "options",
"action": "buy",
"price": "1150",
"expiry_date": "27-Feb-2025",
"stock_code": "CNXBAN",
"cover_order_flow": "N",
"fresh_order_type": "N",
"cover_limit_rate": "0",
"cover_sltp_price": "0",
"fresh_limit_rate": "0",
"open_quantity": "0"
},
{
"strike_price": "0",
"quantity": "75",
"right": "others",
"product": "futures",
"action": "buy",
"price": "23400",
"expiry_date": "27-Feb-2025",
"stock_code": "NIFTY",
"cover_order_flow": "N",
"fresh_order_type": "N",
"cover_limit_rate": "0",
"cover_sltp_price": "0",
"fresh_limit_rate": "0",
"open_quantity": "0"
},
{
"strike_price": "23400",
"quantity": "75",
"right": "call",
"product": "options",
"action": "buy",
"price": "577",
"expiry_date": "27-Feb-2025",
"stock_code": "NIFTY",
"cover_order_flow": "sell",
"fresh_order_type": "limit",
"cover_limit_rate": "0",
"cover_sltp_price": "0",
"fresh_limit_rate": "0",
"open_quantity": "0"
}],
"exchange_code": "NFO"
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"list_of_positions\": [\r\n {\r\n \"strike_price\": \"0\",\r\n \"quantity\": \"15\",\r\n \"right\": \"others\",\r\n \"product\": \"futures\",\r\n \"action\": \"buy\",\r\n \"price\": \"46230.85\",\r\n \"expiry_date\": \"31-Aug-2023\",\r\n \"stock_code\": \"CNXBAN\",\r\n \"cover_order_flow\": \"N\",\r\n \"fresh_order_type\": \"N\",\r\n \"cover_limit_rate\": \"0\",\r\n \"cover_sltp_price\": \"0\",\r\n \"fresh_limit_rate\": \"0\",\r\n \"open_quantity\": \"0\"\r\n },\r\n {\r\n \"strike_price\": \"37000\",\r\n \"quantity\": \"15\",\r\n \"right\": \"Call\",\r\n \"product\": \"options\",\r\n \"action\": \"buy\",\r\n \"price\": \"9100\",\r\n \"expiry_date\": \"27-Jul-2023\",\r\n \"stock_code\": \"CNXBAN\",\r\n \"cover_order_flow\": \"N\",\r\n \"fresh_order_type\": \"N\",\r\n \"cover_limit_rate\": \"0\",\r\n \"cover_sltp_price\": \"0\",\r\n \"fresh_limit_rate\": \"0\",\r\n \"open_quantity\": \"0\"\r\n },\r\n {\r\n \"strike_price\": \"0\",\r\n \"quantity\": \"50\",\r\n \"right\": \"others\",\r\n \"product\": \"futureplus\",\r\n \"action\": \"buy\",\r\n \"price\": \"19800\",\r\n \"expiry_date\": \"27-Jul-2023\",\r\n \"stock_code\": \"NIFTY\",\r\n \"cover_order_flow\": \"N\",\r\n \"fresh_order_type\": \"N\",\r\n \"cover_limit_rate\": \"0\",\r\n \"cover_sltp_price\": \"0\",\r\n \"fresh_limit_rate\": \"0\",\r\n \"open_quantity\": \"0\"\r\n },\r\n {\r\n \"strike_price\": \"19600\",\r\n \"quantity\": \"50\",\r\n \"right\": \"call\",\r\n \"product\": \"optionplus\",\r\n \"action\": \"buy\",\r\n \"price\": \"245.05\",\r\n \"expiry_date\": \"27-Jul-2023\",\r\n \"stock_code\": \"NIFTY\",\r\n \"cover_order_flow\": \"sell\",\r\n \"fresh_order_type\": \"limit\",\r\n \"cover_limit_rate\": \"180.00\",\r\n \"cover_sltp_price\": \"200.00\",\r\n \"fresh_limit_rate\": \"245.05\",\r\n \"open_quantity\": \"50\"\r\n }\r\n ],\r\n \"exchange_code\": \"NFO\"\r\n}");
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/margincalculator")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/margincalculator");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""list_of_positions"": [
" + "\n" +
@" {
" + "\n" +
@" ""strike_price"": ""0"",
" + "\n" +
@" ""quantity"": ""15"",
" + "\n" +
@" ""right"": ""others"",
" + "\n" +
@" ""product"": ""futures"",
" + "\n" +
@" ""action"": ""buy"",
" + "\n" +
@" ""price"": ""46230.85"",
" + "\n" +
@" ""expiry_date"": ""31-Aug-2023"",
" + "\n" +
@" ""stock_code"": ""CNXBAN"",
" + "\n" +
@" ""cover_order_flow"": ""N"",
" + "\n" +
@" ""fresh_order_type"": ""N"",
" + "\n" +
@" ""cover_limit_rate"": ""0"",
" + "\n" +
@" ""cover_sltp_price"": ""0"",
" + "\n" +
@" ""fresh_limit_rate"": ""0"",
" + "\n" +
@" ""open_quantity"": ""0""
" + "\n" +
@" },
" + "\n" +
@" {
" + "\n" +
@" ""strike_price"": ""37000"",
" + "\n" +
@" ""quantity"": ""15"",
" + "\n" +
@" ""right"": ""Call"",
" + "\n" +
@" ""product"": ""options"",
" + "\n" +
@" ""action"": ""buy"",
" + "\n" +
@" ""price"": ""9100"",
" + "\n" +
@" ""expiry_date"": ""27-Jul-2023"",
" + "\n" +
@" ""stock_code"": ""CNXBAN"",
" + "\n" +
@" ""cover_order_flow"": ""N"",
" + "\n" +
@" ""fresh_order_type"": ""N"",
" + "\n" +
@" ""cover_limit_rate"": ""0"",
" + "\n" +
@" ""cover_sltp_price"": ""0"",
" + "\n" +
@" ""fresh_limit_rate"": ""0"",
" + "\n" +
@" ""open_quantity"": ""0""
" + "\n" +
@" },
" + "\n" +
@" {
" + "\n" +
@" ""strike_price"": ""0"",
" + "\n" +
@" ""quantity"": ""50"",
" + "\n" +
@" ""right"": ""others"",
" + "\n" +
@" ""product"": ""futureplus"",
" + "\n" +
@" ""action"": ""buy"",
" + "\n" +
@" ""price"": ""19800"",
" + "\n" +
@" ""expiry_date"": ""27-Jul-2023"",
" + "\n" +
@" ""stock_code"": ""NIFTY"",
" + "\n" +
@" ""cover_order_flow"": ""N"",
" + "\n" +
@" ""fresh_order_type"": ""N"",
" + "\n" +
@" ""cover_limit_rate"": ""0"",
" + "\n" +
@" ""cover_sltp_price"": ""0"",
" + "\n" +
@" ""fresh_limit_rate"": ""0"",
" + "\n" +
@" ""open_quantity"": ""0""
" + "\n" +
@" },
" + "\n" +
@" {
" + "\n" +
@" ""strike_price"": ""19600"",
" + "\n" +
@" ""quantity"": ""50"",
" + "\n" +
@" ""right"": ""call"",
" + "\n" +
@" ""product"": ""optionplus"",
" + "\n" +
@" ""action"": ""buy"",
" + "\n" +
@" ""price"": ""245.05"",
" + "\n" +
@" ""expiry_date"": ""27-Jul-2023"",
" + "\n" +
@" ""stock_code"": ""NIFTY"",
" + "\n" +
@" ""cover_order_flow"": ""sell"",
" + "\n" +
@" ""fresh_order_type"": ""limit"",
" + "\n" +
@" ""cover_limit_rate"": ""180.00"",
" + "\n" +
@" ""cover_sltp_price"": ""200.00"",
" + "\n" +
@" ""fresh_limit_rate"": ""245.05"",
" + "\n" +
@" ""open_quantity"": ""50""
" + "\n" +
@" }
" + "\n" +
@" ],
" + "\n" +
@" ""exchange_code"": ""NFO""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success': {'margin_calulation': [{'strike_price': '0',
'quantity': '30',
'right': 'Others',
'product': 'Futures',
'action': 'Buy',
'price': '49500',
'expiry_date': '27-Feb-2025',
'stock_code': 'CNXBAN'},
{'strike_price': '50000',
'quantity': '30',
'right': 'Call',
'product': 'Options',
'action': 'Buy',
'price': '1150',
'expiry_date': '27-Feb-2025',
'stock_code': 'CNXBAN'},
{'strike_price': '0',
'quantity': '75',
'right': 'Others',
'product': 'Futures',
'action': 'Buy',
'price': '23400',
'expiry_date': '27-Feb-2025',
'stock_code': 'NIFTY '},
{'strike_price': '23400',
'quantity': '75',
'right': 'Call',
'product': 'Options',
'action': 'Buy',
'price': '577',
'expiry_date': '27-Feb-2025',
'stock_code': 'NIFTY '}],
'non_span_margin_required': '0',
'order_value': '493011.26',
'order_margin': '0',
'trade_margin': None,
'block_trade_margin': '0',
'span_margin_required': '493011.26'},
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | POST |
URL | https://api.icicidirect.com/breezeapi/api/v1/margincalculator |
Body Parameters
Parameter | Data Type | Description |
---|---|---|
strike_price | String | Numeric String of Currency |
Quantity | String | Number of quantity to place the order |
right | String | "call","put","others" |
product | String | "options","futures" |
action | String | "buy","sell" |
price | String | Numeric Currency |
expiry_date | String | ISO 8601 |
stock_code | String | "NIFTY","CNXBAN" |
Margin
GetMargins
var axios = require('axios');
var data = JSON.stringify({
"exchange_code": "NSE"
});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/margin',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/margin"
payload = json.dumps({
"exchange_code": "NSE"
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/margin")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/margin");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""exchange_code"": ""NSE""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success': {'limit_list': [],
'cash_limit': 1000000.00,
'amount_allocated': 100000.00,
'block_by_trade': 0.0,
'isec_margin': 0.0},
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/margin |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
exchange_code | String | "NSE", "NFO" | Yes |
Order
OrderPlacement
var axios = require('axios');
var data = JSON.stringify({
"stock_code": "ITC",
"exchange_code": "NSE",
"product": "cash",
"action": "buy",
"order_type": "market",
"quantity": "1",
"price": "263.15",
"validity": "ioc"
});
var config = {
method: 'post',
url: 'https://api.icicidirect.com/breezeapi/api/v1/order',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/order"
payload = json.dumps({
"stock_code": "NIFTY",
"exchange_code": "NFO",
"product": "options",
"action": "buy",
"order_type": "limit",
"quantity": "25",
"price": "1",
"validity": "day",
"stoploss": "",
"validity_date": "2024-07-23T06:00:00.000Z",
"disclosed_quantity": "0",
"expiry_date": "2024-09-12T06:00:00.000Z",
"right": "call",
"strike_price": "25000",
"user_remark": "testing"
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"stock_code\": \"ITC\",\r\n \"exchange_code\": \"NSE\",\r\n \"product\": \"cash\",\r\n \"action\": \"buy\",\r\n \"order_type\": \"market\",\r\n \"quantity\": \"1\",\r\n \"price\": \"263.15\",\r\n \"validity\": \"ioc\"\r\n}");
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/order")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/order");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""stock_code"": ""ITC"",
" + "\n" +
@" ""exchange_code"": ""NSE"",
" + "\n" +
@" ""product"": ""cash"",
" + "\n" +
@" ""action"": ""buy"",
" + "\n" +
@" ""order_type"": ""market"",
" + "\n" +
@" ""quantity"": ""1"",
" + "\n" +
@" ""price"": ""263.15"",
" + "\n" +
@" ""validity"": ""ioc""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success':
{'order_id': '202502051400001234',
'message': 'Successfully Placed the order',
'user_remark': ''},
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | POST |
URL | https://api.icicidirect.com/breezeapi/api/v1/order |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
stock_code | String | "AXIBAN", "TATMOT" | Yes |
exchange_code | String | "NSE", "NFO" | Yes |
product | String | "futures","options","optionplus","cash","btst","margin" | Yes |
action | String | "buy", "sell" | Yes |
order_type | String | "limit","market","stoploss" | Yes |
stoploss | Double | Numeric Currency | No |
quantity | String | Number of quantity to place the order | Yes |
price | String | Numeric Currency | Yes |
validity | String | "day","ioc" | No |
validity_date | String | ISO 8601 | No |
disclosed_quantity | String | Number of quantity to be disclosed | No |
expiry_date | String | ISO 8601 | Yes |
right | String | "call","put","others" | Yes |
strike_price | String | Numeric Currency | Yes |
user_remark | String | Users are free to add their comment/tag to the order | No |
Note: For user_remark, no space and special character are allowed
GetOrderDetail
var axios = require('axios');
var data = JSON.stringify({
"exchange_code": "NSE",
"order_id": "20220601N100000019"
});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/order',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/order"
payload = json.dumps({
"exchange_code": "NFO",
"order_id": "20250205N300001234"
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/order")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/order");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""exchange_code"": ""NSE"",
" + "\n" +
@" ""order_id"": ""20220601N100000019""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success': [
{'order_id': '20250205N300001234',
'exchange_order_id': None,
'exchange_code': 'NSE',
'stock_code': 'ITC',
'product_type': 'Cash',
'action': 'Buy',
'order_type': 'Limit',
'stoploss': '0.00',
'quantity': '1',
'price': '420.00',
'validity': 'Day',
'disclosed_quantity': '0',
'expiry_date': None,
'right': None,
'strike_price': 0.0,
'average_price': '0',
'cancelled_quantity': '0',
'pending_quantity': '1',
'status': 'Ordered',
'user_remark': '',
'order_datetime': '05-Feb-2025 09:26',
'parent_order_id': None,
'modification_number': None,
'exchange_acknowledgement_date': None,
'SLTP_price': None,
'exchange_acknowledge_number': None,
'initial_limit': None,
'intial_sltp': None,
'LTP': None,
'limit_offset': None,
'mbc_flag': None,
'cutoff_price': None,
'validity_date': ''}],
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/order |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
exchange_code | String | "NSE", "NFO" | Yes |
order_id | String | Order ID recieved during order placement | Yes |
GetOrderList
var axios = require('axios');
var data = JSON.stringify({
"exchange_code": "NSE",
"from_date": "2022-05-29T10:00:00.000Z",
"to_date": "2022-05-31T10:00:00.000Z"
});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/order',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/order"
payload = json.dumps({
"exchange_code": "NSE",
"from_date": "2025-02-28T10:00:00.000Z",
"to_date": "2025-03-04T10:00:00.000Z"
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/order")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/order");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""exchange_code"": ""NSE"",
" + "\n" +
@" ""from_date"": ""2022-05-29T10:00:00.000Z"",
" + "\n" +
@" ""to_date"": ""2022-05-31T10:00:00.000Z""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success': [
{'order_id': '20250205N300001234',
'exchange_order_id': None,
'exchange_code': 'NSE',
'stock_code': 'ITC',
'product_type': 'Cash',
'action': 'Buy',
'order_type': 'Limit',
'stoploss': '0.00',
'quantity': '1',
'price': '420.00',
'validity': 'Day',
'disclosed_quantity': '0',
'expiry_date': None,
'right': None,
'strike_price': 0.0,
'average_price': '0',
'cancelled_quantity': '0',
'pending_quantity': '1',
'status': 'Ordered',
'user_remark': '',
'order_datetime': '05-Feb-2025 09:26',
'parent_order_id': None,
'modification_number': None,
'exchange_acknowledgement_date': None,
'SLTP_price': None,
'exchange_acknowledge_number': None,
'initial_limit': None,
'intial_sltp': None,
'LTP': None,
'limit_offset': None,
'mbc_flag': None,
'cutoff_price': None,
'validity_date': ''}],
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/order |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
exchange_code | String | "NSE", "NFO" | Yes |
from_date | String | ISO 8601 - Day should not be less than 10 days from to_date | Yes |
to_date | String | ISO 8601 - Day should not be more than 10 days from from_date | Yes |
OrderCancellation
var axios = require('axios');
var data = JSON.stringify({
"order_id": "20220601N100000019",
"exchange_code": "NSE"
});
var config = {
method: 'delete',
url: 'https://api.icicidirect.com/breezeapi/api/v1/order',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/order"
payload = json.dumps({
"order_id": "202409062500014529",
"exchange_code": "NFO"
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("DELETE", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"order_id\": \"20220601N100000019\",\r\n \"exchange_code\": \"NSE\"\r\n}");
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/order")
.method("DELETE", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/order");
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""order_id"": ""20220601N100000019"",
" + "\n" +
@" ""exchange_code"": ""NSE""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success':
{'order_id': '20250205N300001234',
'message': 'Your Order Canceled successfully.'},
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | DELETE |
URL | https://api.icicidirect.com/breezeapi/api/v1/order |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
order_id | String | Order ID recieved during order placement | Yes |
exchange_code | String | "NSE", "NFO" | Yes |
OrderModification
var axios = require('axios');
var data = JSON.stringify({
"order_id": "20220601N100000019",
"exchange_code": "NSE",
"quantity": "2",
"price": "263.15",
"stoploss": "",
"disclosed_quantity": "",
"order_type": "limit",
"validity": "",
"expiry_date": "",
"right": "",
"strike_price": ""
});
var config = {
method: 'put',
url: 'https://api.icicidirect.com/breezeapi/api/v1/order',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/order"
payload = json.dumps({
"order_id": "202502051400012345",
"exchange_code": "NFO",
"quantity": "25",
"price": "1",
"stoploss": "",
"disclosed_quantity": "0",
"order_type": "limit",
"validity": "day",
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"order_id\":\"20220601N100000019\",\r\n \"exchange_code\":\"NSE\",\r\n \"quantity\": \"2\",\r\n \"price\": \"263.15\",\r\n \"stoploss\":\"\",\r\n \"disclosed_quantity\":\"\",\r\n \"order_type\":\"limit\",\r\n \"validity\":\"\",\r\n \"expiry_date\":\"\",\r\n \"right\":\"\",\r\n \"strike_price\":\"\"\r\n}");
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/order")
.method("PUT", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/order");
client.Timeout = -1;
var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""order_id"":""20220601N100000019"",
" + "\n" +
@" ""exchange_code"":""NSE"",
" + "\n" +
@" ""quantity"": ""2"",
" + "\n" +
@" ""price"": ""263.15"",
" + "\n" +
@" ""stoploss"":"""",
" + "\n" +
@" ""disclosed_quantity"":"""",
" + "\n" +
@" ""order_type"":""limit"",
" + "\n" +
@" ""validity"":"""",
" + "\n" +
@" ""expiry_date"":"""",
" + "\n" +
@" ""right"":"""",
" + "\n" +
@" ""strike_price"":""""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success':
{'message': 'Successfully Modified the order',
'order_id': '202502051400012345'},
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | PUT |
URL | https://api.icicidirect.com/breezeapi/api/v1/order |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
order_id | String | Order ID recieved during order placement | Yes |
exchange_code | String | "NSE", "NFO" | Yes |
order_type | String | "limit","market","stoploss" | No |
stoploss | String | Numeric String of Currency | No |
quantity | String | Modify number of quantity on placed order | Yes |
price | String | Numeric String of Currency | No |
validity | String | "day","ioc" | No |
disclosed_quantity | String | Modify number of disclosed quantity on placed order | No |
expiry_date | String | ISO 8601 | Yes |
right | String | "call","put","others" | Yes |
strike_price | String | Numeric Currency | Yes |
Breeze Limit price calculation
limit calculator
var axios = require('axios');
var data = JSON.stringify({
"strike_price": "19200",
"product_type": "optionplus",
"expiry_date": "13-JUL-2023",
"underlying": "NIFTY",
"exchange_code": "NFO",
"order_flow": "Buy",
"stop_loss_trigger": "200.00",
"option_type": "Call",
"source_flag": "P",
"limit_rate": "",
"order_reference": "",
"available_quantity": "",
"market_type": "limit",
"fresh_order_limit": "218.65"
});
var config = {
method: 'post',
url: 'https://api.icicidirect.com/breezeapi/api/v1/fnolmtpriceandqtycal',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/fnolmtpriceandqtycal"
payload = json.dumps({
"strike_price": "22800",
"product_type": "optionplus",
"expiry_date": "20-Mar-2025",
"underlying": "NIFTY",
"exchange_code": "NFO",
"order_flow": "Buy",
"stop_loss_trigger": "0",
"option_type": "Put",
"source_flag": "P",
"limit_rate": "",
"order_reference": "",
"available_quantity": "75",
"market_type": "limit",
"fresh_order_limit": "85"
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \r\n \"strike_price\": \"19200\", \r\n \"product_type\":\"optionplus\", \r\n \"expiry_date\": \"13-JUL-2023\",\r\n \"underlying\" : \"NIFTY\",\r\n \"exchange_code\":\"NFO\",\r\n \"order_flow\" :\"Buy\",\r\n \"stop_loss_trigger\":\"200.00\",\r\n \"option_type\":\"Call\",\r\n \"source_flag\" : \"P\",\r\n \"limit_rate\" : \"\",\r\n \"order_reference\":\"\",\r\n \"available_quantity\":\"\",\r\n \"market_type\":\"limit\",\r\n \"fresh_order_limit\":\"218.65\"\r\n}");
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/fnolmtpriceandqtycal")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/fnolmtpriceandqtycal");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""strike_price"": ""19200"",
" + "\n" +
@" ""product_type"":""optionplus"",
" + "\n" +
@" ""expiry_date"": ""13-JUL-2023"",
" + "\n" +
@" ""underlying"" : ""NIFTY"",
" + "\n" +
@" ""exchange_code"":""NFO"",
" + "\n" +
@" ""order_flow"" :""Buy"",
" + "\n" +
@" ""stop_loss_trigger"":""200.00"",
" + "\n" +
@" ""option_type"":""Call"",
" + "\n" +
@" ""source_flag"" : ""P"",
" + "\n" +
@" ""limit_rate"" : """",
" + "\n" +
@" ""order_reference"":"""",
" + "\n" +
@" ""available_quantity"":"""",
" + "\n" +
@" ""market_type"":""limit"",
" + "\n" +
@" ""fresh_order_limit"":""218.65""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success':
{'available_quantity': '0',
'action_id': '0',
'order_margin': '0',
'limit_rate': '16'},
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | POST |
URL | https://api.icicidirect.com/breezeapi/api/v1/fnolmtpriceandqtycal |
Body Parameters
Parameter | Data Type | Description |
---|---|---|
strike_price | String | Numeric String of Currency |
product_type | String | "optionplus" |
expiry_date | String | ISO 8601 |
exchange_code | String | "NSE" |
stop_loss_trigger | String | Numeric Currency |
option_type | String | "call","put" |
order_reference | String | -- |
available_quantity | -- | -- |
market_type | String | "limit","market" |
fresh_order_limit | String | Numeric currency |
PortfolioHoldings
GetPortfolioHoldings
var axios = require('axios');
var data = JSON.stringify({
"exchange_code": "NSE",
"from_date": "",
"to_date": "",
"stock_code": "JKPAP",
"portfolio_type": ""
});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/portfolioholdings',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/portfolioholdings"
payload = json.dumps({
"exchange_code": "NSE",
"from_date": "2024-09-01T06:00:00.000Z",
"to_date": "2024-09-05T06:00:00.000Z",
"stock_code": "",
"portfolio_type": ""
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/portfolioholdings")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/portfolioholdings");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""exchange_code"":""NSE"",
" + "\n" +
@" ""from_date"":"""",
" + "\n" +
@" ""to_date"":"""",
" + "\n" +
@" ""stock_code"":""JKPAP"",
" + "\n" +
@" ""portfolio_type"":""""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success':[
{'stock_code': 'NIFTY',
'exchange_code': 'NFO',
'quantity': '0',
'average_price': '0',
'booked_profit_loss': None,
'current_market_price': '0',
'change_percentage': None,
'answer_flag': None,
'product_type': 'Options',
'expiry_date': '01-Aug-2024',
'strike_price': '25200',
'right': 'Call',
'category_index_per_stock':'I',
'action': 'NA',
'realized_profit': '-349.26',
'unrealized_profit': '0',
'open_position_value': '0',
'portfolio_charges': '5.51'}],
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/portfolioholdings |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
exchange_code | String | "NSE", "NFO" | Yes |
from_date | String | ISO 8601 | Yes |
to_date | String | ISO 8601 | Yes |
stock_code | String | "AXIBAN", "TATMOT" | Yes |
portfolio_type | String | -- | No |
PortfolioPositions
GetPortfolioPositions
var axios = require('axios');
var data = JSON.stringify({});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/portfoliopositions',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/portfoliopositions"
payload = json.dumps({})
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/portfoliopositions")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/portfoliopositions");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success': [{'segment': 'fno',
'product_type': 'Options',
'exchange_code': 'NFO',
'stock_code': 'NIFTY',
'expiry_date': '27-Feb-2025',
'strike_price': '24800',
'right': 'Call',
'action': 'NA',
'quantity': '0',
'average_price': '0',
'settlement_id': None,
'margin_amount': None,
'ltp': '29.95',
'price': '28.85',
'stock_index_indicator': 'Index',
'cover_quantity': '0',
'stoploss_trigger': '0',
'stoploss': None,
'take_profit': None,
'available_margin': None,
'squareoff_mode': None,
'mtf_sell_quantity': None,
'mtf_net_amount_payable': None,
'mtf_expiry_date': None,
'order_id': '',
'cover_order_flow': None,
'cover_order_executed_quantity': None,
'pledge_status': None,
'pnl': None,
'underlying': 'NIFTY',
'order_segment_code': None}],
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/portfoliopositions |
Body Parameters
Note: Get Portfolio Positions API does not require body parameters
Quotes
GetQuotes
var axios = require('axios');
var data = JSON.stringify({
"stock_code": "CNXBAN",
"exchange_code": "NFO",
"expiry_date": "2022-05-26T06:00:00.000Z",
"product_type": "Futures",
"right": "Others",
"strike_price": "0"
});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/quotes',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/quotes"
payload = json.dumps({
"stock_code": "NIFTY",
"exchange_code": "NFO",
"expiry_date": "2025-03-06T06:00:00.000Z",
"product_type": "options",
"right": "call",
"strike_price": "22500"
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/quotes")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/quotes");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""stock_code"": ""CNXBAN"",
" + "\n" +
@" ""exchange_code"": ""NFO"",
" + "\n" +
@" ""expiry_date"": ""2022-05-26T06:00:00.000Z"",
" + "\n" +
@" ""product_type"": ""Futures"",
" + "\n" +
@" ""right"": ""Others"",
" + "\n" +
@" ""strike_price"": ""0""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success': [{'exchange_code': 'NFO',
'product_type': 'Future',
'stock_code': 'NIFTY',
'expiry_date': '27-Feb-2025',
'right': '*',
'strike_price': 0.0,
'ltp': 23832.85,
'ltt': '05-Feb-2025 09:36:56',
'best_bid_price': 23832.0,
'best_bid_quantity': '1500',
'best_offer_price': 23833.8,
'best_offer_quantity': '150',
'open': 23825.0,
'high': 23840.6,
'low': 23808.0,
'previous_close': 23785.4,
'ltp_percent_change': 0.2,
'upper_circuit': 26163.95,
'lower_circuit': 21406.9,
'total_quantity_traded': '623325',
'spot_price': '23783.7'}],
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/quotes |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
stock_code | String | "AXIBAN","TATMOT" | Yes |
exchange_code | String | "NSE","NFO" | Yes |
expiry_date | String | ISO 8601 | Yes |
product_type | String | "futures","options","optionplus","cash","btst","margin" | Yes |
right | String | "call","put","others" | Yes |
strike_price | String | Numeric String of Currency | Yes |
SquareOff
SquareOff
var axios = require('axios');
var data = JSON.stringify({
"source_flag": "",
"stock_code": "NIFTY",
"exchange_code": "NFO",
"quantity": "50",
"price": "0",
"action": "Sell",
"order_type": "Market",
"validity": "Day",
"stoploss_price": "0",
"disclosed_quantity": "0",
"protection_percentage": "",
"settlement_id": "",
"margin_amount": "",
"open_quantity": "",
"cover_quantity": "",
"product_type": "Futures",
"expiry_date": "2021-12-30",
"right": "Others",
"strike_price": "0",
"validity_date": "2021-12-16T06:00:00.000Z",
"alias_name": "",
"trade_password": ""
});
var config = {
method: 'post',
url: 'https://api.icicidirect.com/breezeapi/api/v1/squareoff',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/squareoff"
payload = json.dumps({
"stock_code": "NIFTY",
"exchange_code": "NFO",
"quantity": "25",
"price": "1",
"action": "sell",
"order_type": "limit",
"order_rate": "",
"validity": "day",
"disclosed_quantity": "0",
"product_type": "options",
"expiry_date": "2024-09-12T06:00:00.000Z",
"right": "put",
"strike_price": "25000",
"validity_date": "2024-07-23T06:00:00.000Z",
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"source_flag\": \"\",\r\n \"stock_code\": \"NIFTY\",\r\n \"exchange_code\": \"NFO\",\r\n \"quantity\": \"50\",\r\n \"price\": \"0\",\r\n \"action\": \"Sell\",\r\n \"order_type\": \"Market\",\r\n \"validity\": \"Day\",\r\n \"stoploss_price\": \"0\",\r\n \"disclosed_quantity\": \"0\",\r\n \"protection_percentage\": \"\",\r\n \"settlement_id\": \"\",\r\n \"margin_amount\": \"\",\r\n \"open_quantity\": \"\",\r\n \"cover_quantity\": \"\",\r\n \"product_type\": \"Futures\",\r\n \"expiry_date\": \"2021-12-30\",\r\n \"right\": \"Others\",\r\n \"strike_price\": \"0\",\r\n \"validity_date\": \"2021-12-16T06:00:00.000Z\",\r\n \"alias_name\": \"\",\r\n \"trade_password\": \"\"\r\n}");
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/squareoff")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/squareoff");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""source_flag"": """",
" + "\n" +
@" ""stock_code"": ""NIFTY"",
" + "\n" +
@" ""exchange_code"": ""NFO"",
" + "\n" +
@" ""quantity"": ""50"",
" + "\n" +
@" ""price"": ""0"",
" + "\n" +
@" ""action"": ""Sell"",
" + "\n" +
@" ""order_type"": ""Market"",
" + "\n" +
@" ""validity"": ""Day"",
" + "\n" +
@" ""stoploss_price"": ""0"",
" + "\n" +
@" ""disclosed_quantity"": ""0"",
" + "\n" +
@" ""protection_percentage"": """",
" + "\n" +
@" ""settlement_id"": """",
" + "\n" +
@" ""margin_amount"": """",
" + "\n" +
@" ""open_quantity"": """",
" + "\n" +
@" ""cover_quantity"": """",
" + "\n" +
@" ""product_type"": ""Futures"",
" + "\n" +
@" ""expiry_date"": ""2021-12-30"",
" + "\n" +
@" ""right"": ""Others"",
" + "\n" +
@" ""strike_price"": ""0"",
" + "\n" +
@" ""validity_date"": ""2021-12-16T06:00:00.000Z"",
" + "\n" +
@" ""alias_name"": """",
" + "\n" +
@" ""trade_password"": """"
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success': {'order_id': '202502052500001234',
'message': 'Successfully Placed the order',
'indicator': '0'},
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | POST |
URL | https://api.icicidirect.com/breezeapi/api/v1/squareoff |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
source_flag | String | -- | No |
stock_code | String | "NIFTY" | Yes |
exchange_code | String | "NSE","NFO","BSE" | Yes |
quantity | String | Number of quantity to sqaure off the orders | Yes |
price | String | Numeric String of Currency | No |
action | String | "buy","sell" | Yes |
order_type | String | "limit","market","stoploss" | No |
validity | String | "day","ioc" | No |
stoploss_price | String | Numeric String of Currency | No |
disclosed_quantity | String | Number of disclosed quantity to squareoff order | No |
protection_percentage | String | -- | No |
settlement_id | String | Numeric String of Currency | No |
margin_amount | String | Numeric String of Currency | No |
open_quantity | String | Number of open quantity to squareoff order | No |
cover_quantity | String | Number of cover quantity to squareoff order | No |
product_type | String | "futures","options","cash","eatm","margin" | No |
expiry_date | String | Date when squareoff order will be expired | Yes |
right | String | "call","put","others" | Yes |
strike_price | String | Numeric String of Currency | Yes |
validity_date | String | Validity date of squareoff order | No |
alias_name | -- | -- | |
trade_password | String | -- | No |
Trades
GetTradeList
var axios = require('axios');
var data = JSON.stringify({
"from_date": "2022-05-28T06:00:00.000Z",
"to_date": "2022-06-01T06:00:00.000Z",
"exchange_code": "NSE",
"product_type": "",
"action": "",
"stock_code": ""
});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/trades',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/trades"
payload = json.dumps({
"from_date": "2025-02-05T06:00:00.000Z",
"to_date": "2025-02-05T06:00:00.000Z",
"exchange_code": "NSE",
"product_type": "",
"action": "",
"stock_code": ""
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/trades")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/trades");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""from_date"": ""2022-05-28T06:00:00.000Z"",
" + "\n" +
@" ""to_date"": ""2022-06-01T06:00:00.000Z"",
" + "\n" +
@" ""exchange_code"": ""NSE"",
" + "\n" +
@" ""product_type"": """",
" + "\n" +
@" ""action"": """",
" + "\n" +
@" ""stock_code"": """"
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success': [{'book_type': 'Trade-Book',
'trade_date': '05-Feb-2025',
'stock_code': 'ITC',
'action': 'Buy',
'quantity': '1',
'average_cost': '452.20',
'brokerage_amount': '0.00',
'product_type': 'Margin',
'exchange_code': 'NSE',
'order_id': '20250205N300012345',
'segment': 'M',
'settlement_code': '2025027',
'dp_id': 'IN1234566',
'client_id': '12345678',
'ltp': '451.95',
'eatm_withheld_amount': '0.00',
'cash_withheld_amount': '0.00',
'total_taxes': '0.00',
'order_type': 'Market',
'expiry_date': None,
'right': None,
'strike_price': None},
{'book_type': 'Trade-Book',
'trade_date': '05-Feb-2025',
'stock_code': 'ITC',
'action': 'Sell',
'quantity': '1',
'average_cost': '452.55',
'brokerage_amount': '0.00',
'product_type': 'Margin',
'exchange_code': 'NSE',
'order_id': '20250205N300012345',
'segment': 'M',
'settlement_code': '2025012',
'dp_id': 'IN1234566',
'client_id': '12345678',
'ltp': '451.95',
'eatm_withheld_amount': '0.00',
'cash_withheld_amount': '0.00',
'total_taxes': '0.00',
'order_type': 'Market',
'expiry_date': None,
'right': None,
'strike_price': None}],
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/trades |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
from_date | String | ISO 8601 | Yes |
to_date | String | ISO 8601 | Yes |
exchange_code | String | "NSE","NFO" | Yes |
product_type | String | "futures","options","optionplus","cash","btst","margin" | Yes |
action | String | "buy","sell" | Yes |
stock_code | String | "AXIBAN","TATMOT" | Yes |
GetTradeDetail
var axios = require('axios');
var data = JSON.stringify({
"exchange_code": "NSE",
"order_id": "20210928N100000067"
});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/trades',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/trades"
payload = json.dumps({
"exchange_code": "NSE",
"order_id": "20250205N300012345"
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/trades")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/trades");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""exchange_code"": ""NSE"",
" + "\n" +
@" ""order_id"": ""20210928N100000067""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success': [{'settlement_id': '1234567',
'exchange_trade_id': '123456789',
'executed_quantity': '1',
'action': 'B',
'total_transaction_cost': '0',
'brokerage_amount': '0',
'taxes': '0',
'eatm_withheld_amount': '0',
'cash_withheld_amount': '0',
'execution_price': '452.2',
'stock_code': 'ITC',
'exchange_code': 'NSE',
'trade_id': '2025/1234/12345678',
'exchange_trade_time': '05-Feb-2025 10:41:24'}],
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/trades |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
exchange_code | String | "NSE","NFO" | Yes |
order_id | String | Order ID recieved during order placement | Yes |
OptionChain
GetOptionChain
var axios = require('axios');
var data = JSON.stringify({
"stock_code": "NIFTY",
"exchange_code": "NFO",
"expiry_date": "2022-08-25T06:00:00.000Z",
"product_type": "Futures",
"right": "",
"strike_price": ""
});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/OptionChain',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/optionchain"
payload = json.dumps({
"stock_code": "ICIBAN",
"exchange_code": "NFO",
"expiry_date": "2025-01-25T06:00:00.000Z",
"product_type": "futures",
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/OptionChain")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/OptionChain");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""stock_code"": ""NIFTY"",
" + "\n" +
@" ""exchange_code"": ""NFO"",
" + "\n" +
@" ""expiry_date"": ""2022-08-25T06:00:00.000Z"",
" + "\n" +
@" ""product_type"": ""Futures"",
" + "\n" +
@" ""right"": """",
" + "\n" +
@" ""strike_price"": """"
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON response
{'Success': [{'exchange_code': 'NFO',
'product_type': 'Options',
'stock_code': 'NIFTY',
'expiry_date': '06-Feb-2025',
'right': 'Call',
'strike_price': 17600.0,
'ltp': 0.0,
'ltt': '',
'best_bid_price': 0.0,
'best_bid_quantity': '0',
'best_offer_price': 0.0,
'best_offer_quantity': '0',
'open': 0.0,
'high': 0.0,
'low': 0.0,
'previous_close': 0.0,
'ltp_percent_change': 0.0,
'upper_circuit': 6750.4,
'lower_circuit': 5541.8,
'total_quantity_traded': '0',
'spot_price': '23787',
'ltq': '0',
'open_interest': 0.0,
'chnge_oi': 0.0,
'total_buy_qty': '0',
'total_sell_qty': '0'},
{'exchange_code': 'NFO',
'product_type': 'Options',
'stock_code': 'NIFTY',
'expiry_date': '06-Feb-2025',
'right': 'Call',
'strike_price': 17650.0,
'ltp': 0.0,
'ltt': '',
'best_bid_price': 0.0,
'best_bid_quantity': '0',
'best_offer_price': 0.0,
'best_offer_quantity': '0',
'open': 0.0,
'high': 0.0,
'low': 0.0,
'previous_close': 0.0,
'ltp_percent_change': 0.0,
'upper_circuit': 6700.45,
'lower_circuit': 5491.85,
'total_quantity_traded': '0',
'spot_price': '23787',
'ltq': '0',
'open_interest': 0.0,
'chnge_oi': 0.0,
'total_buy_qty': '0',
'total_sell_qty': '0'}],
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/OptionChain |
Body Parameters
Parameter | Data Type | Description |
---|---|---|
stock_code | String | NIFTY |
exchange_code | String | NFO |
expiry_date | String | 2024-12-15T06:00:00.000Z |
product_type | String | options |
right | String | "call","put" |
strike_price | String | 22500 |
Preview Order
GetBrokeragecharges - Equity
var axios = require('axios');
var data = JSON.stringify({
"stock_code": "ICIBAN",
"exchange_code": "NSE",
"product": "margin",
"order_type": "limit",
"price": "907.05",
"action": "buy",
"quantity": "1",
"specialflag": "N"
});
var config = {
method: 'get',
url: 'https://uatapi.icicidirect.com/iciciDirectWebApi_core/api/v1/preview_order',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/preview_order"
payload = json.dumps({
"stock_code": "ICIBAN",
"exchange_code": "NSE",
"product": "margin",
"order_type": "limit",
"price": "907.05",
"action": "buy",
"quantity": "1",
"specialflag": "N"}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://uatapi.icicidirect.com/iciciDirectWebApi_core/api/v1/preview_order")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://uatapi.icicidirect.com/iciciDirectWebApi_core/api/v1/preview_order");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""stock_code"": ""ICIBAN"",
" + "\n" +
@" ""exchange_code"": ""NSE"",
" + "\n" +
@" ""product"": ""margin"",
" + "\n" +
@" ""order_type"":""limit"",
" + "\n" +
@" ""price"":""907.05"",
" + "\n" +
@" ""action"":""buy"",
" + "\n" +
@" ""quantity"":""1"",
" + "\n" +
@" ""specialflag"" : ""N""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON response
{"Success":
{"brokerage":0.63,
"exchange_turnover_charges":0.03,
"stamp_duty":0.14,
"stt":0.91,
"sebi_charges":0.0,
"gst":0.12,
"total_turnover_and_sebi_charges":0.03,
"total_other_charges":1.19,
"total_brokerage":1.83),
"Status": 200, "Error":null}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/preview_order |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
stock_code | String | "NIFTY" | Yes |
exchange_code | String | "NSE" | Yes |
product | String | "futures","options","optionplus","cash","btst","margin" | Yes |
order_type | String | "limit","market","stoploss" | Yes |
price | String | Numeric String of Currency | Yes |
action | String | "buy","sell" | Yes |
quantity | String | Number of quantity in string formatted | Yes |
GetBrokeragecharges - Fno
var axios = require('axios');
var data = JSON.stringify({
"stock_code": "NIFTY",
"exchange_code": "NFO",
"product": "optionplus",
"order_type": "limit",
"price": "171",
"action": "buy",
"quantity": "50",
"expiry_date": "25-Jan-2023",
"right": "call",
"strike_price": "19000",
"specialflag": "S",
"stoploss": "190",
"order_rate_fresh": "195.50"
});
var config = {
method: 'get',
url: 'https://uatapi.icicidirect.com/iciciDirectWebApi_core/api/v1/preview_order',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import http.client
import json
conn = http.client.HTTPSConnection("uatapi.icicidirect.com")
payload = json.dumps({
"stock_code": "NIFTY",
"exchange_code": "NFO",
"product": "optionplus",
"order_type": "limit",
"price": "171",
"action": "buy",
"quantity": "50",
"expiry_date": "25-Jan-2023",
"right": "call",
"strike_price": "19000",
"specialflag": "S",
"stoploss": "190",
"order_rate_fresh": "195.50"
})
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
}
conn.request("GET", "/iciciDirectWebApi_core/api/v1/preview_order", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://uatapi.icicidirect.com/iciciDirectWebApi_core/api/v1/preview_order")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://uatapi.icicidirect.com/iciciDirectWebApi_core/api/v1/preview_order");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""stock_code"": ""NIFTY"",
" + "\n" +
@" ""exchange_code"": ""NFO"",
" + "\n" +
@" ""product"": ""optionplus"",
" + "\n" +
@" ""order_type"":""limit"",
" + "\n" +
@" ""price"":""171"",
" + "\n" +
@" ""action"":""buy"",
" + "\n" +
@" ""quantity"":""50"",
" + "\n" +
@" ""expiry_date"": ""25-Jan-2023"",
" + "\n" +
@" ""right"": ""call"",
" + "\n" +
@" ""strike_price"": ""19000"",
" + "\n" +
@" ""specialflag"" : ""S"",
" + "\n" +
@" ""stoploss"": ""190"",
" + "\n" +
@" ""order_rate_fresh"": ""195.50""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{}"Success":
{"brokerage":7.0,
"exchange_turnover_charges":0.17,
"stamp_duty":0.01,
"stt":0.0,
"sebi_charges":0.0,
"gst":1.29,
"total_turnover_and_sebi_charges": 0.17,
"total_other_charges": 1.47,
"total_brokerage":8.47),
"Status": 200, "Error":null}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/preview_order |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
stock_code | String | "NIFTY" | Yes |
exchange_code | String | "NFO" | Yes |
product | String | "futures","options","optionplus","margin" | Yes |
order_type | String | "limit","market","stoploss" | Yes |
price | String | Numeric String of Currency | Yes |
action | String | "buy","sell" | Yes |
quantity | String | Number of quantity in string formatted | Yes |
expiry_date | String | ISO 8601 | Yes |
right | String | "call","put","others" | Yes |
strike_price | String | Numeric Currency | Yes |
stoploss | String | Numeric Currency | Yes |
order_rate_fresh | String | Numeric Currency | Yes |
HistoricalChartsv2
GetOptionChain
var axios = require('axios');
var data = JSON.stringify({
"stock_code": "NIFTY",
"exchange_code": "NFO",
"expiry_date": "2022-08-25T06:00:00.000Z",
"product_type": "Futures",
"right": "",
"strike_price": ""
});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/OptionChain',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/optionchain"
payload = json.dumps({
"stock_code": "ICIBAN",
"exchange_code": "NFO",
"expiry_date": "2025-01-25T06:00:00.000Z",
"product_type": "futures",
}, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/OptionChain")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/OptionChain");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""stock_code"": ""NIFTY"",
" + "\n" +
@" ""exchange_code"": ""NFO"",
" + "\n" +
@" ""expiry_date"": ""2022-08-25T06:00:00.000Z"",
" + "\n" +
@" ""product_type"": ""Futures"",
" + "\n" +
@" ""right"": """",
" + "\n" +
@" ""strike_price"": """"
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON response
{'Success': [{'exchange_code': 'NFO',
'product_type': 'Options',
'stock_code': 'NIFTY',
'expiry_date': '06-Feb-2025',
'right': 'Call',
'strike_price': 17600.0,
'ltp': 0.0,
'ltt': '',
'best_bid_price': 0.0,
'best_bid_quantity': '0',
'best_offer_price': 0.0,
'best_offer_quantity': '0',
'open': 0.0,
'high': 0.0,
'low': 0.0,
'previous_close': 0.0,
'ltp_percent_change': 0.0,
'upper_circuit': 6750.4,
'lower_circuit': 5541.8,
'total_quantity_traded': '0',
'spot_price': '23787',
'ltq': '0',
'open_interest': 0.0,
'chnge_oi': 0.0,
'total_buy_qty': '0',
'total_sell_qty': '0'},
{'exchange_code': 'NFO',
'product_type': 'Options',
'stock_code': 'NIFTY',
'expiry_date': '06-Feb-2025',
'right': 'Call',
'strike_price': 17650.0,
'ltp': 0.0,
'ltt': '',
'best_bid_price': 0.0,
'best_bid_quantity': '0',
'best_offer_price': 0.0,
'best_offer_quantity': '0',
'open': 0.0,
'high': 0.0,
'low': 0.0,
'previous_close': 0.0,
'ltp_percent_change': 0.0,
'upper_circuit': 6700.45,
'lower_circuit': 5491.85,
'total_quantity_traded': '0',
'spot_price': '23787',
'ltq': '0',
'open_interest': 0.0,
'chnge_oi': 0.0,
'total_buy_qty': '0',
'total_sell_qty': '0'}],
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/OptionChain |
Headers
Key | Description |
---|---|
X-SessionToken | Session Token |
apikey | API Key |
Body Parameters
Parameter | Data Type | Description |
---|---|---|
stock_code | String | NIFTY |
exchange_code | String | NFO |
expiry_date | String | 2022-12-15T06:00:00.000Z |
product_type | String | options |
right | String | Call |
strike_price | String | 19000 |
Order Notifications
live feeds for Order Updates
var axios = require('axios');
var config = {
method: 'get',
url: 'https://breezeapi.icicidirect.com',
headers: {
'User-Agent': 'XYZABC',
'user': 'LZLAL',
'token': '12i299'
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import base64
import socketio
from datetime import datetime
#Get User ID and Session Token
session_key = "SESSION_TOKEN_FROM_CUSTOMER_DETAILS_API"
#e.g session_key = "QUYyOTUzMTM6NjY5ODc5NzY="
user_id, session_token = base64.b64decode(session_key.encode('ascii')).decode('ascii').split(":")
#e.g Decoded value - AF296713:66987976, after split user_id = AF295313, session_token = 6698797
# Python Socket IO Client
sio = socketio.Client()
auth = {"user": user_id, "token": session_token}
print(auth)
sio.connect("https://livefeeds.icicidirect.com", headers={"User-Agent":"python-socketio[client]/socket"},
auth=auth, transports="websocket", wait_timeout=3)
if sio.connected:
print("Connection established successfully.")
else:
print("Failed to connect.")
tux_to_user_value = {
"orderFlow": {
"B": "Buy",
"S": "Sell",
"N": "NA"
},
"limitMarketFlag": {
"L": "Limit",
"M": "Market",
"S": "StopLoss"
},
"orderType": {
"T": "Day",
"I": "IoC",
"V": "VTC"
},
"productType": {
"F": "Futures",
"O": "Options",
"P": "FuturePlus",
"U": "FuturePlus_sltp",
"I": "OptionPlus",
"C": "Cash",
"Y": "eATM",
"B": "BTST",
"M": "Margin",
"T": "MarginPlus"
},
"orderStatus": {
"A": "All",
"R": "Requested",
"Q": "Queued",
"O": "Ordered",
"P": "Partially Executed",
"E": "Executed",
"J": "Rejected",
"X": "Expired",
"B": "Partially Executed And Expired",
"D": "Partially Executed And Cancelled",
"F": "Freezed",
"C": "Cancelled"
},
"optionType": {
"C": "Call",
"P": "Put",
"*": "Others"
},
}
# parse market depth
def parse_market_depth(data, exchange):
depth = []
counter = 0
for lis in data:
counter += 1
dict = {}
if exchange == '1':
dict["BestBuyRate-"+str(counter)] = lis[0]
dict["BestBuyQty-"+str(counter)] = lis[1]
dict["BestSellRate-"+str(counter)] = lis[2]
dict["BestSellQty-"+str(counter)] = lis[3]
depth.append(dict)
else:
dict["BestBuyRate-"+str(counter)] = lis[0]
dict["BestBuyQty-"+str(counter)] = lis[1]
dict["BuyNoOfOrders-"+str(counter)] = lis[2]
dict["BuyFlag-"+str(counter)] = lis[3]
dict["BestSellRate-"+str(counter)] = lis[4]
dict["BestSellQty-"+str(counter)] = lis[5]
dict["SellNoOfOrders-"+str(counter)] = lis[6]
dict["SellFlag-"+str(counter)] = lis[7]
depth.append(dict)
return depth
# parsing logic
def parse_data(data):
if data and type(data) == list and len(data) > 0 and type(data[0]) == str and "!" not in data[0] and len(data) == 19:
#if data and type(data) == list and len(data) > 0 and type(data[0]) == str and "!" not in data[0] and len(data) == 19:
iclick_data = dict()
#iclick_data['sequence_number'] = data[0]
iclick_data['stock_name'] = data[0]
iclick_data['stock_code'] = data[1]
iclick_data['action_type'] = data[2]
iclick_data['expiry_date'] = data[3]
iclick_data['strike_price'] = data[4]
iclick_data['option_type'] = data[5]
iclick_data['stock_description'] = data[6]
iclick_data['recommended_price_and_date'] = data[7]
iclick_data['recommended_price_from'] = data[8]
iclick_data['recommended_price_to'] = data[9]
iclick_data['recommended_date'] = data[10]
iclick_data['target_price'] = data[11]
iclick_data['sltp_price'] = data[12]
iclick_data['part_profit_percentage'] = data[13]
iclick_data['profit_price'] = data[14]
iclick_data['exit_price'] = data[15]
iclick_data['recommended_update'] = data[16]
iclick_data['iclick_status'] = data[17]
iclick_data['subscription_type'] = data[18]
return(iclick_data)
if data and type(data) == list and len(data) > 0 and type(data[0]) == str and "!" not in data[0] and len(data) == 28:
strategy_dict = dict()
strategy_dict['strategy_date'] = data[0]
strategy_dict['modification_date'] = data[1]
strategy_dict['portfolio_id'] = data[2]
strategy_dict['call_action'] = data[3]
strategy_dict['portfolio_name'] = data[4]
strategy_dict['exchange_code'] = data[5]
strategy_dict['product_type'] = data[6]
#strategy_dict['INDEX/STOCK'] = data[7]
strategy_dict['underlying'] = data[8]
strategy_dict['expiry_date'] = data[9]
#strategy_dict['OCR_EXER_TYP'] = data[10]
strategy_dict['option_type'] = data[11]
strategy_dict['strike_price'] = data[12]
strategy_dict['action'] = data[13]
strategy_dict['recommended_price_from'] = data[14]
strategy_dict['recommended_price_to'] = data[15]
strategy_dict['minimum_lot_quantity'] = data[16]
strategy_dict['last_traded_price'] = data[17]
strategy_dict['best_bid_price'] = data[18]
strategy_dict['best_offer_price'] = data[19]
strategy_dict['last_traded_quantity'] = data[20]
strategy_dict['target_price'] = data[21]
strategy_dict['expected_profit_per_lot'] = data[22]
strategy_dict['stop_loss_price'] = data[23]
strategy_dict['expected_loss_per_lot'] = data[24]
strategy_dict['total_margin'] = data[25]
strategy_dict['leg_no'] = data[26]
strategy_dict['status'] = data[27]
return(strategy_dict)
if data and type(data) == list and len(data) > 0 and type(data[0]) == str and "!" not in data[0]:
order_dict = {}
order_dict["sourceNumber"] = data[0] #Source Number
order_dict["group"] = data[1] #Group
order_dict["userId"] = data[2] #User_id
order_dict["key"] = data[3] #Key
order_dict["messageLength"] = data[4] #Message Length
order_dict["requestType"] = data[5] #Request Type
order_dict["messageSequence"] = data[6] #Message Sequence
order_dict["messageDate"] = data[7] #Date
order_dict["messageTime"] = data[8] #Time
order_dict["messageCategory"] = data[9] #Message Category
order_dict["messagePriority"] = data[10] #Priority
order_dict["messageType"] = data[11] #Message Type
order_dict["orderMatchAccount"] = data[12] #Order Match Account
order_dict["orderExchangeCode"] = data[13] #Exchange Code
if data[11] == '4' or data[11] == '5':
order_dict["stockCode"] = data[14] #Stock Code
order_dict["orderFlow"] = tux_to_user_value['orderFlow'].get(str(data[15]).upper(),str(data[15])) # Order Flow
order_dict["limitMarketFlag"] = tux_to_user_value['limitMarketFlag'].get(str(data[16]).upper(),str(data[16])) #Limit Market Flag
order_dict["orderType"] = tux_to_user_value['orderType'].get(str(data[17]).upper(),str(data[17])) #OrderType
order_dict["orderLimitRate"] = data[18] #Limit Rate
order_dict["productType"] = tux_to_user_value['productType'].get(str(data[19]).upper(),str(data[19])) #Product Type
order_dict["orderStatus"] = tux_to_user_value['orderStatus'].get(str(data[20]).upper(),str(data[20])) # Order Status
order_dict["orderDate"] = data[21] #Order Date
order_dict["orderTradeDate"] = data[22] #Trade Date
order_dict["orderReference"] = data[23] #Order Reference
order_dict["orderQuantity"] = data[24] #Order Quantity
order_dict["openQuantity"] = data[25] #Open Quantity
order_dict["orderExecutedQuantity"] = data[26] #Order Executed Quantity
order_dict["cancelledQuantity"] = data[27] #Cancelled Quantity
order_dict["expiredQuantity"] = data[28] #Expired Quantity
order_dict["orderDisclosedQuantity"] = data[29] # Order Disclosed Quantity
order_dict["orderStopLossTrigger"] = data[30] #Order Stop Loss Triger
order_dict["orderSquareFlag"] = data[31] #Order Square Flag
order_dict["orderAmountBlocked"] = data[32] # Order Amount Blocked
order_dict["orderPipeId"] = data[33] #Order PipeId
order_dict["channel"] = data[34] #Channel
order_dict["exchangeSegmentCode"] = data[35] #Exchange Segment Code
order_dict["exchangeSegmentSettlement"] = data[36] #Exchange Segment Settlement
order_dict["segmentDescription"] = data[37] #Segment Description
order_dict["marginSquareOffMode"] = data[38] #Margin Square Off Mode
order_dict["orderValidDate"] = data[40] #Order Valid Date
order_dict["orderMessageCharacter"] = data[41] #Order Message Character
order_dict["averageExecutedRate"] = data[42] #Average Exited Rate
order_dict["orderPriceImprovementFlag"] = data[43] #Order Price Flag
order_dict["orderMBCFlag"] = data[44] #Order MBC Flag
order_dict["orderLimitOffset"] = data[45] #Order Limit Offset
order_dict["systemPartnerCode"] = data[46] #System Partner Code
elif data[11] == '6' or data[11] == '7':
order_dict["stockCode"] = data[14] #stockCode
order_dict["productType"] = tux_to_user_value['productType'].get(str(data[15]).upper(),str(data[15])) #Product Type
order_dict["optionType"] = tux_to_user_value['optionType'].get(str(data[16]).upper(),str(data[16])) #Option Type
order_dict["exerciseType"] = data[17] #Exercise Type
order_dict["strikePrice"] = data[18] #Strike Price
order_dict["expiryDate"] = data[19] #Expiry Date
order_dict["orderValidDate"] = data[20] #Order Valid Date
order_dict["orderFlow"] = tux_to_user_value['orderFlow'].get(str(data[21]).upper(),str(data[21])) #Order Flow
order_dict["limitMarketFlag"] = tux_to_user_value['limitMarketFlag'].get(str(data[22]).upper(),str(data[22])) #Limit Market Flag
order_dict["orderType"] = tux_to_user_value['orderType'].get(str(data[23]).upper(),str(data[23])) #Order Type
order_dict["limitRate"] = data[24] #Limit Rate
order_dict["orderStatus"] = tux_to_user_value['orderStatus'].get(str(data[25]).upper(),str(data[25])) #Order Status
order_dict["orderReference"] = data[26] #Order Reference
order_dict["orderTotalQuantity"] = data[27] #Order Total Quantity
order_dict["executedQuantity"] = data[28] #Executed Quantity
order_dict["cancelledQuantity"] = data[29] #Cancelled Quantity
order_dict["expiredQuantity"] = data[30] #Expired Quantity
order_dict["stopLossTrigger"] = data[31] #Stop Loss Trigger
order_dict["specialFlag"] = data[32] #Special Flag
order_dict["pipeId"] = data[33] #PipeId
order_dict["channel"] = data[34] #Channel
order_dict["modificationOrCancelFlag"] = data[35] #Modification or Cancel Flag
order_dict["tradeDate"] = data[36] #Trade Date
order_dict["acknowledgeNumber"] = data[37] #Acknowledgement Number
order_dict["stopLossOrderReference"] = data[37] #Stop Loss Order Reference
order_dict["totalAmountBlocked"] = data[38] # Total Amount Blocked
order_dict["averageExecutedRate"] = data[39] #Average Executed Rate
order_dict["cancelFlag"] = data[40] #Cancel Flag
order_dict["squareOffMarket"] = data[41] #SquareOff Market
order_dict["quickExitFlag"] = data[42] #Quick Exit Flag
order_dict["stopValidTillDateFlag"] = data[43] #Stop Valid till Date Flag
order_dict["priceImprovementFlag"] = data[44] #Price Improvement Flag
order_dict["conversionImprovementFlag"] = data[45] #Conversion Improvement Flag
order_dict["trailUpdateCondition"] = data[45] #Trail Update Condition
order_dict["systemPartnerCode"] = data[46] #System Partner Code
return order_dict
exchange = str.split(data[0], '!')[0].split('.')[0]
data_type = str.split(data[0], '!')[0].split('.')[1]
if exchange == '6':
data_dict = {}
data_dict["symbol"] = data[0]
data_dict["AndiOPVolume"] = data[1]
data_dict["Reserved"] = data[2]
data_dict["IndexFlag"] = data[3]
data_dict["ttq"] = data[4]
data_dict["last"] = data[5]
data_dict["ltq"] = data[6]
data_dict["ltt"] = datetime.fromtimestamp(data[7]).strftime('%c')
data_dict["AvgTradedPrice"] = data[8]
data_dict["TotalBuyQnt"] = data[9]
data_dict["TotalSellQnt"] = data[10]
data_dict["ReservedStr"] = data[11]
data_dict["ClosePrice"] = data[12]
data_dict["OpenPrice"] = data[13]
data_dict["HighPrice"] = data[14]
data_dict["LowPrice"] = data[15]
data_dict["ReservedShort"] = data[16]
data_dict["CurrOpenInterest"] = data[17]
data_dict["TotalTrades"] = data[18]
data_dict["HightestPriceEver"] = data[19]
data_dict["LowestPriceEver"] = data[20]
data_dict["TotalTradedValue"] = data[21]
marketDepthIndex = 0
for i in range(22, len(data)):
data_dict["Quantity-"+str(marketDepthIndex)] = data[i][0]
data_dict["OrderPrice-"+str(marketDepthIndex)] = data[i][1]
data_dict["TotalOrders-"+str(marketDepthIndex)] = data[i][2]
data_dict["Reserved-"+str(marketDepthIndex)] = data[i][3]
data_dict["SellQuantity-"+str(marketDepthIndex)] = data[i][4]
data_dict["SellOrderPrice-"+str(marketDepthIndex)] = data[i][5]
data_dict["SellTotalOrders-"+str(marketDepthIndex)] = data[i][6]
data_dict["SellReserved-"+str(marketDepthIndex)] = data[i][7]
marketDepthIndex += 1
if exchange == '3':
nifty_data = dict()
nifty_data['stock_code'] = data[0]
nifty_data['open'] = data[1]
nifty_data['high'] = data[2]
nifty_data['low'] = data[3]
nifty_data['previous_close'] = data[4]
nifty_data['last_trade_price'] = data[5]
nifty_data['last_trade_quantity'] = data[6]
nifty_data['last_traded_time'] = data[7]
nifty_data['total_traded_volume'] = data[8]
nifty_data['percentage_change'] = data[9]
nifty_data['absolute_change'] = data[10]
nifty_data['weighted_average'] = data[11]
nifty_data['bid_price'] = data[12]
nifty_data['bid_quantity'] = data[13]
nifty_data['offer_price'] = data[14]
nifty_data['offer_quantity'] = data[15]
nifty_data['open_interest_value'] = data[16]
# nifty_data['expiry_date'] = data[17]
return(nifty_data)
elif data_type == '1':
data_dict = {
"symbol": data[0],
"open": data[1],
"last": data[2],
"high": data[3],
"low": data[4],
"change": data[5],
"bPrice": data[6],
"bQty": data[7],
"sPrice": data[8],
"sQty": data[9],
"ltq": data[10],
"avgPrice": data[11],
"quotes": "Quotes Data"
}
# For NSE & BSE conversion
if len(data) == 21:
data_dict["ttq"] = data[12]
data_dict["totalBuyQt"] = data[13]
data_dict["totalSellQ"] = data[14]
data_dict["ttv"] = data[15]
data_dict["trend"] = data[16]
data_dict["lowerCktLm"] = data[17]
data_dict["upperCktLm"] = data[18]
data_dict["ltt"] = datetime.fromtimestamp(
data[19]).strftime('%c')
data_dict["close"] = data[20]
# For FONSE & CDNSE conversion
elif len(data) == 23:
data_dict["OI"] = data[12]
data_dict["CHNGOI"] = data[13]
data_dict["ttq"] = data[14]
data_dict["totalBuyQt"] = data[15]
data_dict["totalSellQ"] = data[16]
data_dict["ttv"] = data[17]
data_dict["trend"] = data[18]
data_dict["lowerCktLm"] = data[19]
data_dict["upperCktLm"] = data[20]
data_dict["ltt"] = datetime.fromtimestamp(
data[21]).strftime('%c')
data_dict["close"] = data[22]
else:
data_dict = {
"symbol": data[0],
"time": datetime.fromtimestamp(data[1]).strftime('%c'),
"depth": parse_market_depth(data[2], exchange),
"quotes": "Market Depth"
}
if exchange == '4' and len(data) == 21:
data_dict['exchange'] = 'NSE Equity'
elif exchange == '1':
data_dict['exchange'] = 'BSE'
elif exchange == '13':
data_dict['exchange'] = 'NSE Currency'
elif exchange == '4' and len(data) == 23:
data_dict['exchange'] = 'NSE Futures & Options'
elif exchange == '6':
data_dict['exchange'] = 'Commodity'
return data_dict
# CallBack functions to receive feeds
def on_ticks(data):
ticks = parse_data(data)
print(ticks)
#Connect to receive feeds
sio.on('order', on_ticks)
sio.wait()
#Disconnect from the server
sio.emit("disconnect", "transport close")
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://breezeapi.icicidirect.com")
.method("GET", null)
.addHeader("User-Agent", "XYZABC")
.addHeader("user", "LZLAL")
.addHeader("token", "12i299")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://breezeapi.icicidirect.com");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
client.UserAgent = "XYZABC";
request.AddHeader("user", "LZLAL");
request.AddHeader("token", "12i299");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'sourceNumber': '1',
'group': '',
'userId': 'AG570549',
'key': '',
'messageLength': '\x19249',
'requestType': '5',
'messageSequence": '2025031001818814',
'messageDate': '10-03-2025',
'messageTime': '14:13:22',
'messageCategory': 'Intraday Calls',
'messagePriority': 'N',
'messageType': '6',
'orderMatchAccount': '8510232533',
'orderExchangeCode': 'NFO',
'stockCode': 'NIFTY',
'productType': 'Options',
'optionType': 'Call',
'exerciseType': 'E",
'strikePrice': '2310000',
'expiryDate': '13-Mar-2025',
'orderValidDate': '10-Mar-2025',
'orderFlow': 'Buy',
'limitMarketFlag': 'Limit',
'orderType': 'Day',
'limitRate: 100',
'orderStatus": "Requested',
'orderReference': '202503102500012717',
'orderTotalQuantity': '600',
'executedQuantity': '0',
'cancelled Quantity': '0',
'expiredQuantity': '0',
'stopLossTrigger': '0',
'specialFlag': 'N',
'pipeId': '25',
'channel': 'WEB',
'modificationOrCancelFlag": 'Y',
'tradeDate': '10-Mar-2025',
'acknowledgeNumber':'',
stopLossOrderReference': '',
'totalAmountBlocked': '',
'averageExecutedRate': "0.000000",
'cancelFlag': '0.000000',
'squareOffMarket': 'N',
'quickExitFlag': 'N',
'stopValidTillDateFlag': 'Y',
'priceImprovementFlag': 'N',
'conversion ImprovementFlag': 'N',
'trailUpdateCondition': 'N',
'systemPartnerCode': 'N'}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://livefeeds.icicidirect.com/ |
SourceNumber | Source Number |
userId | User ID |
messageLength | Message Length |
requestType | Request Type |
messageSequence | Message Sequence |
messageDate | Message Date |
messageTime | Message Time |
messageCategory | Message Category |
Intraday Calls | Intraday Calls |
messagePriority Message Priority | |
messageType | Message Type |
orderMatchAccount | Order Match Account |
orderExchangeCode | Order Exchange Code |
stockCode | Stock Code |
orderFlow | Order Flow |
limitMarketFlag | Limit Market Flag |
orderType | Order Type |
orderLimitRate | Order Limit Rate |
productType | Product Type |
orderStatus | Order Status |
orderDate | Order Date |
orderTradeDate | Order Trade Date |
orderReference | Order Reference |
orderQuantity | Order Quantity |
openQuantity | Open Quantity |
orderExecutedQuantity | Order Executed Quantity |
cancelledQuantity | Cancelled Quantity |
expiredQuantity | Expired Quantity |
orderDisclosedQuantity | Order Disclosed Quantity |
orderStopLossTrigger | Order Stop Loss Trigger |
orderSquareFlag | Order Square Flag |
orderAmountBlocked | Order Amount Blocked |
orderPipeId | Order PipeId |
channel | Channel |
exchangeSegmentCode | Exchange Segment Code |
exchangeSegmentSettlement | Exchange Segment Settlement |
segmentDescription | Segment Description |
marginSquareOffMode | Margin Square Off Mode |
orderMessageCharacter | Order Message Character |
averageExecutedRate | Average Executed Rate |
orderPriceImprovementFlag | Order Price Improvement Flag |
orderMBCFlag | Order MBC Flag |
orderLimitOffset | Order Limit Offset |
systemPartnerCode | System Partner Code |
Note : After every state change in order status, new notification would be received instantaneously.
Tick Data Stream
Tick By Tick Market Data
var axios = require('axios');
var config = {
method: 'get',
url: 'https://breezeapi.icicidirect.com',
headers: {
'User-Agent': 'XYZABC',
'user': 'LZLAL',
'token': '12i299'
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import base64
import socketio
from datetime import datetime
#Get User ID and Session Token
session_key = "SESSION_TOKEN_FROM_CUSTOMER_DETAILS_API"
#e.g session_key = "QUYyOTUzMTM6NjY5ODc5NzY="
user_id, session_token = base64.b64decode(session_key.encode('ascii')).decode('ascii').split(":")
#e.g Decoded value - AF296713:66987976, after split user_id = AF295313, session_token = 6698797
# Python Socket IO Client
sio = socketio.Client()
script_code = "4.1!2885" #Subscribe more than one stock at a time
auth = {"user": user_id, "token": session_token}
sio.connect("https://livestream.icicidirect.com", headers={"User-Agent":"python-socketio[client]/socket"},
auth=auth, transports="websocket", wait_timeout=3)
if sio.connected:
print("Connection established successfully!")
else:
print("Failed to connect.")
tux_to_user_value = {
"orderFlow": {
"B": "Buy",
"S": "Sell",
"N": "NA"
},
"limitMarketFlag": {
"L": "Limit",
"M": "Market",
"S": "StopLoss"
},
"orderType": {
"T": "Day",
"I": "IoC",
"V": "VTC"
},
"productType": {
"F": "Futures",
"O": "Options",
"P": "FuturePlus",
"U": "FuturePlus_sltp",
"I": "OptionPlus",
"C": "Cash",
"Y": "eATM",
"B": "BTST",
"M": "Margin",
"T": "MarginPlus"
},
"orderStatus": {
"A": "All",
"R": "Requested",
"Q": "Queued",
"O": "Ordered",
"P": "Partially Executed",
"E": "Executed",
"J": "Rejected",
"X": "Expired",
"B": "Partially Executed And Expired",
"D": "Partially Executed And Cancelled",
"F": "Freezed",
"C": "Cancelled"
},
"optionType": {
"C": "Call",
"P": "Put",
"*": "Others"
},
}
# parse market depth
def parse_market_depth(self, data, exchange):
depth = []
counter = 0
for lis in data:
counter += 1
dict = {}
if exchange == '1':
dict["BestBuyRate-"+str(counter)] = lis[0]
dict["BestBuyQty-"+str(counter)] = lis[1]
dict["BestSellRate-"+str(counter)] = lis[2]
dict["BestSellQty-"+str(counter)] = lis[3]
depth.append(dict)
else:
dict["BestBuyRate-"+str(counter)] = lis[0]
dict["BestBuyQty-"+str(counter)] = lis[1]
dict["BuyNoOfOrders-"+str(counter)] = lis[2]
dict["BuyFlag-"+str(counter)] = lis[3]
dict["BestSellRate-"+str(counter)] = lis[4]
dict["BestSellQty-"+str(counter)] = lis[5]
dict["SellNoOfOrders-"+str(counter)] = lis[6]
dict["SellFlag-"+str(counter)] = lis[7]
depth.append(dict)
return depth
# parsing logic
def parse_data(data):
if data and type(data) == list and len(data) > 0 and type(data[0]) == str and "!" not in data[0]:
order_dict = {}
order_dict["sourceNumber"] = data[0] #Source Number
order_dict["group"] = data[1] #Group
order_dict["userId"] = data[2] #User_id
order_dict["key"] = data[3] #Key
order_dict["messageLength"] = data[4] #Message Length
order_dict["requestType"] = data[5] #Request Type
order_dict["messageSequence"] = data[6] #Message Sequence
order_dict["messageDate"] = data[7] #Date
order_dict["messageTime"] = data[8] #Time
order_dict["messageCategory"] = data[9] #Message Category
order_dict["messagePriority"] = data[10] #Priority
order_dict["messageType"] = data[11] #Message Type
order_dict["orderMatchAccount"] = data[12] #Order Match Account
order_dict["orderExchangeCode"] = data[13] #Exchange Code
if data[11] == '4' or data[11] == '5':
order_dict["stockCode"] = data[14] #Stock Code
order_dict["orderFlow"] = tux_to_user_value['orderFlow'].get(str(data[15]).upper(),str(data[15])) # Order Flow
order_dict["limitMarketFlag"] = tux_to_user_value['limitMarketFlag'].get(str(data[16]).upper(),str(data[16])) #Limit Market Flag
order_dict["orderType"] = tux_to_user_value['orderType'].get(str(data[17]).upper(),str(data[17])) #OrderType
order_dict["orderLimitRate"] = data[18] #Limit Rate
order_dict["productType"] = tux_to_user_value['productType'].get(str(data[19]).upper(),str(data[19])) #Product Type
order_dict["orderStatus"] = tux_to_user_value['orderStatus'].get(str(data[20]).upper(),str(data[20])) # Order Status
order_dict["orderDate"] = data[21] #Order Date
order_dict["orderTradeDate"] = data[22] #Trade Date
order_dict["orderReference"] = data[23] #Order Reference
order_dict["orderQuantity"] = data[24] #Order Quantity
order_dict["openQuantity"] = data[25] #Open Quantity
order_dict["orderExecutedQuantity"] = data[26] #Order Executed Quantity
order_dict["cancelledQuantity"] = data[27] #Cancelled Quantity
order_dict["expiredQuantity"] = data[28] #Expired Quantity
order_dict["orderDisclosedQuantity"] = data[29] # Order Disclosed Quantity
order_dict["orderStopLossTrigger"] = data[30] #Order Stop Loss Triger
order_dict["orderSquareFlag"] = data[31] #Order Square Flag
order_dict["orderAmountBlocked"] = data[32] # Order Amount Blocked
order_dict["orderPipeId"] = data[33] #Order PipeId
order_dict["channel"] = data[34] #Channel
order_dict["exchangeSegmentCode"] = data[35] #Exchange Segment Code
order_dict["exchangeSegmentSettlement"] = data[36] #Exchange Segment Settlement
order_dict["segmentDescription"] = data[37] #Segment Description
order_dict["marginSquareOffMode"] = data[38] #Margin Square Off Mode
order_dict["orderValidDate"] = data[40] #Order Valid Date
order_dict["orderMessageCharacter"] = data[41] #Order Message Character
order_dict["averageExecutedRate"] = data[42] #Average Exited Rate
order_dict["orderPriceImprovementFlag"] = data[43] #Order Price Flag
order_dict["orderMBCFlag"] = data[44] #Order MBC Flag
order_dict["orderLimitOffset"] = data[45] #Order Limit Offset
order_dict["systemPartnerCode"] = data[46] #System Partner Code
elif data[11] == '6' or data[11] == '7':
order_dict["stockCode"] = data[14] #stockCode
order_dict["productType"] = tux_to_user_value['productType'].get(str(data[15]).upper(),str(data[15])) #Product Type
order_dict["optionType"] = tux_to_user_value['optionType'].get(str(data[16]).upper(),str(data[16])) #Option Type
order_dict["exerciseType"] = data[17] #Exercise Type
order_dict["strikePrice"] = data[18] #Strike Price
order_dict["expiryDate"] = data[19] #Expiry Date
order_dict["orderValidDate"] = data[20] #Order Valid Date
order_dict["orderFlow"] = tux_to_user_value['orderFlow'].get(str(data[21]).upper(),str(data[21])) #Order Flow
order_dict["limitMarketFlag"] = tux_to_user_value['limitMarketFlag'].get(str(data[22]).upper(),str(data[22])) #Limit Market Flag
order_dict["orderType"] = tux_to_user_value['orderType'].get(str(data[23]).upper(),str(data[23])) #Order Type
order_dict["limitRate"] = data[24] #Limit Rate
order_dict["orderStatus"] = tux_to_user_value['orderStatus'].get(str(data[25]).upper(),str(data[25])) #Order Status
order_dict["orderReference"] = data[26] #Order Reference
order_dict["orderTotalQuantity"] = data[27] #Order Total Quantity
order_dict["executedQuantity"] = data[28] #Executed Quantity
order_dict["cancelledQuantity"] = data[29] #Cancelled Quantity
order_dict["expiredQuantity"] = data[30] #Expired Quantity
order_dict["stopLossTrigger"] = data[31] #Stop Loss Trigger
order_dict["specialFlag"] = data[32] #Special Flag
order_dict["pipeId"] = data[33] #PipeId
order_dict["channel"] = data[34] #Channel
order_dict["modificationOrCancelFlag"] = data[35] #Modification or Cancel Flag
order_dict["tradeDate"] = data[36] #Trade Date
order_dict["acknowledgeNumber"] = data[37] #Acknowledgement Number
order_dict["stopLossOrderReference"] = data[37] #Stop Loss Order Reference
order_dict["totalAmountBlocked"] = data[38] # Total Amount Blocked
order_dict["averageExecutedRate"] = data[39] #Average Executed Rate
order_dict["cancelFlag"] = data[40] #Cancel Flag
order_dict["squareOffMarket"] = data[41] #SquareOff Market
order_dict["quickExitFlag"] = data[42] #Quick Exit Flag
order_dict["stopValidTillDateFlag"] = data[43] #Stop Valid till Date Flag
order_dict["priceImprovementFlag"] = data[44] #Price Improvement Flag
order_dict["conversionImprovementFlag"] = data[45] #Conversion Improvement Flag
order_dict["trailUpdateCondition"] = data[45] #Trail Update Condition
order_dict["systemPartnerCode"] = data[46] #System Partner Code
return order_dict
exchange = str.split(data[0], '!')[0].split('.')[0]
data_type = str.split(data[0], '!')[0].split('.')[1]
if exchange == '6':
data_dict = {}
data_dict["symbol"] = data[0]
data_dict["AndiOPVolume"] = data[1]
data_dict["Reserved"] = data[2]
data_dict["IndexFlag"] = data[3]
data_dict["ttq"] = data[4]
data_dict["last"] = data[5]
data_dict["ltq"] = data[6]
data_dict["ltt"] = datetime.fromtimestamp(data[7]).strftime('%c')
data_dict["AvgTradedPrice"] = data[8]
data_dict["TotalBuyQnt"] = data[9]
data_dict["TotalSellQnt"] = data[10]
data_dict["ReservedStr"] = data[11]
data_dict["ClosePrice"] = data[12]
data_dict["OpenPrice"] = data[13]
data_dict["HighPrice"] = data[14]
data_dict["LowPrice"] = data[15]
data_dict["ReservedShort"] = data[16]
data_dict["CurrOpenInterest"] = data[17]
data_dict["TotalTrades"] = data[18]
data_dict["HightestPriceEver"] = data[19]
data_dict["LowestPriceEver"] = data[20]
data_dict["TotalTradedValue"] = data[21]
marketDepthIndex = 0
for i in range(22, len(data)):
data_dict["Quantity-"+str(marketDepthIndex)] = data[i][0]
data_dict["OrderPrice-"+str(marketDepthIndex)] = data[i][1]
data_dict["TotalOrders-"+str(marketDepthIndex)] = data[i][2]
data_dict["Reserved-"+str(marketDepthIndex)] = data[i][3]
data_dict["SellQuantity-"+str(marketDepthIndex)] = data[i][4]
data_dict["SellOrderPrice-"+str(marketDepthIndex)] = data[i][5]
data_dict["SellTotalOrders-"+str(marketDepthIndex)] = data[i][6]
data_dict["SellReserved-"+str(marketDepthIndex)] = data[i][7]
marketDepthIndex += 1
elif data_type == '1':
data_dict = {
"symbol": data[0],
"open": data[1],
"last": data[2],
"high": data[3],
"low": data[4],
"change": data[5],
"bPrice": data[6],
"bQty": data[7],
"sPrice": data[8],
"sQty": data[9],
"ltq": data[10],
"avgPrice": data[11],
"quotes": "Quotes Data"
}
# For NSE & BSE conversion
if len(data) == 21:
data_dict["ttq"] = data[12]
data_dict["totalBuyQt"] = data[13]
data_dict["totalSellQ"] = data[14]
data_dict["ttv"] = data[15]
data_dict["trend"] = data[16]
data_dict["lowerCktLm"] = data[17]
data_dict["upperCktLm"] = data[18]
data_dict["ltt"] = datetime.fromtimestamp(
data[19]).strftime('%c')
data_dict["close"] = data[20]
# For FONSE & CDNSE conversion
elif len(data) == 23:
data_dict["OI"] = data[12]
data_dict["CHNGOI"] = data[13]
data_dict["ttq"] = data[14]
data_dict["totalBuyQt"] = data[15]
data_dict["totalSellQ"] = data[16]
data_dict["ttv"] = data[17]
data_dict["trend"] = data[18]
data_dict["lowerCktLm"] = data[19]
data_dict["upperCktLm"] = data[20]
data_dict["ltt"] = datetime.fromtimestamp(
data[21]).strftime('%c')
data_dict["close"] = data[22]
else:
data_dict = {
"symbol": data[0],
"time": datetime.fromtimestamp(data[1]).strftime('%c'),
"depth": parse_market_depth(data[2], exchange),
"quotes": "Market Depth"
}
if exchange == '4' and len(data) == 21:
data_dict['exchange'] = 'NSE Equity'
elif exchange == '1':
data_dict['exchange'] = 'BSE'
elif exchange == '13':
data_dict['exchange'] = 'NSE Currency'
elif exchange == '4' and len(data) == 23:
data_dict['exchange'] = 'NSE Futures & Options'
elif exchange == '6':
data_dict['exchange'] = 'Commodity'
return data_dict
# CallBack functions to receive feeds
def on_ticks(data):
ticks = parse_data(data)
print(ticks)
sio.emit('join', script_code)
sio.on('stock', on_ticks)
sio.wait()
#Unwatch from the stock
sio.emit("leave", script_code)
#Disconnect from the server
sio.emit("disconnect", "transport close")
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://breezeapi.icicidirect.com")
.method("GET", null)
.addHeader("User-Agent", "XYZABC")
.addHeader("user", "LZLAL")
.addHeader("token", "12i299")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://breezeapi.icicidirect.com");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
client.UserAgent = "XYZABC";
request.AddHeader("user", "LZLAL");
request.AddHeader("token", "12i299");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'symbol': '4.112885',
'open': 1240,
'last': 1236.2,
'high': 1244.8,
'low': 1229.75,
'change': -0.18,
'bPrice': 1236.2,
'boty': 63,
'sPrice': 1236.55,
'sQty': 18,
'ltq': 100,
'avgPrice': 1235.13,
'quotes': 'Quotes Data',
'ttq': 2158026,
'totalBuyQt': 237149,
'totalSello': 370391,
'ttv': '266.54C',
'trend': '',
'lowerCktLm': 1114.6,
'upperCktLm': 1362.2,
'ltt': 'Tue Mar 11 09:38:22 2025',
'close': 1238.4,
'exchange': 'NSE Equity'}
Request Information
The WebSocket API uses WebSocket protocol to establish a single long standing TCP connection after an HTTP handshake to receive streaming quotes.To connect to the ICICI's WebSocket API, you will need a WebSocket client library in your choice of programming language we will provide the sample code supported in 4 languages(Python, C#, Javascript and Java). You can subscribe for stock-token on a single WebSocket connection and receive live stream for them.
Category | Value |
---|---|
HTTP Request | GET |
URL | https://livestream.icicidirect.com/ |
Symbol Stock | Token Value |
Open | Open Price |
Last | Last Price |
high | High Price |
Low | Low Price |
change | change |
bPrice | Buy Price |
bQty | Buy Quantity |
sPrice | Selling Price |
sQty | Selling Quantity |
ltq | Last Traded Quantity |
avgPrice | Average Price |
quotes | Quotes |
ttq | Total Traded Quantity |
totalBuyQt | Total Buy Quantity |
totalSellQt | Total Sell Quantity |
ttv | Total Traded Volume |
trend | trend |
lowerCktLM Lower | Circuit Limit |
upperCktLM | Upper Circuit Limit |
ltt | Last Traded Time |
close Close | Price |
exchange | Exchange |
stock_name | Stock Name |
One Click F&O Stream
Oneclick Strategy
var axios = require('axios');
var config = {
method: 'get',
url: 'https://breezeapi.icicidirect.com',
headers: {
'User-Agent': 'XYZABC',
'user': 'LZLAL',
'token': '12i299'
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
#import required libraries
import base64
import socketio
#Get User ID and Session Token
session_key = "SESSION_TOKEN_FROM_CUSTOMER_DETAILS_API"
#e.g session_key = "QUYyOTUzMTM6NjY5ODc5NzY="
user_id, session_token = base64.b64decode(session_key.encode('ascii')).decode('ascii').split(":")
#e.g Decoded value - AF296713:66987976, after split user_id = AF295313, session_token = 6698797
# Python Socket IO Client
sio = socketio.Client()
auth = {"user": user_id, "token": session_token}
sio.connect("https://livefeeds.icicidirect.com", headers={"User-Agent":"python-socketio[client]/socket"},
auth=auth, transports="websocket", wait_timeout=3)
# Script Code of Stock or Instrument e.g 4.1!1594, 1.1!500209 , 13.1!5023, 6.1!247457.
script_code = ["one_click_fno"] #Subscribe more than one stock at a time
# channel_name = 'stock'
#parsing logic
def parse_data(data):
if data and type(data) == list and len(data) > 0 and type(data[0]) == str and "!" not in data[0] and len(data) == 28:
strategy_dict = dict()
strategy_dict['strategy_date'] = data[0]
strategy_dict['modification_date'] = data[1]
strategy_dict['portfolio_id'] = data[2]
strategy_dict['call_action'] = data[3]
strategy_dict['portfolio_name'] = data[4]
strategy_dict['exchange_code'] = data[5]
strategy_dict['product_type'] = data[6]
#strategy_dict['INDEX/STOCK'] = data[7]
strategy_dict['underlying'] = data[8]
strategy_dict['expiry_date'] = data[9]
#strategy_dict['OCR_EXER_TYP'] = data[10]
strategy_dict['option_type'] = data[11]
strategy_dict['strike_price'] = data[12]
strategy_dict['action'] = data[13]
strategy_dict['recommended_price_from'] = data[14]
strategy_dict['recommended_price_to'] = data[15]
strategy_dict['minimum_lot_quantity'] = data[16]
strategy_dict['last_traded_price'] = data[17]
strategy_dict['best_bid_price'] = data[18]
strategy_dict['best_offer_price'] = data[19]
strategy_dict['last_traded_quantity'] = data[20]
strategy_dict['target_price'] = data[21]
strategy_dict['expected_profit_per_lot'] = data[22]
strategy_dict['stop_loss_price'] = data[23]
strategy_dict['expected_loss_per_lot'] = data[24]
strategy_dict['total_margin'] = data[25]
strategy_dict['leg_no'] = data[26]
strategy_dict['status'] = data[27]
return(strategy_dict)
#CallBack functions to receive feeds
def on_ticks(ticks):
print(ticks)
ticks = parse_data(ticks)
print(ticks)
#Connect to receive feeds
sio.emit('join', script_code)
sio.on('stock', on_ticks)
#Unwatch from the stock
sio.emit("leave", script_code)
#Disconnect from the server
sio.emit("disconnect", "transport close")
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://breezeapi.icicidirect.com")
.method("GET", null)
.addHeader("User-Agent", "XYZABC")
.addHeader("user", "LZLAL")
.addHeader("token", "12i299")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://breezeapi.icicidirect.com");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
client.UserAgent = "XYZABC";
request.AddHeader("user", "LZLAL");
request.AddHeader("token", "12i299");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'strategy_date': '2025-02-07 14:29:29',
'modification_date': '2025-02-07 14:29:29',
'portfolio_id': '133444',
'call_action': 'Call Initiated',
'portfolio_name': 'Index Long Call',
'exchange_code': 'NFO',
'product_type': 'options',
'underlying': 'NIFTY ',
'expiry_date': '2025-02-13 00:00:00',
'option_type': 'call',
'strike_price': '23450',
'action': 'buy',
'recommended_price_from': '175',
'recommended_price_to': '178',
'minimum_lot_quantity': '75',
'last_traded_price': '181.45',
'best_bid_price': '181.5',
'best_offer_price': '181.9',
'last_traded_quantity': '23461.65',
'target_price': '240',
'expected_profit_per_lot': '4762.5',
'stop_loss_price': '144.9',
'expected_loss_per_lot': '2370',
'total_margin': '13350',
'leg_no': '1',
'status': 'active'}
The One Click F&O is a functionality which lets you chose from range of strategies curated by our award winning research team. It helps you save hours and hours of research and analysis time required to make a trading decision. With this function of One Click F&O, our research team does all the heavy lifting of research and analysis of over 170 F&O stocks with different expiries in real time and develop high probability winning opportunities for our customers. For the strategies available, you can either chose the desired strategy and place order in a single click or opt for customising by copying our recommended strategy to suit your requirement. You can also view margin required, maximum profit/loss, timeframe to hold the strategy before making a trade.
Get User ID and Session Token
The User Id and session Token can be obtained by decoding the 'session_token' from base64 , This session token obtained via get_customer_details API. An example is given in python
Connect to Websocket Server
Websocket endpoint is https://livefeeds.icicidirect.com/. Please make sure to pass the auth credentials and User-Agent in headers
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://livefeeds.icicidirect.com/ |
One Click Equity Stream
Oneclick Equity Strategy(iclick_2_gain)
var axios = require('axios');
var config = {
method: 'get',
url: 'https://breezeapi.icicidirect.com',
headers: {
'User-Agent': 'XYZABC',
'user': 'LZLAL',
'token': '12i299'
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import base64
import socketio
from datetime import datetime
#Get User ID and Session Token
session_key = "SESSION_TOKEN_FROM_CUSTOMER_DETAILS_API"
#e.g session_key = "QUYyOTUzMTM6NjY5ODc5NzY="
user_id, session_token = base64.b64decode(session_key.encode('ascii')).decode('ascii').split(":")
#e.g Decoded value - AF296713:66987976, after split user_id = AF295313, session_token = 6698797
# Python Socket IO Client
sio = socketio.Client()
script_code = ["i_click_2_gain"] #Subscribe more than one stock at a time
auth = {"user": user_id, "token": session_token}
sio.connect("https://livefeeds.icicidirect.com", headers={"User-Agent":"python-socketio[client]/socket"},
auth=auth, transports="websocket", wait_timeout=3)
if sio.connected:
print("Connection established successfully!")
else:
print("Failed to connect.")
tux_to_user_value = {
"orderFlow": {
"B": "Buy",
"S": "Sell",
"N": "NA"
},
"limitMarketFlag": {
"L": "Limit",
"M": "Market",
"S": "StopLoss"
},
"orderType": {
"T": "Day",
"I": "IoC",
"V": "VTC"
},
"productType": {
"F": "Futures",
"O": "Options",
"P": "FuturePlus",
"U": "FuturePlus_sltp",
"I": "OptionPlus",
"C": "Cash",
"Y": "eATM",
"B": "BTST",
"M": "Margin",
"T": "MarginPlus"
},
"orderStatus": {
"A": "All",
"R": "Requested",
"Q": "Queued",
"O": "Ordered",
"P": "Partially Executed",
"E": "Executed",
"J": "Rejected",
"X": "Expired",
"B": "Partially Executed And Expired",
"D": "Partially Executed And Cancelled",
"F": "Freezed",
"C": "Cancelled"
},
"optionType": {
"C": "Call",
"P": "Put",
"*": "Others"
},
}
# parse market depth
def parse_market_depth(self, data, exchange):
depth = []
counter = 0
for lis in data:
counter += 1
dict = {}
if exchange == '1':
dict["BestBuyRate-"+str(counter)] = lis[0]
dict["BestBuyQty-"+str(counter)] = lis[1]
dict["BestSellRate-"+str(counter)] = lis[2]
dict["BestSellQty-"+str(counter)] = lis[3]
depth.append(dict)
else:
dict["BestBuyRate-"+str(counter)] = lis[0]
dict["BestBuyQty-"+str(counter)] = lis[1]
dict["BuyNoOfOrders-"+str(counter)] = lis[2]
dict["BuyFlag-"+str(counter)] = lis[3]
dict["BestSellRate-"+str(counter)] = lis[4]
dict["BestSellQty-"+str(counter)] = lis[5]
dict["SellNoOfOrders-"+str(counter)] = lis[6]
dict["SellFlag-"+str(counter)] = lis[7]
depth.append(dict)
return depth
# parsing logic
def parse_data(data):
if data and type(data) == list and len(data) > 0 and type(data[0]) == str and "!" not in data[0]:
order_dict = {}
order_dict["sourceNumber"] = data[0] #Source Number
order_dict["group"] = data[1] #Group
order_dict["userId"] = data[2] #User_id
order_dict["key"] = data[3] #Key
order_dict["messageLength"] = data[4] #Message Length
order_dict["requestType"] = data[5] #Request Type
order_dict["messageSequence"] = data[6] #Message Sequence
order_dict["messageDate"] = data[7] #Date
order_dict["messageTime"] = data[8] #Time
order_dict["messageCategory"] = data[9] #Message Category
order_dict["messagePriority"] = data[10] #Priority
order_dict["messageType"] = data[11] #Message Type
order_dict["orderMatchAccount"] = data[12] #Order Match Account
order_dict["orderExchangeCode"] = data[13] #Exchange Code
if data[11] == '4' or data[11] == '5':
order_dict["stockCode"] = data[14] #Stock Code
order_dict["orderFlow"] = tux_to_user_value['orderFlow'].get(str(data[15]).upper(),str(data[15])) # Order Flow
order_dict["limitMarketFlag"] = tux_to_user_value['limitMarketFlag'].get(str(data[16]).upper(),str(data[16])) #Limit Market Flag
order_dict["orderType"] = tux_to_user_value['orderType'].get(str(data[17]).upper(),str(data[17])) #OrderType
order_dict["orderLimitRate"] = data[18] #Limit Rate
order_dict["productType"] = tux_to_user_value['productType'].get(str(data[19]).upper(),str(data[19])) #Product Type
order_dict["orderStatus"] = tux_to_user_value['orderStatus'].get(str(data[20]).upper(),str(data[20])) # Order Status
order_dict["orderDate"] = data[21] #Order Date
order_dict["orderTradeDate"] = data[22] #Trade Date
order_dict["orderReference"] = data[23] #Order Reference
order_dict["orderQuantity"] = data[24] #Order Quantity
order_dict["openQuantity"] = data[25] #Open Quantity
order_dict["orderExecutedQuantity"] = data[26] #Order Executed Quantity
order_dict["cancelledQuantity"] = data[27] #Cancelled Quantity
order_dict["expiredQuantity"] = data[28] #Expired Quantity
order_dict["orderDisclosedQuantity"] = data[29] # Order Disclosed Quantity
order_dict["orderStopLossTrigger"] = data[30] #Order Stop Loss Triger
order_dict["orderSquareFlag"] = data[31] #Order Square Flag
order_dict["orderAmountBlocked"] = data[32] # Order Amount Blocked
order_dict["orderPipeId"] = data[33] #Order PipeId
order_dict["channel"] = data[34] #Channel
order_dict["exchangeSegmentCode"] = data[35] #Exchange Segment Code
order_dict["exchangeSegmentSettlement"] = data[36] #Exchange Segment Settlement
order_dict["segmentDescription"] = data[37] #Segment Description
order_dict["marginSquareOffMode"] = data[38] #Margin Square Off Mode
order_dict["orderValidDate"] = data[40] #Order Valid Date
order_dict["orderMessageCharacter"] = data[41] #Order Message Character
order_dict["averageExecutedRate"] = data[42] #Average Exited Rate
order_dict["orderPriceImprovementFlag"] = data[43] #Order Price Flag
order_dict["orderMBCFlag"] = data[44] #Order MBC Flag
order_dict["orderLimitOffset"] = data[45] #Order Limit Offset
order_dict["systemPartnerCode"] = data[46] #System Partner Code
elif data[11] == '6' or data[11] == '7':
order_dict["stockCode"] = data[14] #stockCode
order_dict["productType"] = tux_to_user_value['productType'].get(str(data[15]).upper(),str(data[15])) #Product Type
order_dict["optionType"] = tux_to_user_value['optionType'].get(str(data[16]).upper(),str(data[16])) #Option Type
order_dict["exerciseType"] = data[17] #Exercise Type
order_dict["strikePrice"] = data[18] #Strike Price
order_dict["expiryDate"] = data[19] #Expiry Date
order_dict["orderValidDate"] = data[20] #Order Valid Date
order_dict["orderFlow"] = tux_to_user_value['orderFlow'].get(str(data[21]).upper(),str(data[21])) #Order Flow
order_dict["limitMarketFlag"] = tux_to_user_value['limitMarketFlag'].get(str(data[22]).upper(),str(data[22])) #Limit Market Flag
order_dict["orderType"] = tux_to_user_value['orderType'].get(str(data[23]).upper(),str(data[23])) #Order Type
order_dict["limitRate"] = data[24] #Limit Rate
order_dict["orderStatus"] = tux_to_user_value['orderStatus'].get(str(data[25]).upper(),str(data[25])) #Order Status
order_dict["orderReference"] = data[26] #Order Reference
order_dict["orderTotalQuantity"] = data[27] #Order Total Quantity
order_dict["executedQuantity"] = data[28] #Executed Quantity
order_dict["cancelledQuantity"] = data[29] #Cancelled Quantity
order_dict["expiredQuantity"] = data[30] #Expired Quantity
order_dict["stopLossTrigger"] = data[31] #Stop Loss Trigger
order_dict["specialFlag"] = data[32] #Special Flag
order_dict["pipeId"] = data[33] #PipeId
order_dict["channel"] = data[34] #Channel
order_dict["modificationOrCancelFlag"] = data[35] #Modification or Cancel Flag
order_dict["tradeDate"] = data[36] #Trade Date
order_dict["acknowledgeNumber"] = data[37] #Acknowledgement Number
order_dict["stopLossOrderReference"] = data[37] #Stop Loss Order Reference
order_dict["totalAmountBlocked"] = data[38] # Total Amount Blocked
order_dict["averageExecutedRate"] = data[39] #Average Executed Rate
order_dict["cancelFlag"] = data[40] #Cancel Flag
order_dict["squareOffMarket"] = data[41] #SquareOff Market
order_dict["quickExitFlag"] = data[42] #Quick Exit Flag
order_dict["stopValidTillDateFlag"] = data[43] #Stop Valid till Date Flag
order_dict["priceImprovementFlag"] = data[44] #Price Improvement Flag
order_dict["conversionImprovementFlag"] = data[45] #Conversion Improvement Flag
order_dict["trailUpdateCondition"] = data[45] #Trail Update Condition
order_dict["systemPartnerCode"] = data[46] #System Partner Code
return order_dict
exchange = str.split(data[0], '!')[0].split('.')[0]
data_type = str.split(data[0], '!')[0].split('.')[1]
if exchange == '6':
data_dict = {}
data_dict["symbol"] = data[0]
data_dict["AndiOPVolume"] = data[1]
data_dict["Reserved"] = data[2]
data_dict["IndexFlag"] = data[3]
data_dict["ttq"] = data[4]
data_dict["last"] = data[5]
data_dict["ltq"] = data[6]
data_dict["ltt"] = datetime.fromtimestamp(data[7]).strftime('%c')
data_dict["AvgTradedPrice"] = data[8]
data_dict["TotalBuyQnt"] = data[9]
data_dict["TotalSellQnt"] = data[10]
data_dict["ReservedStr"] = data[11]
data_dict["ClosePrice"] = data[12]
data_dict["OpenPrice"] = data[13]
data_dict["HighPrice"] = data[14]
data_dict["LowPrice"] = data[15]
data_dict["ReservedShort"] = data[16]
data_dict["CurrOpenInterest"] = data[17]
data_dict["TotalTrades"] = data[18]
data_dict["HightestPriceEver"] = data[19]
data_dict["LowestPriceEver"] = data[20]
data_dict["TotalTradedValue"] = data[21]
marketDepthIndex = 0
for i in range(22, len(data)):
data_dict["Quantity-"+str(marketDepthIndex)] = data[i][0]
data_dict["OrderPrice-"+str(marketDepthIndex)] = data[i][1]
data_dict["TotalOrders-"+str(marketDepthIndex)] = data[i][2]
data_dict["Reserved-"+str(marketDepthIndex)] = data[i][3]
data_dict["SellQuantity-"+str(marketDepthIndex)] = data[i][4]
data_dict["SellOrderPrice-"+str(marketDepthIndex)] = data[i][5]
data_dict["SellTotalOrders-"+str(marketDepthIndex)] = data[i][6]
data_dict["SellReserved-"+str(marketDepthIndex)] = data[i][7]
marketDepthIndex += 1
elif data_type == '1':
data_dict = {
"symbol": data[0],
"open": data[1],
"last": data[2],
"high": data[3],
"low": data[4],
"change": data[5],
"bPrice": data[6],
"bQty": data[7],
"sPrice": data[8],
"sQty": data[9],
"ltq": data[10],
"avgPrice": data[11],
"quotes": "Quotes Data"
}
# For NSE & BSE conversion
if len(data) == 21:
data_dict["ttq"] = data[12]
data_dict["totalBuyQt"] = data[13]
data_dict["totalSellQ"] = data[14]
data_dict["ttv"] = data[15]
data_dict["trend"] = data[16]
data_dict["lowerCktLm"] = data[17]
data_dict["upperCktLm"] = data[18]
data_dict["ltt"] = datetime.fromtimestamp(
data[19]).strftime('%c')
data_dict["close"] = data[20]
# For FONSE & CDNSE conversion
elif len(data) == 23:
data_dict["OI"] = data[12]
data_dict["CHNGOI"] = data[13]
data_dict["ttq"] = data[14]
data_dict["totalBuyQt"] = data[15]
data_dict["totalSellQ"] = data[16]
data_dict["ttv"] = data[17]
data_dict["trend"] = data[18]
data_dict["lowerCktLm"] = data[19]
data_dict["upperCktLm"] = data[20]
data_dict["ltt"] = datetime.fromtimestamp(
data[21]).strftime('%c')
data_dict["close"] = data[22]
else:
data_dict = {
"symbol": data[0],
"time": datetime.fromtimestamp(data[1]).strftime('%c'),
"depth": parse_market_depth(data[2], exchange),
"quotes": "Market Depth"
}
if exchange == '4' and len(data) == 21:
data_dict['exchange'] = 'NSE Equity'
elif exchange == '1':
data_dict['exchange'] = 'BSE'
elif exchange == '13':
data_dict['exchange'] = 'NSE Currency'
elif exchange == '4' and len(data) == 23:
data_dict['exchange'] = 'NSE Futures & Options'
elif exchange == '6':
data_dict['exchange'] = 'Commodity'
return data_dict
# CallBack functions to receive feeds
def on_ticks(data):
ticks = parse_data(data)
print(ticks)
sio.emit('join', script_code)
sio.on('stock', on_ticks)
sio.wait()
#Unwatch from the stock
sio.emit("leave", script_code)
#Disconnect from the server
sio.emit("disconnect", "transport close")
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://breezeapi.icicidirect.com")
.method("GET", null)
.addHeader("User-Agent", "XYZABC")
.addHeader("user", "LZLAL")
.addHeader("token", "12i299")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://breezeapi.icicidirect.com");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
client.UserAgent = "XYZABC";
request.AddHeader("user", "LZLAL");
request.AddHeader("token", "12i299");
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'stock_name': 'MAHINDRA & MAHINDRA LIMITED(MAHMAH)Margin-Buy',
'stock_code': 'MAHMAH',
'action_type': 'buy',
'expiry_date': '',
'strike_price': '',
'option_type': '',
'stock_description': 'Margin',
'recommended_price_and_date': '3065-3068,2025-01-02 08:55:02',
'recommended_price_from': '3065',
'recommended_price_to': '3068',
'recommended_date': '2025-01-02 08:55:02',
'target_price': '3098',
'sltp_price': '3050',
'part_profit_percentage': '0,0',
'profit_price': '0',
'exit_price': '0',
'recommended_update': '',
'iclick_status': 'open',
'subscription_type': 'iclick_2_gain'}
{'stock_name': 'POWER FINANCE CORPORATION LTD(POWFIN)Margin-Buy',
'stock_code': 'POWFIN',
'action_type': 'buy',
'expiry_date': '',
'strike_price': '',
'option_type': '',
'stock_description': 'Margin',
'recommended_price_and_date': '450-451,2025-01-02 09:37:01',
'recommended_price_from': '450',
'recommended_price_to': '451',
'recommended_date': '2025-01-02 09:37:01',
'target_price': '456',
'sltp_price': '447',
'part_profit_percentage': '0,0',
'profit_price': '0',
'exit_price': '0',
'recommended_update': ' ',
'iclick_status': 'open',
'subscription_type': 'iclick_2_gain'}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://livefeeds.icicidirect.com/ |
The One Click Equity Stream also known as iclick2gain stream is a functionality which lets you chose from range of strategies curated by our award winning research team. It helps you save hours and hours of research and analysis time required to make a trading decision. With this function of One Click Equity, our research team does all the heavy lifting of research and analysis of over Equity stocks with different expiries in real time and develop high probability winning opportunities for our customers.
For the strategies available, you can either chose the desired strategy and place order in a single click or opt for customising by copying our recommended strategy to suit your requirement. You can also view margin required, maximum profit/loss, timeframe to hold the strategy before making a trade.
Candle Stream
Candle Data LIVE(StreamLiveOHLCV)
This feature allows the user to stream OHLCV candle data in real time via websockets with lower latency. Candle intervals supported are 1 second, 1 minute, 5 minutes and 30 minutes. Below, is the set instructions to use this feature.
import base64
import socketio
#Get User ID and Session Token
session_key = "SESSION_TOKEN_FROM_CUSTOMER_DETAILS_API"
#e.g session_key = "QUYyOTUzMTM6NjY5ODc5NzY="
user_id, session_token = base64.b64decode(session_key.encode('ascii')).decode('ascii').split(":")
#e.g Decoded value - AF296713:66987976, after split user_id = AF295313, session_token = 6698797
# Python Socket IO Client
sio = socketio.Client()
auth = {"user": user_id, "token": session_token}
sio.connect("https://breezeapi.icicidirect.com/", socketio_path='ohlcvstream', headers={"User-Agent":"python-socketio[client]/socket"},
auth=auth, transports="websocket", wait_timeout=3)
# Script Code of Stock or Instrument e.g 4.1!1594, 1.1!500209 , 13.1!5023, 6.1!247457.
script_code = ["4.1!1594"] #Subscribe more than one stock at a time
#Channel name i.e 1SEC,1MIN,5MIN,30MIN
channel_name = "1SEC"
#CallBack functions to receive feeds
def on_ticks(ticks):
print(ticks)
#Connect to receive feeds
sio.emit('join', script_code)
sio.on(channel_name, on_ticks)
#Unwatch from the stock
sio.emit("leave", script_code)
#Disconnect from the server
sio.emit("disconnect", "transport close")
Sample Response Examples
For Equity -
NSE,NIFTY,18687.95,18687.95,18687.95,18687.95,0,2022-12-02 14:13:53,1SEC
For Derivatives -
Options - NFO,NIFTY,08-Dec-2022,18700.0,CE,120.5,120.5,120.5,120.5,2500,7592550,2022-12-02 14:10:14,1SEC
Futures - NFO,NIFTY,29-Dec-2022,18807.35,18807.35,18807.35,18807.35,0,11771450,2022-12-02 14:19:21,1SEC
Get User ID and Session Token
The User Id and session Token can be obtained by decoding the 'session_token' from base64 , This session token obtained via get_customer_details API. An example is given in python
Connect to Websocket Server
Websocket endpoint is https://breezeapi.icicidirect.com/ and the socket.io path is '/ohlcvstream'. Please make sure to pass the auth credentials and User-Agent in headers
Script Code of a Stock
Real streaming ohlcv data of a stock is obtained by subscribing to a particular stock using the Script Code of the stock. Script Code of a stock has the following pattern as given below.
'ExchangeType.Qualiflier!Scripid'
Examples of script code are 4.1!1594, 1.1!500209 , 13.1!5023, 6.1!247457
The Qualifier of an ExchangeType corresponds to a particular Exchange Code. Please refer to the table below
Qualifier | Exchange Code |
---|---|
4.1 | NSE,NFO |
Note:
1) Suffix '.1' in Qualifier refers to Exchange Quotes whereas '.2' refers to Market Depth. In Streaming OHLCV, we just need Exchange Quotes 2) Maximum 2000 scripts can be subscribed at a time in all OHLC and Live streaming.
For ScriptId, please refer to the CSV attachment in the link below
https://traderweb.icicidirect.com/Content/File/txtFile/ScripFile/StockScriptNew.csv
Column 'TK' in the CSV File refers to ScriptId.
Subscribe to OHLCV live stream of a particular Stock
To subscribe to a particular stock, we require to have the Script Code of a particular stocks. We can subscribe to more than one stock for a particular interval.
To subscribe to stock, we need to connect to a channels. Channels are divided as per the candle intervals. The channel names are as follows
Channel Name | Interval |
---|---|
1SEC | 1 second |
1MIN | 1 minute |
5MIN | 5 minutes |
30MIN | 30 minutes |
Streaming Response Data convention
The streaming respone Data has the following structure as shown in tables below. The response is a comma separated string.
For equity i.e NSE
Attribute | Description |
---|---|
exchange code | Exchange Code (NSE) |
stock code | Stock Code |
low | Low Price |
high | High Price |
open | Open Price |
close | Close Price |
volume | Traded Volume |
datetime | Date in YYYY-MM-DD HH:MM:SS format |
interval | 1SEC,1MIN,5MIN,30MIN |
For derivative options/futues i.e NFO,NDX,MCX
Attribute | Description |
---|---|
exchange code | Exchange Code (NFO) |
stock code | Stock Code |
expiry date | Date in YYYY-MM-DD format |
strike price | Strike Price (Only For Options) |
right type | Right Type (Only For Options) |
low | Low Price |
high | High Price |
open | Open Price |
close | Close Price |
volume | Traded Volume |
oi | Open Interest |
datetime | Date in YYYY-MM-DD HH:MM:SS format |
interval | 1SEC,1MIN,5MIN,30MIN |
Note: interval - 1SEC,1MIN,5MIN,30MIN (for 1second, 1minute, 5minutes, 30minutes respectively)
GTTOrder
GTTOrderPlacement
var axios = require('axios');
var data = JSON.stringify({
"stock_code": "ITC",
"exchange_code": "NSE",
"product": "cash",
"action": "buy",
"order_type": "market",
"quantity": "1",
"price": "263.15",
"validity": "ioc"
});
var config = {
method: 'post',
url: 'https://api.icicidirect.com/breezeapi/api/v1/gttorder',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/gttorder"
payload = json.dumps({
"exchange_code": "NFO",
"stock_code": "NIFTY",
"product": "options",
"quantity": "75",
"expiry_date": "2025-03-06T06:00:00.00Z",
"right": "put",
"strike_price": "22500",
"gtt_type": "cover_oco",
"fresh_order_action": "buy",
"fresh_order_price": "30",
"fresh_order_type": "limit",
"index_or_stock": "index",
"trade_date": "2025-03-03T06:00:00.00Z",
"order_details": [
{
"gtt_leg_type": "target",
"action": "sell",
"limit_price": "75",
"trigger_price": "72"
},
{
"gtt_leg_type": "stoploss",
"action": "sell",
"limit_price": "18",
"trigger_price": "22"
}
]
}
, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"stock_code\": \"ITC\",\r\n \"exchange_code\": \"NSE\",\r\n \"product\": \"cash\",\r\n \"action\": \"buy\",\r\n \"order_type\": \"market\",\r\n \"quantity\": \"1\",\r\n \"price\": \"263.15\",\r\n \"validity\": \"ioc\"\r\n}");
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/gttorder")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/gttorder");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""stock_code"": ""ITC"",
" + "\n" +
@" ""exchange_code"": ""NSE"",
" + "\n" +
@" ""product"": ""cash"",
" + "\n" +
@" ""action"": ""buy"",
" + "\n" +
@" ""order_type"": ""market"",
" + "\n" +
@" ""quantity"": ""1"",
" + "\n" +
@" ""price"": ""263.15"",
" + "\n" +
@" ""validity"": ""ioc""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success':
{'gtt_order_id': '2025020500001234',
'message': 'Your GTT Order Request Placed Successfully'},
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | POST |
URL | https://api.icicidirect.com/breezeapi/api/v1/gttorder |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
stock_code | String | "AXIBAN", "TATMOT" | Yes |
exchange_code | String | "NFO" | Yes |
product | String | "futures","options","optionplus","cash","btst","margin" | Yes |
action | String | "buy", "sell" | Yes |
quantity | String | Number of quantity to place the order | Yes |
expiry_date | String | ISO 8601 | Yes |
right | String | "call","put","others" | Yes |
strike_price | Integer | Numeric Currency | Yes |
gtt_type | String | "cover_oco" for three leg GTT order and "single" for single leg GTT order | Yes |
fresh_order_action | String | "buy","sell" | Yes |
fresh_order_price | String | -- | Yes |
fresh_order_type | String | "limit", "market" | Yes |
index_or_stock | String | "index" or "stock" | Yes |
trade_date | String | ISO 8601 | Yes |
gtt_leg_type | String | "stoploss","target" | Yes |
limit_price | String | -- | Yes |
trigger_price | String | -- | Yes |
GTTOrderBook
var axios = require('axios');
var data = JSON.stringify({
"exchange_code": "NSE",
"order_id": "20220601N100000019"
});
var config = {
method: 'get',
url: 'https://api.icicidirect.com/breezeapi/api/v1/gttorder',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/gttorder"
payload = json.dumps({
"exchange_code": "NFO",
"from_date": "2025-02-05T06:00:00.00Z",
"to_date": "2025-02-05T06:00:00.00Z"
}
, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/gttorder")
.method("GET", null)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/gttorder");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""exchange_code"": ""NSE"",
" + "\n" +
@" ""order_id"": ""20220601N100000019""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success': [{'order_details': [{'gtt_leg_type': None,
'action': 'Buy',
'trigger_price': 7.0,
'limit_price': 6.0,
'status': 'Cancelled',
'gtt_order_id': '2025020500001234'}],
'exchange_code': 'NFO',
'product_type': 'Options',
'stock_code': 'NIFTY',
'expiry_date': '06-Feb-2025',
'strike_price': 24000.0,
'right': 'Call',
'quantity': 75,
'index_or_stock': 'Index',
'gtt_type': 'Single',
'fresh_order_id': None,
'order_datetime': '05-FEB-2025 11:19:32'},
{'order_details': [{'gtt_leg_type': 'Target',
'action': 'Sell',
'trigger_price': 11.5,
'limit_price': 12.0,
'status': 'Cancelled',
'gtt_order_id': '2025020500001234'},
{'gtt_leg_type': 'Stoploss',
'action': 'Sell',
'trigger_price': 5.0,
'limit_price': 4.0,
'status': 'Cancelled',
'gtt_order_id': '2025020500001234'}],
'exchange_code': 'NFO',
'product_type': 'Options',
'stock_code': 'NIFTY',
'expiry_date': '06-Feb-2025',
'strike_price': 24000.0,
'right': 'Call',
'quantity': 75,
'index_or_stock': 'Index',
'gtt_type': 'Cover OCO',
'fresh_order_id': '202502052500001234',
'order_datetime': '05-FEB-2025 11:14:38'}],
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | GET |
URL | https://api.icicidirect.com/breezeapi/api/v1/gttorder |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
exchange_code | String | "NFO" | Yes |
from_date | String | ISO 8601 - Day should not be less than 10 days from to_date | Yes |
to_date | String | ISO 8601 - Day should not be more than 10 days from from_date | Yes |
GTTCancelOrder
var axios = require('axios');
var data = JSON.stringify({
"order_id": "20220601N100000019",
"exchange_code": "NSE"
});
var config = {
method: 'delete',
url: 'https://api.icicidirect.com/breezeapi/api/v1/gttorder',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/gttorder"
payload = json.dumps({
"gtt_order_id": "2025020500001234",
"exchange_code": "NFO"
}
, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("DELETE", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"order_id\": \"20220601N100000019\",\r\n \"exchange_code\": \"NSE\"\r\n}");
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/gttorder")
.method("DELETE", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/gttorder");
client.Timeout = -1;
var request = new RestRequest(Method.DELETE);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""order_id"": ""20220601N100000019"",
" + "\n" +
@" ""exchange_code"": ""NSE""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{
"Success": {
"order_id": "2025020500001234",
"message": "Your Order Cancelled successfully."
},
"Status": 200,
"Error": null
}
Request Information
Category | Value |
---|---|
HTTP Request | DELETE |
URL | https://api.icicidirect.com/breezeapi/api/v1/gttorder |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
gtt_order_id | String | Order Reference to cancel order | Yes |
exchange_code | String | "NFO" | Yes |
GTTModifyOrder
var axios = require('axios');
var data = JSON.stringify({
"order_id": "20220601N100000019",
"exchange_code": "NSE",
"quantity": "2",
"price": "263.15",
"stoploss": "",
"disclosed_quantity": "",
"order_type": "limit",
"validity": "",
"expiry_date": "",
"right": "",
"strike_price": ""
});
var config = {
method: 'put',
url: 'https://api.icicidirect.com/breezeapi/api/v1/gttorder',
headers: {
'Content-Type': 'application/json',
'X-Checksum': 'token ',
'X-Timestamp': '',
'X-AppKey': '',
'X-SessionToken': ''
},
data : data
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
import requests
import json
import hashlib
from datetime import datetime, timezone
customerDetail_url = "https://api.icicidirect.com/breezeapi/api/v1/customerdetails"
secret_key = "Your Secret_key goes here"
appkey = "Your App_Key goes here"
session_key = "Your Session_key goes here"
time_stamp = datetime.now(timezone.utc).isoformat()[:19] + '.000Z'
customerDetail_payload = json.dumps({
"SessionToken": session_key,
"AppKey": appkey
})
customerDetail_headers = {
'Content-Type': 'application/json',
}
customerDetail_response = requests.request("GET", customerDetail_url, headers=customerDetail_headers, data=customerDetail_payload)
data = json.loads(customerDetail_response.text)
session_token = data["Success"]["session_token"]
url = "https://api.icicidirect.com/breezeapi/api/v1/gttorder"
payload = json.dumps({
"exchange_code": "NFO",
"gtt_order_id" : "2025020500001234",
"gtt_type" : "ocox",
"order_details": [
{
"gtt_leg_type": "target",
"action": "sell",
"limit_price": "75",
"trigger_price": "72"
},
{
"gtt_leg_type": "stoploss",
"action": "sell",
"limit_price": "18",
"trigger_price": "22"
}
]
}
, separators=(',', ':'))
checksum = hashlib.sha256((time_stamp+payload+secret_key).encode("utf-8")).hexdigest()
headers = {
'Content-Type': 'application/json',
'X-Checksum': 'token '+ checksum,
'X-Timestamp': time_stamp,
'X-AppKey': appkey,
'X-SessionToken': session_token
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\r\n \"order_id\":\"20220601N100000019\",\r\n \"exchange_code\":\"NSE\",\r\n \"quantity\": \"2\",\r\n \"price\": \"263.15\",\r\n \"stoploss\":\"\",\r\n \"disclosed_quantity\":\"\",\r\n \"order_type\":\"limit\",\r\n \"validity\":\"\",\r\n \"expiry_date\":\"\",\r\n \"right\":\"\",\r\n \"strike_price\":\"\"\r\n}");
Request request = new Request.Builder()
.url("https://api.icicidirect.com/breezeapi/api/v1/gttorder")
.method("PUT", body)
.addHeader("Content-Type", "application/json")
.addHeader("X-Checksum", "token ")
.addHeader("X-Timestamp", "")
.addHeader("X-AppKey", "")
.addHeader("X-SessionToken", "")
.build();
Response response = client.newCall(request).execute();
var client = new RestClient("https://api.icicidirect.com/breezeapi/api/v1/gttorder");
client.Timeout = -1;
var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("X-Checksum", "token ");
request.AddHeader("X-Timestamp", "");
request.AddHeader("X-AppKey", "");
request.AddHeader("X-SessionToken", "");
var body = @"{
" + "\n" +
@" ""order_id"":""20220601N100000019"",
" + "\n" +
@" ""exchange_code"":""NSE"",
" + "\n" +
@" ""quantity"": ""2"",
" + "\n" +
@" ""price"": ""263.15"",
" + "\n" +
@" ""stoploss"":"""",
" + "\n" +
@" ""disclosed_quantity"":"""",
" + "\n" +
@" ""order_type"":""limit"",
" + "\n" +
@" ""validity"":"""",
" + "\n" +
@" ""expiry_date"":"""",
" + "\n" +
@" ""right"":"""",
" + "\n" +
@" ""strike_price"":""""
" + "\n" +
@"}";
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
Sample JSON Response
{'Success':
{'gtt_order_id': '2025020500001234',
'message': 'Order Modified Successfully'},
'Status': 200,
'Error': None}
Request Information
Category | Value |
---|---|
HTTP Request | PUT |
URL | https://api.icicidirect.com/breezeapi/api/v1/gttorder |
Body Parameters
Parameter | Data Type | Description | Mandatory |
---|---|---|---|
stock_code | String | "AXIBAN", "TATMOT" | Yes |
exchange_code | String | "NFO" | Yes |
product | String | "futures","options","optionplus","cash","btst","margin" | Yes |
action | String | "buy", "sell" | Yes |
quantity | String | Number of quantity to place the order | Yes |
expiry_date | String | ISO 8601 | Yes |
right | String | "call","put","others" | Yes |
strike_price | String | Numeric Currency | Yes |
gtt_type | String | "cover_oco" for three leg GTT order and "single" for single leg GTT order | Yes |
fresh_order_action | String | "buy","sell" | Yes |
fresh_order_price | String | -- | Yes |
fresh_order_type | String | "limit", "market" | Yes |
index_or_stock | String | "index" or "stock" | Yes |
trade_date | String | ISO 8601 | Yes |
gtt_leg_type | String | "stoploss","target" | Yes |
limit_price | String | -- | Yes |
trigger_price | String | -- | Yes |