Create Basket
POST /basket/createBasket
What is a Basket?
In trading, a basket is a collection of different financial assets such as stocks, future, or options that are grouped together. This allows traders and investors to buy or sell multiple assets in one single transaction, rather than dealing with each one individually.
Basket name can only contain alphabets, numbers, hyphen, and space
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
basketName | string | true | The basket name is a label or identifier you give to a collection of financial assets grouped together as a basket. |
Sample Request Body
json
requestBody={
"basketName": "Basket Name"
}Sample Code
bash
curl -X POST 'https://tradeapi.samco.in/basket/createBasket' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'x-session-token: <SESSION_TOKEN>' \
-d '{"basketName":"Basket Name"}'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 = """
{
"basketName": "Basket Name"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://tradeapi.samco.in/basket/createBasket"))
.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 = {
basketName: "Basket Name"
};
const response = await fetch('https://tradeapi.samco.in/basket/createBasket', {
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 = {
"basketName": "Basket Name"
}
r = requests.post('https://tradeapi.samco.in/basket/createBasket',
data=json.dumps(requestBody),
headers=headers)
print(r.json())Sample Responses
json
{
"serverTime": "08/08/24 19:06:22",
"msgId": "b8d2d66b-2729-46eb-b799-7f2055008a57",
"status": "Success",
"statusMessage": "Basket created successfully",
"basketDetails": {
"basketId": 64,
"basketName": "NIFTY FO"
}
}json
{
"serverTime": "08/08/24 19:07:00",
"msgId": "dccaa746-f30c-48cf-96cf-2eca0f50949a",
"status": "Failure",
"statusMessage": "You have reached the maximum order limit of 50 orders. Please remove existing orders and try again."
}Response Schema
Status Code 200
| Name | Type | Description |
|---|---|---|
serverTime | string | Time at Server. |
msgId | string | This is a unique identifier for every request into the system. Please quote this identifier to the support team if you face issues with the API request. |
status | string | Status of the order cancellation request. Can be 'success' or 'failure'. |
statusMessage | string | Status message for the order cancellation request. |
basketDetails | string | An object that contains information about a specific trading basket. |
basketId | string | A unique identifier for the basket. It is typically a numeric value that allows for easy reference and management of the basket within the trading system. |
basketName | string | The name of the basket. This string provides a human-readable identifier for the basket, helping users understand its purpose or the assets it contains. |