Introduction
Trade smart API is a set of rest APIs that provide data required to build a complete investment and trading platform. Execute orders in real time, manage user portfolio, stream live market data (using Websocket), and more, with the easy to understand API collection.
To Use Swing API you should be logged in to either swing App or Swing Web (You should not logged out)
Encryption Decryption
For the purpose of encryption/decryption we're using the OpenSSL library. The cipher method used is AES-256-CBC
Encryption & Decryption
Encryption :
The stringified JSON request can be encrypted using openssl_encrypt function with the KEY (provided by VNS).
OPENSSL_RAW_DATA = 0
$request_string should be appended with any 16 digit random number.
Example :
KEY – to be provided by VNS
IV = openssl_random_pseudo_bytes(16);
$request_string = '1234567890123456'.$request_string;
$encrypted_data = openssl_encrypt($request_string, 'aes-256-cbc', KEY, 0, IV);
return $encrypted_data;
Decryption :
The decoded response can then be decrypted using openssl_decrypt function with the KEY provided by VNS.
OPENSSL_RAW_DATA = 0
Remove first 16 digit from decrypted value
Example :
KEY – to be provided by VNS
IV = openssl_random_pseudo_bytes(16);
$decrypted = openssl_decrypt($response["data"], 'aes-256-cbc', KEY, 0, IV);
if ($decrypted === false) {
$response = false;
} else {
$decrypted = substr($decrypted,16);
$response = $decrypted;
}
(Note : JWT Token recieved in Validate Answer API has been used in header as authorization bearer for all Post Login APIs.)
Fund Allocation API
Allows to fetch details of account balance, allocated amount, used margin etc prior to allocating funds
Get Fund details
Allows to get available funds in user account
Requires authentication
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/withdrawable-data" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{"uid":"test123","actid":"test123"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/withdrawable-data"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"uid": "test123",
"actid": "test123"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": {
"EquityData": {
"totalBal": "0.00",
"mtm": "-0.00",
"usedMargin": "0.00",
"availableMargin": "0.00",
"spanmargin": "0.00",
"exposuremargin": "0.00",
"viewrealizedmtom": "0.00",
"realisedmtom": "0.00",
"viewunrealizedmtom": "0.00",
"unrealisedmtom": "0.00",
"varmargin": "0.00",
"elm": "0.00",
"status": 3
},
"CommData": {
"totalBal": "0.00",
"mtm": "-0.00",
"usedMargin": "0.00",
"availableMargin": "0.00",
"spanmargin": "0.00",
"exposuremargin": "0.00",
"viewrealizedmtom": "0.00",
"realisedmtom": "0.00",
"viewunrealizedmtom": "0.00",
"unrealisedmtom": "0.00",
"varmargin": "0.00",
"elm": "0.00",
"status": 3
}
},
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"'actid'": "Client Id field is required"
}
}
HTTP Request
POST api/v1/withdrawable-data
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
uid |
string | required | The client id of the user. |
actid |
string | required | The client id of the user. |
Login API
APIs for managing user login
Login Token
API to get login token
Note : encryption request is created by Encryption process.
data string for encrypted string : {"uid":"test123","appId":"test","password":"test"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/login-token" \
-H "Content-Type: application/json" \
-d '{"data":"ENCRYPTED_STRING","app":"APPLICATION_ID"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/login-token"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
let body = {
"data": "ENCRYPTED_STRING",
"app": "APPLICATION_ID"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": {
"s_prdt_ali": "BO:BO||CNC:CNC||CO:CO||MIS:MIS||NRML:NRML",
"brkname": "",
"email_id": "",
"client_name": "",
"order_type": "market",
"product_cash": "delivery",
"product_derivative": "overnight",
"enabled_exch": [
"BSE",
"CDS",
"MCX",
"NCDEX",
"NSE",
"NFO"
],
"session_mw": [],
"user_session_id": "",
"theme": 0,
"jwt_token": ""
},
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"uid": "uid field is required."
}
}
HTTP Request
POST api/v1/login-token
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
uid |
string | required | The client id of the user. |
appId |
string | required | The application Id(Provided by VNS). |
password |
string | required | One time pass key generated from Swing Web Application by customer. |
Market Watch API
APIs for managing Market Watch
Scrip Master
This API returns the details of the scrips/contracts based on the exchange passed
Requires authentication
Note : encryption request is created by Encryption process
data string for encrypted string : {"exchange":"cash"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/script-mw" \
-H "Content-Type: application/json" \
-H "authorization : Bearer {your_access_token}" \
-d '{"data":"ENCRYPTED_STRING","app":"APPLICATION_ID"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/script-mw"
);
let headers = {
"Content-Type": "application/json",
"authorization":"Bearer {your_access_token}",
};
let body = {
"data": "ENCRYPTED_STRING",
"app": "APPLICATION_ID"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": {
"msg": "Scrip found.",
"Result": "OK",
"responseData": [
{
"Exch": "BSE",
"Symbol": "523395",
"Tsym": "3MINDIA",
"Series": "A",
"Instrument_Type": null,
"Expiry_Date": null,
"Strike_Price": null,
"Option_Type": null,
"Scripname": "3M INDIA LTD."
},
{
"Exch": "BSE",
"Symbol": "524208",
"Tsym": "AARTIIND",
"Series": "A",
"Instrument_Type": null,
"Expiry_Date": null,
"Strike_Price": null,
"Option_Type": null,
"Scripname": "AARTI INDUSTRIES LTD."
},
{
"Exch": "BSE",
"Symbol": "541988",
"Tsym": "AAVAS",
"Series": "A",
"Instrument_Type": null,
"Expiry_Date": null,
"Strike_Price": null,
"Option_Type": null,
"Scripname": "AAVAS Financiers Limited"
},
{
"Exch": "BSE",
"Symbol": "500488",
"Tsym": "ABBOTINDIA",
"Series": "A",
"Instrument_Type": null,
"Expiry_Date": null,
"Strike_Price": null,
"Option_Type": null,
"Scripname": "ABBOTT INDIA LTD."
},
{
"Exch": "BSE",
"Symbol": "540691",
"Tsym": "ABCAPITAL",
"Series": "A",
"Instrument_Type": null,
"Expiry_Date": null,
"Strike_Price": null,
"Option_Type": null,
"Scripname": "Aditya Birla Capital Ltd"
}
]
},
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 2015,
"error_msg": "Please enter proper exchange name."
}
HTTP Request
POST api/v1/script-mw
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
exchange |
string | required | The exchange of the scrip(i.e. all,cash,com,cur,fno). |
Order API
APIs for managing order
Order Book
API to get order book
Requires authentication
Note : encryption request is created by Encryption process
data string for encrypted string : {"uid":"test123"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/order-book" \
-H "Content-Type: application/json" \
-H "authorization : Bearer {your_access_token}" \
-d '{"data":"ENCRYPTED_STRING","app":"APPLICATION_ID"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/order-book"
);
let headers = {
"Content-Type": "application/json",
"authorization":"Bearer {your_access_token}",
};
let body = {
"data": "ENCRYPTED_STRING",
"app": "APPLICATION_ID"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": [
{
"OrderUserMessage": "",
"Cancelqty": 0,
"AlgoCategory": "NA",
"modifiedBy": "--",
"customText": "NA",
"RefLmtPrice": 0,
"Mktpro": "NA",
"Qty": 1,
"ExpSsbDate": "NA",
"Trgprc": "00.00",
"ExchOrdID": "NA",
"COPercentage": 0,
"exchangeuserinfo": "1111111111111100",
"RequestID": "1",
"usecs": "998953",
"orderentrytime": "May 21 2020 11:38:45",
"Avgprc": "00.00",
"Fillshares": 0,
"optionType": "XX",
"ordergenerationtype": "--",
"iSinceBOE": 1590041325,
"InstName": "",
"Nstordno": "200521000000022",
"Unfilledsize": 0,
"Usercomments": "NA",
"mpro": "1",
"ticksize": "5",
"strikePrice": "00.00",
"OrderedTime": "21\/05\/2020 11:38:45",
"panNo": "AJAPT0575E",
"defmktproval": "3",
"orderCriteria": "NA",
"ExchConfrmtime": "--",
"Minqty": 0,
"AlgoID": "NA",
"ordersource": "NEST_REST_WEB",
"sipindicator": "N",
"decprec": "2",
"series": "A",
"PriceNumerator": "1",
"Ordvaldate": "NA",
"Trsym": "SBIN",
"accountId": "UTEST17",
"Dscqty": 0,
"BrokerClient": "--",
"reporttype": "failure",
"remarks": "--",
"Scripname": "STATE BANK OF INDIA",
"Prc": "180.00",
"Exchange": "BSE",
"Sym": "SBIN",
"token": "500112",
"Prctype": "L",
"RejReason": "Rejected due to Algo order without Algo id",
"orderAuthStatus": "",
"GeneralDenomenator": "1",
"Validity": "DAY",
"GeneralNumerator": "1",
"stat": "Ok",
"multiplier": "1",
"bqty": "1",
"noMktPro": "1",
"discQtyPerc": "10",
"Status": "rejected",
"PriceDenomenator": "1",
"SyomOrderId": "",
"Trantype": "B",
"ExpDate": "NA",
"marketprotectionpercentage": "--",
"Pcode": "CNC",
"Exseg": "bse_cm",
"user": "UTEST17"
}
],
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"uid": "uid field is required"
}
}
HTTP Request
POST api/v1/order-book
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
uid |
string | required | The client id of the user. |
Place Order
Requires authentication
Note : encryption request is created by Encryption process
data string for encrypted string : {"client_id":"test123","exchange":"NSE","TokenNo":"test123","quantity":0, "validity":"Day","disclosed_quantity":"1","price":100,"order_tag":"WEB", "target_price":10,"stoploss_bo_co":2,"trailing_ticks":1,"trigger_price":101, "tradingsymbol":"test123","transaction_type":"B","order_type":"LIMIT", "product":"DELIVERY","AMO":"NO"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/place-order" \
-H "Content-Type: application/json" \
-H "authorization : Bearer {your_access_token}" \
-d '{"data":"ENCRYPTED_STRING","app":"APPLICATION_ID"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/place-order"
);
let headers = {
"Content-Type": "application/json",
"authorization":"Bearer {your_access_token}",
};
let body = {
"data": "ENCRYPTED_STRING",
"app": "APPLICATION_ID"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": {
"NOrdNo": "200521000000019",
"stat": "Ok"
},
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"'exch'": "'exch field is required"
}
}
HTTP Request
POST api/v1/place-order
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
client_id |
string | required | The client id of the user. |
exchange |
string | required | The exchange of the script(BSE,MCX,CDS,NSE,NFO). |
TokenNo |
string | optional | Required for BO - The Token No of the script. |
quantity |
integer | required | The quantity of share selected by the user. |
validity |
string | required | Order Validity (Validity has two options available as of now. You can make it Day or IOC. Day means the order is valid for the whole day and if there's a matching order it will be executed. IOC means “immediate or cancel” - if this is chosen, the order will be executed immediately or canceled if there is no match). |
disclosed_quantity |
Integer | optional | The disclosed quantity by the user. |
price |
float | required | The Price of the share. |
order_tag |
string | required | The Order source(WEB). |
target_price |
float | optional | Required for BO - The Square off value . |
stoploss_bo_co |
float | optional | optional Required for BO and CO - Stop Loss Value . |
trailing_ticks |
integer | optional | Optional for BO - Trailing Stop Loss flag . |
trigger_price |
float | optional | Required for SL-M and SL-L. The Trigger Price of the script. |
tradingsymbol |
string | required | Trading symbol of script |
transaction_type |
string | required | Transaction type (B for Buy/S for Sell) |
order_type |
string | required | Product type (limit/market/sl-l/sl-m) |
product |
string | required | Product Code (delivery/intraday/overnight/bo/co) |
AMO |
string | required | After market order(YES/NO) |
View Order History
API to get order history
Requires authentication
Note : encryption request is created by Encryption process
data string for encrypted string : {"uid":"test123","NOrdNo":"200521000000038"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/order-history" \
-H "Content-Type: application/json" \
-H "authorization : Bearer {your_access_token}" \
-d '{"data":"ENCRYPTED_STRING","app":"APPLICATION_ID"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/order-history"
);
let headers = {
"Content-Type": "application/json",
"authorization":"Bearer {your_access_token}",
};
let body = {
"data": "ENCRYPTED_STRING",
"app": "APPLICATION_ID"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": [
{
"OrderUserMessage": "",
"Trsym": "HDFC-EQ",
"PriceNumerator": "1",
"modifiedBy": "--",
"reporttype": "status",
"customerfirm": "C",
"symbolname": "HDFC",
"Prc": "1633.00",
"Qty": 1,
"Action": "B",
"exchangetimestamp": "21-May-2020 12:10:37",
"legorderindicator": "",
"nestreqid": "1",
"Ordtype": "L",
"exchange": "NSE",
"filldateandtime": "-- --",
"GeneralDenomenator": "1",
"ordergenerationtype": "--",
"exchangeorderid": "1100000000001165",
"productcode": "CNC",
"unfilledSize": 1,
"triggerprice": "0.0",
"GeneralNumerator": "1",
"averageprice": "0.0",
"ExchTimeStamp": "21\/05\/2020 11:57:58",
"stat": "Ok",
"bqty": 1,
"filledShares": 0,
"Status": "open",
"duration": "DAY",
"PriceDenomenator": "1",
"rejectionreason": "--",
"nestordernumber": "200521000000038",
"scripname": "HDFC LTD",
"disclosedqty": "0",
"ordersource": "NEST_REST_WEB"
}
],
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"'NOrdNo'": "'NOrdNo' field is required"
}
}
HTTP Request
POST api/v1/order-history
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
uid |
string | required | The client id of the user. |
NOrdNo |
string | required | The order number . |
Cancel Order
API to cancel order
Requires authentication
Note : encryption request is created by Encryption process
data string for encrypted string : {"uid":"test123","NestOrd":"200521000000038","sTradeSymbo":"HDFC-EQ","sExch":"NSE"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/cancel-order" \
-H "Content-Type: application/json" \
-H "authorization : Bearer {your_access_token}" \
-d '{"data":"ENCRYPTED_STRING","app":"APPLICATION_ID"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/cancel-order"
);
let headers = {
"Content-Type": "application/json",
"authorization":"Bearer {your_access_token}",
};
let body = {
"data": "ENCRYPTED_STRING",
"app": "APPLICATION_ID"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": {
"msg": "",
"status": 3,
"data": {
"Result": " NEST Order Number :200521000000038",
"stat": "Ok"
}
},
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"uid": "uid field is required"
}
}
HTTP Request
POST api/v1/cancel-order
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
uid |
string | required | The client id of the user. |
NestOrd |
string | required | The Nest Order number . |
sTradeSymbo |
string | required | The Trade Symbol of script. |
sExch |
string | required | The exchnge of script . |
Order Modification
Api to modify order
Requires authentication
Note : encryption request is created by Encryption process
data string for encrypted string : {"client_id":"test123","Nstordno":"010101","exchange":"NSE","tradingsymbol":"HDFC-EQ","transaction_type":"B","order_type":"LIMIT","price":123, "quantity":10,"target_price":102,"validity":"Day","Filledqty":0,"product":"DELIVERY"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/modify-order" \
-H "Content-Type: application/json" \
-H "authorization : Bearer {your_access_token}" \
-d '{"data":"ENCRYPTED_STRING","app":"APPLICATION_ID"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/modify-order"
);
let headers = {
"Content-Type": "application/json",
"authorization":"Bearer {your_access_token}",
};
let body = {
"data": "ENCRYPTED_STRING",
"app": "APPLICATION_ID"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": {
"Result": " NEST Order Number :200521000000055",
"stat": "Ok"
},
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"acctId": "Client Id field is required"
}
}
HTTP Request
POST api/v1/modify-order
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
client_id |
string | required | The client id of the user. |
Nstordno |
string | required | The Nest Order number. |
exchange |
string | required | The exchange of script. |
tradingsymbol |
string | required | Trading symbol of script. |
transaction_type |
string | required | Transaction type (B for Buy/S for Sell) |
order_type |
string | required | Product type (LIMIT/MARKET/SL-L/SL-M) |
price |
float | required | The price of the script. |
quantity |
integer | required | The quantity of the script. |
target_price |
float | required | The target price of the script. |
validity |
string | required | Order Validity (Validity has two options available as of now. You can make it Day or IOC. Day means the order is valid for the whole day and if there's a matching order it will be executed. IOC means “immediate or cancel” - if this is chosen, the order will be executed immediately or canceled if there is no match). |
Filledqty |
integer | optional | Execution quantity (the number of shares bought or sold on a single trade). |
product |
string | required | Product Code (DELIVERY/INTRADAY/OVERNIGHT/BO/CO) |
Trade Book
Api to get Trade book
Requires authentication
Note : encryption request is created by Encryption process
data string for encrypted string : {"uid":"test123"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/trade-book" \
-H "Content-Type: application/json" \
-H "authorization : Bearer {your_access_token}" \
-d '{"data":"ENCRYPTED_STRING","app":"APPLICATION_ID"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/trade-book"
);
let headers = {
"Content-Type": "application/json",
"authorization":"Bearer {your_access_token}",
};
let body = {
"data": "ENCRYPTED_STRING",
"app": "APPLICATION_ID"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": [
{
"series": "EQ",
"AvgPrice": "1633.00",
"PriceNumerator": "1",
"accountId": "UTEST17",
"Custofrm": "C",
"Ordduration": "DAY",
"AlgoCategory": "01",
"Filltime": "12:40:15",
"BrokerClient": "--",
"expdate": "NA",
"remarks": "--",
"symbolname": "HDFC",
"Qty": 1,
"ReportType": "fill",
"Exchange": "NSE",
"Time": "21\/05\/2020 12:27:35",
"Prctype": "L",
"usecs": "819057",
"Filldate": "21-May-2020",
"NOReqID": "1",
"Exchtime": "21-May-2020 12:40:15",
"optiontype": "XX",
"GeneralDenomenator": "1",
"ordergenerationtype": "--",
"strikeprice": "00.00",
"FillLeg": 1,
"iSinceBOE": 1590044255,
"Nstordno": "200521000000065",
"Tsym": "HDFC-EQ",
"GeneralNumerator": "1",
"Expiry": "NA",
"companyname": "HDFC LTD",
"bqty": 1,
"FillId": "50000666",
"stat": "Ok",
"PriceDenomenator": "1",
"Filledqty": 1,
"panNo": "AJAPT0575E",
"Symbol": "1330",
"Trantype": "B",
"posflag": "false",
"Price": "1633.00",
"Exchseg": "nse_cm",
"ExchordID": "1100000000001465",
"Pcode": "BO",
"Minqty": 0,
"user": "UTEST17",
"AlgoID": "37277",
"Fillqty": 1
}
],
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"uid": " uid field is required"
}
}
HTTP Request
POST api/v1/trade-book
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
uid |
string | required | The client id of the user. |
Exit Cover Order
Api to get Exit Cover order
Requires authentication
Note : encryption request is created by Encryption process
data string for encrypted string : {"uid":"test123","NestOrd":"120102"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/exit-cover-order" \
-H "Content-Type: application/json" \
-H "authorization : Bearer {your_access_token}" \
-d '{"data":"ENCRYPTED_STRING","app":"APPLICATION_ID"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/exit-cover-order"
);
let headers = {
"Content-Type": "application/json",
"authorization":"Bearer {your_access_token}",
};
let body = {
"data": "ENCRYPTED_STRING",
"app": "APPLICATION_ID"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": {
"Result": "Success",
"stat": "Ok"
},
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"uid": " uid field is required"
}
}
HTTP Request
POST api/v1/exit-cover-order
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
uid |
string | required | The client id of the user. |
NestOrd |
string | required | The Nest Order . |
Exit Bracket Order
Api to exit bracket order
Requires authentication
Note : encryption request is created by Encryption process
data string for encrypted string : {"uid":"test123","NestOrd":"120102","SyomOrderId":"1254123","status":"open"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/exit-bracket-order" \
-H "Content-Type: application/json" \
-H "authorization : Bearer {your_access_token}" \
-d '{"data":"ENCRYPTED_STRING","app":"APPLICATION_ID"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/exit-bracket-order"
);
let headers = {
"Content-Type": "application/json",
"authorization":"Bearer {your_access_token}",
};
let body = {
"data": "ENCRYPTED_STRING",
"app": "APPLICATION_ID"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": {
"stat": "Ok"
},
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"nestordernumber": "nestordernumber field is required"
}
}
HTTP Request
POST api/v1/exit-bracket-order
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
uid |
string | required | The client id of the user. |
NestOrd |
string | required | The Nest Order . |
SyomOrderId |
string | required | Symbol Order Id . |
status |
string | required | Status of the order from Order book . |
Get Place Order View
Requires authentication
Note : encryption request is created by Encryption process
data string for encrypted string : {"uid":"test123","TokenNo":"010101","Ttranstyp":"B","exch":"BSE","Tsym":"SBIN", "insType":"aut","order_type":"limit","product_cash":"delivery"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/get-place-order-view" \
-H "Content-Type: application/json" \
-H "authorization : Bearer {your_access_token}" \
-d '{"data":"ENCRYPTED_STRING","app":"APPLICATION_ID"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/get-place-order-view"
);
let headers = {
"Content-Type": "application/json",
"authorization":"Bearer {your_access_token}",
};
let body = {
"data": "ENCRYPTED_STRING",
"app": "APPLICATION_ID"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": {
"uid": "UTEST17",
"token": "500112",
"Ttranstype": "B",
"exch": "BSE",
"Tsym": "SBIN",
"order_type": "limit",
"product_cash": "delivery",
"insType": "",
"tick_size": "0.05",
"lot_qty": "0 0"
},
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"order_type": "order type field is required"
}
}
HTTP Request
POST api/v1/get-place-order-view
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
uid |
string | required | The client id of the user. |
TokenNo |
string | required | The Token No of the script. |
Ttranstyp |
string | required | Transaction type. |
exch |
string | required | The exchange of the script. |
Tsym |
string | required | Trading symbol of script. |
insType |
string | optional | Instrument type. |
order_type |
string | optional | Order type . |
product_cash |
string | optional | Product Cash . |
Portfolio API
APIs for managing portfolio
View Holdings
Api to get holdings
Requires authentication
Note : encryption request is created by Encryption process
data string for encrypted string : {"uid":"test123","acctid":"test123"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/view-holdings" \
-H "Content-Type: application/json" \
-H "authorization : Bearer {your_access_token}" \
-d '{"data":"ENCRYPTED_STRING","app":"APPLICATION_ID"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/view-holdings"
);
let headers = {
"Content-Type": "application/json",
"authorization":"Bearer {your_access_token}",
};
let body = {
"data": "ENCRYPTED_STRING",
"app": "APPLICATION_ID"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": {
"clientid": "UTEST17",
"Totalval": {
"TotalMCXHoldingValue": "0.00",
"TotalCSEHoldingValue": "0.00",
"TotalBSEHoldingValue": "464520.00",
"TotalNSEHoldingValue": "551293.00",
"TotalYSXHoldingValue": "0.00"
},
"HoldingVal": [
{
"WHqty": "0",
"SellableQty": "100",
"CUqty": "100",
"hsflag": "Y",
"CSEHOldingValue": "0.00",
"Token5": "0",
"Btst": "0",
"Token3": "0",
"Token4": "0",
"Token1": "0",
"Token2": "512093",
"BuyQty": "0",
"WCqty": "0",
"DaysMTM": "0",
"LTnse": "0.00",
"Ltp": "0.00",
"Ttrind": "N",
"Mcxsxcmsym": "0",
"Bsetsym": "CRANESSOFT",
"Price": 40.85,
"Haircut": "30.00",
"Series": "---",
"Usedqty": "0",
"HUqty": "0",
"Tprod": "MIS",
"Scripcode": "512093",
"NSEHOldingValue": 0,
"Series1": "X",
"Nsetsym": "0",
"Csetsym": "0",
"Colqty": "0",
"Exch1": "0",
"Exch2": "bse_cm",
"Exch3": "0",
"Exch4": "0",
"csflag": "Y",
"Exch5": "0",
"BSEHOldingValue": 0,
"Ysxtsym": "0",
"LTmcxsxcm": "0.00",
"Coltype": "LT",
"LTPValuation": "0",
"ExchSeg4": null,
"ExchSeg3": null,
"ExchSeg2": "BSE",
"YSXHOldingValue": "0.00",
"ExchSeg1": null,
"ExchSeg5": null,
"LTbse": "0.00",
"Holdqty": "100",
"LTysx": "0.00",
"LTcse": "0.00",
"MCXHOldingValue": "0.00",
"Pcode": "CNC",
"isin": "INE234B01023",
"pnl": -4085,
"pnl_perc": "-100.00",
"amt_invested": 4085,
"current_value": 0,
"pcode_view": "delivery"
}
],
"stat": "Ok",
"total_invested": 257199.84,
"current_value": 621673,
"pnl_perc": "141.71"
},
"error_code": "",
"error_msg": ""
}
Example response (200):
{
"status": false,
"data": "",
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"'acctid'": "'acctid field is required."
}
}
HTTP Request
POST api/v1/view-holdings
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
uid |
string | required | The client id of the user. |
acctid |
string | required | The client id of the user. |
View Positions
Api to get positions
Requires authentication
Note : encryption request is created by Encryption process
data string for encrypted string : {"uid":"test123","acctid":"test123"}
Example request:
curl -X POST \
"https://api.swing.tradesmartonline.in/api/v1/view-postion" \
-H "Content-Type: application/json" \
-H "authorization : Bearer {your_access_token}" \
-d '{"uid":"test123","acctid":"test123"}'
const url = new URL(
"https://api.swing.tradesmartonline.in/api/v1/view-postion"
);
let headers = {
"Content-Type": "application/json",
"authorization":"Bearer {your_access_token}",
};
let body = {
"uid": "test123",
"acctid": "test123"
}
fetch(url, {
method: "POST",
headers: headers,
body: body
})
.then(response => response.json())
.then(json => console.log(json));
Example response (200):
{
"status": true,
"data": {
"response_data": [
{
"Fillsellqty": "0",
"realisedprofitloss": "0.00",
"NetSellavgprc": "0.00",
"Opttype": "XX",
"Exchangeseg": "nse_cm",
"Netqty": "10",
"CFBuyavgprc": "0.0000",
"sSqrflg": "Y",
"netbuyamt": "11,051.50",
"Tsym": "ACC-EQ",
"Netamt": "-11,051.50",
"netsellqty": "0",
"Sqty": "0",
"FillsellamtCF": "0.00",
"NetBuyavgprc": "1,105.15",
"MtoM": "-1.50",
"Symbol": "ACC",
"posflag": "true",
"Series": "EQ",
"netSellamt": "0.00",
"Fillbuyamt": "11,051.50",
"unrealisedprofitloss": "-1.50",
"PriceNumerator": "1",
"Type": "DAY1",
"netbuyqty": "10",
"BLQty": 1,
"Fillbuyqty": "10",
"CFsellqty": "0",
"s_NetQtyPosConv": "N",
"CFbuyqty": "0",
"Sellavgprc": "0.0000",
"Bqty": "10",
"Exchange": "NSE",
"CFSellavgprc": "0.0000",
"Fillsellamt": "0.00",
"actid": "UTEST17",
"GeneralDenomenator": "1",
"Instname": "NA",
"discQty": "10",
"Expdate": "NA",
"LTP": 1105,
"Buyavgprc": "1,105.1500",
"Token": "22",
"GeneralNumerator": "1",
"companyname": "ACC LIMITED",
"stat": "Ok",
"PriceDenomenator": "1",
"FillbuyamtCF": "0.00",
"Stikeprc": "0",
"BEP": "1,105.15",
"Pcode": "CO",
"pcode_view": "CO",
"mtm": "-1.50",
"day_net_value": "-11,051.5000",
"cf_net_qty": 0,
"cf_net_value": "0",
"mtm_new": "-1.5000",
"avg_price": "1,105.1500",
"realized_pnl": 0,
"unrealized_pnl": -1.5000000000009095,
"p_l_percent": "-0.14"
}
],
"total_mtm": "6021.70",
"realized_mtm": "-7764.57"
},
"error_code": "",
"error_msg": ""
}
Example response (200):
{
"status": false,
"data": "",
"error_code": "",
"error_msg": ""
}
Example response (400):
{
"status": false,
"data": "",
"error_code": 400,
"error_msg": {
"actid": "actid field is required."
}
}
HTTP Request
POST api/v1/view-postion
Body Parameters
Parameter | Type | Status | Description |
---|---|---|---|
uid |
string | required | The client id of the user. |
acctid |
string | required | The client id of the user. |