Create Basket Order
POST basket/createOrder
The create order API is used to add a new order to a specified basket. This operation allows users to specify the details of the order, including the product, quantity, and any special instructions.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
basketID | string | true | The ID of the basket to which the order needs to be added. |
symbolName | string | true | The stock symbol to be traded. |
exchange | string | true | The exchange where the stock is listed. |
transactionType | string | true | Indicates whether the transaction is BUY or SELL. |
orderType | string | true | Specifies the order type (e.g., L - Limit, SL - Stop Limit). |
orderValidity | string | true | Specifies the order's validity duration. |
productType | string | true | Specifies the product type (e.g., CNC - Cash and Carry, CO - Cover Order, BO - Bracket Order, NRML, MIS). |
quantity | string | true | The number of shares or units to be traded. |
disclosedQuantity | string | true | The quantity to be disclosed in the market, which can be equal to or less than the order quantity. |
price | string | false | The execution price for the order. Mandatory for L or SL orders. |
priceType | string | false | Applicable only for BO orders. Valid options: LTP (Last Traded Price) or ATP (Average Traded Price). Default is LTP. |
squareOffValue | string | false | The value used to square off the position automatically. Applicable only for BO orders. |
stopLossValue | string | false | The stop-loss value. Applicable only for BO orders. |
valueType | string | false | The type of value for Stop Loss and Square Off. Valid options: Absolute or Ticks. Default is Absolute. Applicable only for BO orders. |
trailingStopLoss | string | false | Incremental value as a percentage of the price change. The trailing stop loss moves with price increases but stays fixed if the price drops. Applicable only for BO orders. |
triggerPrice | string | false | The price at which the order will be triggered. Applicable for SL orders. |
Sample Request Body
json
requestBody={
"basketID": "88",
"symbolName": "INFY",
"exchange": "NSE",
"transactionType": "BUY",
"orderType": "L",
"orderValidity": "DAY",
"productType": "MIS",
"quantity": "150",
"disclosedQuantity": "",
"price":"1800",
"triggerPrice": "1925.30"
}json
requestBody={
"basketID": "88",
"symbolName": "HDFCBANK",
"exchange": "NSE",
"transactionType": "BUY",
"orderType": "L",
"orderValidity": "DAY",
"productType": "CNC",
"quantity": "50",
"disclosedQuantity": "50",
"price": "1600"
}json
requestBody={
"basketID": "88",
"symbolName": "RELIANCE",
"exchange": "NSE",
"transactionType": "BUY",
"orderType": "L",
"orderValidity": "DAY",
"productType": "BO",
"quantity": "100",
"disclosedQuantity": "50",
"price": "2700",
"squareOffValue": "3000",
"stopLossValue": "2690",
"valueType": "Absolute",
"trailingStopLoss": "10",
"priceType": "LTP"
}Sample Code
bash
curl -X POST 'https://tradeapi.samco.in/basket/createOrder' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'x-session-token: <SESSION_TOKEN>' \
-d '{"basketID":"88","symbolName":"INFY","exchange":"NSE","transactionType":"BUY","orderType":"L","orderValidity":"DAY","productType":"MIS","quantity":"150","disclosedQuantity":"","price":"1800","triggerPrice":"1925.30"}'java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Sample {
public static void main(String[] args) throws Exception {
String requestBody = """
{
"basketID": "88",
"symbolName": "INFY",
"exchange": "NSE",
"transactionType": "BUY",
"orderType": "L",
"orderValidity": "DAY",
"productType": "MIS",
"quantity": "150",
"disclosedQuantity": "",
"price": "1800",
"triggerPrice": "1925.30"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://tradeapi.samco.in/basket/createOrder"))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("x-session-token", "<SESSION_TOKEN>")
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response =
client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}js
(async () => {
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'x-session-token': '<SESSION_TOKEN>',
};
const requestBody = {
basketID: "88",
symbolName: "INFY",
exchange: "NSE",
transactionType: "BUY",
orderType: "L",
orderValidity: "DAY",
productType: "MIS",
quantity: "150",
disclosedQuantity: "",
price: "1800",
triggerPrice: "1925.30"
};
const response = await fetch('https://tradeapi.samco.in/basket/createOrder', {
method: 'POST',
headers,
body: JSON.stringify(requestBody),
});
const data = await response.json();
console.log(data);
})();py
import requests
import json
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'x-session-token': '<SESSION_TOKEN>',
}
requestBody = {
"basketID": "88",
"symbolName": "INFY",
"exchange": "NSE",
"transactionType": "BUY",
"orderType": "L",
"orderValidity": "DAY",
"productType": "MIS",
"quantity": "150",
"disclosedQuantity": "",
"price": "1800",
"triggerPrice": "1925.30"
}
r = requests.post('https://tradeapi.samco.in/basket/createOrder',
data=json.dumps(requestBody),
headers=headers)
print(r.json())Sample Responses
json
{
"serverTime": "26/12/24 16:21:36",
"msgId": "c5268be4-f1c5-488b-bc86-69b06317aeb0",
"status": "Success",
"statusMessage": "Order Added Successfully",
"basketDetails": {
"clientId": "RM37283",
"basketId": 88,
"basketOrderId": 39,
"displayOrder": 39,
"exchange": "NSE",
"tradingSymbol": "INFY-EQ",
"transactionType": "BUY",
"productCode": "MIS",
"orderType": "L",
"quantity": 150,
"orderPrice": 1800,
"createdAt": "2024-12-26 16:21:38"
}
}json
{
"serverTime": "26/12/24 16:28:24",
"msgId": "d1b5be1c-2dff-4e7d-a566-fd642c594015",
"status": "Success",
"statusMessage": "Order Added Successfully",
"basketDetails": {
"clientId": "RM37283",
"basketId": 88,
"basketOrderId": 41,
"displayOrder": 41,
"exchange": "NSE",
"tradingSymbol": "HDFCBANK-EQ",
"transactionType": "BUY",
"productCode": "CNC",
"orderType": "L",
"quantity": 50,
"orderPrice": 1680,
"createdAt": "2024-12-26 16:28:25"
}
}json
{
"serverTime": "26/12/24 16:29:21",
"msgId": "c1f4dadb-06b0-417e-9b73-dc3020851d6d",
"status": "Success",
"statusMessage": "Order Added Successfully",
"basketDetails": {
"clientId": "RM37283",
"basketId": 88,
"basketOrderId": 43,
"displayOrder": 43,
"exchange": "NSE",
"tradingSymbol": "RELIANCE-EQ",
"transactionType": "BUY",
"productCode": "BO",
"orderType": "L",
"quantity": 100,
"orderPrice": 1200,
"stoplossValue": "1190",
"squareOffValue": "1300",
"trailingStopLoss": "10",
"createdAt": "2024-12-26 16:29:21"
}
}Response Schema
Status Code 200
| Name | Type | Description |
|---|---|---|
serverTime | string | The timestamp when the order response was generated by the server. |
msgId | string | A unique identifier for the order response message. |
status | string | The outcome of the order request (e.g., Success, Failure). |
clientId | string | A unique identifier for the client who placed the order. |
basketId | string | The identity of the user or customer associated with the order. |
basketOrderId | string | The identifier for the specific order in the user's basket. |
displayOrder | string | Dispaly order at this number. |
triggerPrice | string | The price at which a conditional order, such as a Stop Loss, is triggered. |
exchange | string | The stock exchange where the order is being executed (e.g., NSE). |
tradingSymbol | string | The symbol representing the stock or asset being traded (e.g., AAPL). |
transactionType | string | The type of trade (e.g., BUY, SELL). |
productCode | string | The type of trading product (e.g., BO, CO, MIS, CNC, NRML). |
orderType | string | The nature of the order (e.g., L for Limit, SL for Stop Loss). |
quantity | string | The number of units being bought or sold. |
orderPrice | string | The price at which the order was executed or filled. |
stoplossValue | string | The price at which the Stop Loss order will trigger. |
squareOffValue | string | The price at which the order is expected to be squared off (completed). |
trailingStopLoss | string | The price level for a trailing stop loss, adjusting as the price moves. |
createdAt | string | The timestamp when the order was initially placed. |