Execute Basket Order
POST basket/executeBasketOrder
The Execute Basket Order API allows you to execute a basket of orders using the provided basketId. You can specify the execution type as either "allatonce" to execute all orders simultaneously or "chronologically" to execute them in sequence.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
basketId | string | true | The unique identifier of the basket that you want to execute. |
executionType | string | true | Specifies how the orders in the basket should be executed. The value can be allatonce or chronologically. |
Sample Request Body
json
requestBody={
"basketId":"63",
"executionType":"allatonce"
}Live trading endpoint
This sample sends a real request against your trading account. Replace <SESSION_TOKEN> and review every field before running — Samco does not provide a sandbox, and any successful call affects live positions and balances.
Sample Code
bash
curl -X POST 'https://tradeapi.samco.in/basket/executeBasketOrder' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'x-session-token: <SESSION_TOKEN>' \
-d '{"basketId":"63","executionType":"allatonce"}'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": "63",
"executionType": "allatonce"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://tradeapi.samco.in/basket/executeBasketOrder"))
.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: "63",
executionType: "allatonce"
};
const response = await fetch('https://tradeapi.samco.in/basket/executeBasketOrder', {
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": "63",
"executionType": "allatonce"
}
r = requests.post('https://tradeapi.samco.in/basket/executeBasketOrder',
data=json.dumps(requestBody),
headers=headers)
print(r.json())Sample Responses
json
{
"serverTime": "21/08/24 12:26:46",
"msgId": "53aab933-0003-48ee-999c-0e68fe1f89b7",
"status": "Success",
"statusMessage": "Basket Order Initiated Successfully"
}Response Schema
Status Code 200
| Name | Type | Description |
|---|---|---|
serverTime | string | This indicates the timestamp of when the response was generated by the server. |
msgId | string | A unique identifier for the message or response. It helps in tracking and referencing the specific response. |
status | string | Status of the order cancellation request. Can be success, error, or failure. |
statusMessage | string | A human-readable message confirming that the basket order has been initiated successfully. |