NAV Navigation
JavaScript Python

Samco Trade API Documentation v3.0

Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

Samco Trade API is a set of Rest APIs using which users can build customized applications based on their trading requirements. It facilitates the users of the APIs to login, search symbols, place orders and execute them, view their order status, positions and holdings etc. This documentation provides you with all the necessary details to understand the SAMCO Trade API collection. APIs are compatible with both Javascript and Python.

For any issues or support, please raise ticket to us using the support link and we will be happy to assist you.

For Reference you can download postman collection Click here

For downloading a list of all tradeable scrips across exchanges please Click here This is a CSV file which you can import into your database.

NOTE: To ensure stability and there by provide seamless services to our customers, Samco may set limits on your use of the Trade APIs (for example, limit on the number of requests sent to a specific API) . If you have additional questions regarding the rate limits on APIs, please reach out to us using the support link and we will be happy to assist you.


Supports the list of following index names:

 
BSE CG SENSEX BSE CD NIFTY50 PR 1x INV
BSE IT METAL OILGAS NIFTY50 PR 2x LEV
BSEIPO GREENX POWER NIFTY50 TR 1x INV
CARBON BASMTR CDGS NIFTY50 TR 2x LEV
BSEFMC BSE HC ALLCAP NIFTY50 TR 2x LEV
REALTY SMEIPO DOL30 NIFTY Mid LIQ 15
LRGCAP MIDSEL SMLSEL NIFTY100 LIQ 15
SNXT50 SNSX50 NIFTY 50 NIFTY Quality 30
NIFTY BANK NIFTY NEXT 50 DOL100 NIFTY MIDCAP 50
NIFTY 100 NIFTY 200 NIFTY 500 NIFTY FIN SERVICE
NIFTY AUTO NIFTY FMCG NIFTY IT NIFTY COMMODITIES
NIFTY MEDIA NIFTY METAL NIFTY PHARMA NIFTY CONSUMPTION
NIFTY PSU BANK NIFTY PVT BANK NIFTY REALTY NIFTY GROWSECT 15
NIFTY CPSE NIFTY ENERGY NIFTY INFRA NIFTY DIV OPPS 50
NIFTY MNC NIFTY PSE NIFTY SERV SECTOR NIFTY MID100 FREE
DOL200 TECK BSEPSU NIFTY SML100 FREE
AUTO BANKEX INDIA VIX NIFTY50 VALUE 20

APIs will work intermittently over the weekends/holidays and outside market hours due to maintenance activity. Base URLs:

Http Request Header

This is the request header which should be included in every api.

Name Required Discription
Accept false Accept indicates what the format of the response will be.If the user does not provide an accept , by default considered as application/json .Only accept type application/json, */* or blank is acceptable.
Content-Type false Content-Type refers to the media type or MIME type of the data in an HTTP message, indicating the type of content being sent, by default considered as application/json .Only Content-Type type application/json, */* or blank is acceptable.
x-session-token true When one hits the login-api, it receives a session token in response. The same token is used here for validation for all api.

Http Response Code

The HTTP response code indicates the success or failure of an HTTP request. Below is a list

Name Meaning Description
200 OK API response received successfully
400 Bad Request Input validation Failed. Check the validation errors in response object.
406 Not Acceptable Client's request headers unacceptable. Server can't provide desired response.
415 Unsupported Media Type Unsupported media type in request.Server cannot process the content.
429 Too Many Requests rate limiting
500 Internal Server Error Server Error

Trade Limits

Rate Limits - March 2024

Our Samco Trade APIs are set with defined rate limits, which are based on the IP address. If these limits are exceeded, a "429 - Too Many Requests" error may occur. We've recently updated our rate limit policy, which involves enhancing the limits for specific Samco APIs.

Updated list of our API request limits and time limits:

TradeAPI - Rate Limit Configuration
API Name Requests URL Session IP
User Login /login 5 200
Personal Index /indexData 3 20
Market Depth /marketDepth 3 20
Add GTT /gttoco/addGtt 3 20
Modify GTT /gttoco/modifyGtt 3 20
Delete GTT /gttoco/deleteGtt 3 20
Add OCO /gttoco/addOco 3 20
Modify OCO /gttoco/modifyOco 3 20
Delete OCO /gttoco/deleteOco 3 20
List GTT OCO /gttoco/listGttOco 3 20
Span Margin /spanMargin 3 20
Get Quote /quote/getQuote 10 500
Index Quote /quote/indexQuote 10 500
Multi Quote /quote/multiQuote 10 500
Search Equity & Derivative /eqDervSearch/search 5 500
Option Chain /option/optionChain 1 20
Future Chain /future/futureChain 1 20
User Limits /limit/getLimits 2 200
Place Order /order/placeOrder 200 200
Place BO Order /order/placeOrderBO 200 200
Place CO Order /order/placeOrderCO 200 200
Get Order Status /order/getOrderStatus 100 200
Order Book /order/orderBook 100 200
TriggerOrders /order/getTriggerOrders 20 200
Modify Order /order/modifyOrder 100 200
Cancel BO Order /order/exitBO 5 200
Cancel CO Order /order/exitCO 5 200
Cancel Order /order/cancelOrder 100 200
Trade Book /trade/tradeBook 5 20
User Positions /position/getPositions 5 200
Position Conversion /position/convertPosition 5 200
Position Square Off /position/squareOff 20 200
User Holdings /holding/getHoldings 2 200
Intraday candle data /intraday/candleData 5 20
Index IntraDay candle data /intraday/indexCandleData 5 20
Historical candle data /history/candleData 5 20
Index Historical CandleData /history/indexCandleData 5 20

User Login

User Login

Body parameter


requestBody={
  "userId": "DV99999",
  "password": "abc1234",
  "yob": "1975"
}

Code samples

var headers = {
  'Content-Type' : 'application/json',
  'Accept' : 'application/json'
};

$.ajax({
  url : 'https://tradeapi.samco.in/login',
  method : 'post',
  data : JSON.stringify(requestBody),
  headers : headers,
  success : function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})


import requests

headers = {
  'Content-Type' : 'application/json',
  'Accept' : 'application/json'
}

r = requests.post('https://tradeapi.samco.in/login'
, data=json.dumps(requestBody)
, headers = headers)

print r.json()

POST /login

The Trade APIs allow the user authentication using the Login API. A valid SAMCO Trading Account and subscription to Trade API Services is a pre-requisite for successful authentication. For Example, if you are going to use 3 users for Trading using APIs, all the 3 users will have to open a SAMCO Trading Account and will have to subscribe to SAMCO Trade API Services.

Parameters

Name Type Required Description
userId string true The client Code provided to you by SAMCO after opening an account.
password string true If user has set password using any of the SAMCO Trading platform i.e. Stocknote Mobile App, Stocknote Web or Stockbasket, then use the password as set. Or else, use the password provided in the welcome email sent to you at the time of account opening.
yob string false Your year of birth.

Example responses

200 Response

{
    "serverTime": "04/04/24 11:06:17",
    "msgId": "4d54c81c-2c57-4049-8683-af0ed3e307d8",
    "status": "Success",
    "statusMessage": "Login session token generated successfully",
    "sessionToken": "e0317d9c9d4749a0706e3994c80653bc",
    "accountID": "RMXXXX3",
    "accountName": "MXXXXXXD XXXH",
    "exchangeList": ["BFO","BSE","CDS","MCX","NSE","NFO"],
    "orderTypeList": ["MKT","L","SL","SL-M"],
    "productList": ["MIS","CNC","NRML","CO","BO"]
}

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 The status of the API response. It can be either 'Success' or 'Failure'.
statusMessage string A message describing the result of the API call.
sessionToken string Session token that should be used with API request is given in the response. It is used as an authenticator. A session token is valid for 24 hours or until a new login request is given, where you a new session token will be generated and the previous one will get expired.
accountID string Same as Client Code for SAMCO Trading Account, is unique and used for identification of user.
accountName string Users full name as registered with Samco Trading Account.
exchangeList [string] List of exchanges enabled for trading for the user.
orderTypeList [string] List of order types enabled for trading for the user.The list can be from of the following, MKT - Market Order,L- Limit Order,SL - Stop Loss Limit,SL-M - Stop loss market.
productList [string] List of product types enabled for the user . It can be CNC (Cash and Carry),BO (Bracket Order),CO (Cover Order),NRML (Normal),MIS (Intraday).

Personal Index

Index Data

GET /indexData

The Index Data API shows the user's personal index. It shows the overall profit and loss of all the trades done by the user.

Code samples


var headers = {
'Accept': 'application/json',
'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

$.ajax({
  url: 'https://tradeapi.samco.in/indexData',
  method: 'Get',
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})


import requests
import json

headers = {
'Accept': 'application/json',
'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'

}

r = requests.get('https://tradeapi.samco.in/indexData'
, headers = headers)

print (r.json())

Parameters

No parameters are required to use this API.

Sample Response

200 Response

{
    "serverTime": "04/04/24 11:22:12",
    "msgId": "2164268d-d38b-490e-bbb2-d3cedda3a907",
    "status": "Success",
    "statusMessage": "Index Data retrieved successfully",
    "indexData": {
        "indexName": "MXXXXXXD IXXXx",
        "networth": "209.52",
        "indexData": {
            "index": "4.04",
            "indexChange": "0.04",
            "indexChangePercentage": "1.04",
            "latestTime": "2024-04-04 11:21:00",
            "networthChange": "2.15",
            "networthChangePercentage": "1.04",
            "fundReceipt": "0.00"
        }
    }
}

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 The status of the API response. It can be either 'Success' or 'Failure'.
statusMessage string A message describing the result of the API call.
indexDataDetails Object User index data details
indexName string Client Personal Index.
networth string Client's total worth.
indexData Object User index data details
Index string The latest calculated value of the index.
IndexChange string The variance between yesterday's and today's index values.
IndexChangePercentage string The percentage change in index value from yesterday to today.
latestTime string Timestamp indicating the latest update of the index value.
networthChange string The variance between yesterday's and today's net worth values.
networthChangePercentage string The percentage change in net worth value from yesterday to today.
fundReceipt string Today's payment amount: the sum received or transferred to fund.

Market Depth

Market Depth

POST /marketDepth

Body parameter


requestBody={ 
  "exchange" : "BFO",
  "symbolName" : "BANKEX2450656000CE"
}

Code samples


var headers = {
  'Content-Type' : 'application/json',
  'Accept' : 'application/json',
  'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938',
}

$.ajax({
   url : 'https://tradeapi.samco.in/marketDepth',
   method : 'POST',
   data : JSON.stringify(requestBody),
   headers : headers,
   success : function(data) {
      console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})


import requests
import json

headers = {
  'Content-Type' : 'application/json',
  'Accept' : 'application/json',
  'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938',
}
r = requests.post('https://tradeapi.samco.in/marketDepth'
, data=json.dumps(requestBody)
, headers = headers)

print (r.json())

Example responses

200 Response

{
    "serverTime": "04/04/24 11:57:24",
    "msgId": "a1454ad2-dc44-4299-8907-faa751b750cd",
    "status": "Success",
    "statusMessage": "Market depth data retrieved successfully",
    "MarketDepthDetails": {
        "marketDepth": {
            "tradingSymbol": "BANKEX2450656000CE",
            "vega": "0.00",
            "theta": "-0.00",
            "gamma": "0.0000",
            "symbol": "870393_BFO",
            "tBuyQty": "0",
            "iv": "1.79",
            "tSellQty": "0",
            "bestFiveAsk": [
                {
                    "askNumber": "0",
                    "askSize": "0",
                    "askPrice": "0.00"
                },
                {
                    "askNumber": "0",
                    "askSize": "0",
                    "askPrice": "0.00"
                },
                {
                    "askNumber": "0",
                    "askSize": "0",
                    "askPrice": "0.00"
                },
                {
                    "askNumber": "0",
                    "askSize": "0",
                    "askPrice": "0.00"
                },
                {
                    "askNumber": "0",
                    "askSize": "0",
                    "askPrice": "0.00"
                }
            ],
            "bestFiveBid": [
                {
                    "bidSize": "0",
                    "bidNumber": "0",
                    "bidPrice": "0.00"
                },
                {
                    "bidSize": "0",
                    "bidNumber": "0",
                    "bidPrice": "0.00"
                },
                {
                    "bidSize": "0",
                    "bidNumber": "0",
                    "bidPrice": "0.00"
                },
                {
                    "bidSize": "0",
                    "bidNumber": "0",
                    "bidPrice": "0.00"
                },
                {
                    "bidSize": "0",
                    "bidNumber": "0",
                    "bidPrice": "0.00"
                }
            ],
            "delta": "0.00",
            "exc": "BFO"
        }
    }
}

Parameters

Name Type Required Description
exchange string false Name of the exchange.Valid exchanges values (BSE/NSE/NFO/BFO/MCX/CDS/MFO).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
symbolName string true Symbol name of the scrip.For Equity enter SymbolName of the scrip & For Derivatives enter TradingSymbol of the scrip

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 The status of the API response. It can be either 'Success' or 'Failure'.
statusMessage string A message describing the result of the API call.
marketDepth Object Obtain a list providing Market Depth details.
tradingSymbol string Symbol for trading the scrip.
vega string The value of an options contract typically increases.
theta string The rate of price change in an options contract relative to its remaining time until expiration.
gamma string Gamma represents a key factor in option chain calculations.
symbol string The actual name of the symbol for the scrip.
tBuyQty string Total quantity of BUY transaction.
iv string Implied Volatility is how much experts think a stock will change.
tSellQty string The overall quantity of SELL transactions.
bestFiveAsk Object Obtain a list of Ask values.
bestFiveBid Object Obtain a list of Bid Values.
delta string The price change of an option relative to the asset's movements.
exc string The name of the stock exchange.

GTT Order

A GTT order is a type of limit order that remains active until it is either filled or canceled by the user. This is useful for traders who want to buy or sell a security at a specific price but are not able to monitor the market continuously.

The Trade API mentioned here likely allows traders to interact with a trading platform programmatically, enabling them to place GTT orders without needing to use a graphical user interface (GUI). The API would typically involve sending HTTP requests with specific parameters to a server, which would then execute the order on behalf of the trader.

Add GTT

POST /gttoco/addGtt

GTT (Good Till Triggered) is a feature that allows users to place buy or sell orders of any stock at market or limit price. These orders are executed (triggered) once the market price of the stock reaches your desired price i.e the price you mentioned in the GTT Order. Read More....

In the BFO exchange, only SENSEX and BANKEX trades are allowed.

Body parameter

requestBody={
  "exchange": "BFO",
  "symbolName": "SENSEX502441823950PE",
  "transactionType": "BUY",
  "quantity": "1",
  "productType": "NRML",
  "orderType": "L",
  "triggerPrice": "12",
  "limitPrice": "14",
  "marketProtection": ""
}

Code samples


var headers = {
  'Content-Type' : 'application/json',
  'Accept' : 'application/json',
  'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938',
}

$.ajax({
  url: 'https://tradeapi.samco.in/gttoco/addGtt',
  method: 'post',
  data : JSON.stringify(requestBody),
  headers : headers,
  success : function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})


import requests
import json

headers = {
  'Content-Type' : 'application/json',
  'Accept' : 'application/json',
  'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938',
}

r = requests.post('https://tradeapi.samco.in/gttoco/addGtt'
, data=json.dumps(requestBody)
, headers = headers)

print r.json()

Parameters

Name Type Required Description
exchange string true Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ BFO/ MCX/ CDS/ MFO).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO,BFO,CDS,MFO and MCX, exchange is mandatory.
symbolName string true Symbol name of the scrip.For Equity enter SymbolName of the scrip & For Derivatives enter TradingSymbol of the scrip
transactionType string true Determines whether the order is a buy or sell transaction.
quantity string true Defines the number of units or shares of the asset to be bought or sold.
productType string true Product Type of the order. It can be CNC (Cash and Carry)NRML (Normal).The valid product type for F&O (Futures and Options) is NRML
orderType string true Type of order user has placed . It can be one of the following, MKT - Market Order,L- Limit Order.
triggerPrice string true This represents the market-entry price level for the placed order.
limitPrice string true Limit price is a required field for L - Limit orders.This is the price at which the order is executed in the market.
marketProtection string true MarketProtection is a required field for market orders. By default, MarketProtection is set to 3% to protect the order from potential market losses.

Example responses

200 Response

{
    "serverTime": "04/04/24 12:32:34",
    "msgId": "ab50b682-3642-443b-8218-c5fded443076",
    "status": "Success",
    "statusMessage": "GTT CREATED",
    "gttSummaryId": "670185",
    "orderDetails": {
        "productType": "NRML",
        "orderType": "L",
        "triggerPrice": "12",
        "marketProtection": "",
        "transactionType": "BUY",
        "symbol": "860822_BFO",
        "symbolName": "SENSEX502441823950PE",
        "createdAt": "2024-04-04 12:32:34"
    }
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
gttSummaryId string gttSummaryId uniquely identifies GTT order, essential for modifying, retrieving status, and deleting.
productType string The product type of the order.
orderType string The type of order.
triggerPrice string The trigger price for the order.
marketProtection string The market protection percentage for the order.
transactionType string The transaction type for the order.
symbol string The actual name of the symbol for the scrip.
symbolName string The name of the symbol representing the scrip.
createdAt string Timestamp marking the addition of the GTT order.

Modify GTT

PUT /gttoco/modifyGtt

Modifying a GTT (Good Till Triggered) order allows investors to adjust the parameters of their existing GTT orders. This can include changing the trigger price, altering the quantity of the order, productType, limitPrice, marketProtection or modifying the order type.

Body parameter

requestBody={
      "exchange": "NSE",
      "symbolName": "IDEA",
      "transactionType": "BUY",
      "quantity": 20,
      "productType": "CNC",
      "orderType": "L",
      "triggerPrice": 13.10,
      "limitPrice": 13.05,
      "marketProtection": "",
      "gttSummaryId" : 136042
}

Code samples


var headers = {
  'Content-Type' : 'application/json',
  'Accept' : 'application/json',
  'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938',
}

$.ajax({
  url : 'https://tradeapi.samco.in/gttoco/modifyGtt',
  method : 'put',
  data : JSON.stringify(requestBody),
  headers : headers,
  success : function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})


import requests
import json

headers = {
  'Content-Type' : 'application/json',
  'Accept' : 'application/json',
  'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938',
}

r = requests.put('https://tradeapi.samco.in/gttoco/modifyGtt'
, data=json.dumps(requestBody)
, headers = headers)

print (r.json())

Parameters

Name Type Required Description
exchange string true The valid exchange will remain the same as it was at the time of creating the GTT. We cannot modify the exchange.
symbolName string true The symbol name will also remain the same as it was at the time of creating the GTT. We cannot modify the symbol name.
transactionType string true Determines whether the order is a buy or sell transaction.
quantity number true Defines the number of units or shares of the asset to be bought or sold.
productType string true Product Type of the order. It can be CNC (Cash and Carry)NRML (Normal)
orderType string true Type of order user has placed . It can be one of the following, MKT - Market Order,L- Limit Order.
triggerPrice number true This represents the market-entry price level for the placed order.
limitPrice number true This is the price at which the order is executed in the market.
marketProtection string true MarketProtection is a required field for market orders. By default, MarketProtection is set to 3% to protect the order from potential market losses.
gttSummaryId number true Enter the gttSummaryId of the GTT order you want to modify here.

Example responses

200 Response

{
    "serverTime": "28/02/24 12:47:38",
    "status": "Success",
    "msgId": "242c7fa5-a6f7-438f-859b-a4b5ced39ce5",
    "gttSummaryId": "136045",
    "statusMessage": "GTT order Modified",
    "orderDetails": {
        "productType": "CNC",
        "orderType": "L",
        "triggerPrice": "13.10",
        "marketProtection": "",
        "transactionType": "BUY",
        "limitPrice": "13.05",
        "symbol": "14366_NSE",
        "symbolName": "IDEA",
        "quantity": "20",
    }
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
gttSummaryId string After the order is modified, a new gttSummaryId is generated. For any further operation, this gttSummaryId will be valid for this order and the gttSummaryId becomes invalid.
productType string The product type of the order.
orderType string The type of order.
triggerPrice string The trigger price for the order.
marketProtection string The market protection percentage for the order.
transactionType string The transaction type for the order.
limitPrice string This is the price at which the order is executed in the market.
symbol string The actual name of the symbol for the scrip.
symbolName string The name of the symbol representing the scrip.
quantity string Defines the number of units or shares of the asset to be bought or sold.

Delete GTT

DELETE /gttoco/deleteGtt

Deleting a GTT order cancels it before execution, removing it from the exchange's order book and preventing future execution. Once GTT is triggered, deletion is not possible.

Body parameter


requestBody={
  "gttSummaryId" : 136045
}

Code samples


var headers = {
  'Content-Type' : 'application/json',
  'Accept' : 'application/json',
  'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938',
}

$.ajax({
  url : 'https://tradeapi.samco.in/gttoco/deleteGtt',
  method : 'delete',
  data : JSON.stringify(requestBody),
  headers : headers,
  success : function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})


import requests
import json

headers = {
  'Content-Type' : 'application/json',
  'Accept' : 'application/json',
  'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938',
}

r = requests.delete('https://tradeapi.samco.in/gttoco/deleteGtt'
, data=json.dumps(requestBody)
, headers = headers)

print r.json()

Parameters

Name Type Required Description
gttSummaryId number true Enter the gttSummaryId of the GTT order you want to delete here.

Example responses

200 Response

{
    "serverTime": "28/02/24 12:49:19",
    "status": "Success",
    "msgId": "a62afb04-84a5-4d3d-ba5b-3299cce4fd77",
    "gttSummaryId": "136045",
    "statusMessage": "GTT order Deleted",
    "orderDetails": {
        "userId": "RM1001"
    }
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
gttSummaryId string gttSummaryId of the order which is deleted.
userId string User ID of the user who deleted the order.

Add OCO

POST /gttoco/addOco

Add OCO refers to the functionality of adding an OCO (One-Cancels-the-Other) condition to a GTT (Good Till Triggered) order. With this feature, investors can set up two separate exit conditions for a single position. If one condition is triggered and the corresponding order is executed, the other order is automatically canceled, hence the "one-cancels-the-other" concept.

Here’s how it works?

In the BFO exchange, only SENSEX and BANKEX trades are allowed.

Body parameter

requestBody={
    "exchange": "NSE",
    "symbolName": "IDEA",
    "transactionType": "SELL",
    "quantity": "5",
    "productType": "CNC",
    "orderType": "L",
    "targetTriggerPrice": "13.5",
    "targetLimitPrice": "13.5",
    "stoplossTriggerPrice": "10.5",
    "stoplossLimitPrice": "10.5",
    "marketProtection": ""
}

Code samples


var headers = {
  'Content-Type' : 'application/json',
  'Accept' : 'application/json',
  'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938'
}

$.ajax({
  url: 'https://tradeapi.samco.in/gttoco/addOco',
  method: 'post',
  data : JSON.stringify(requestBody),
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
import json

headers = {
    'Content-Type' : 'application/json',
    'Accept' : 'application/json',
    'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.post('https://tradeapi.samco.in/gttoco/addOco'
, data=json.dumps(requestBody)
, headers = headers)

print r.json()

Parameters

Name Type Required Description
exchange string true Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ BFO/ MFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, BFO, MFO, CDS and MCX, exchange is mandatory.
symbolName string true Symbol name of the scrip.For Equity enter SymbolName of the scrip & For Derivatives enter TradingSymbol of the scrip
transactionType string true Determines whether the order is a buy or sell transaction. EQ delivery buy order not allowed in the Gtt.
quantity string true Defines the number of units or shares of the asset to be bought or sold.
productType string true Product Type of the order. It can be CNC (Cash and Carry)NRML (Normal)
orderType string true Type of order user has placed . It can be one of the following, MKT - Market Order,L- Limit Order.
targetTriggerPrice string true The targetTriggerPrice at which the order will enter the market.
targetLimitPrice string true targetLimitPrice is a required field for limit orders. The targetLimitPrice at which the order will be executed on the exchange.
stoplossTriggerPrice string false The stoplossTriggerPrice at which the order will enter the market.
stoplossLimitPrice string true stoplossLimitPrice is a required field for limit orders. The stoplossLimitPrice at which the order will be executed on the exchange.
marketProtection string true MarketProtection is a required field for market orders. By default, MarketProtection is set to 3% to protect the order from potential market losses.

Example responses

200 Response

{
    "serverTime": "04/04/24 13:21:04",
    "msgId": "474288ae-dc9c-4ea3-82ee-9f6c9ba9b0d9",
    "status": "Success",
    "statusMessage": "GTT CREATED",
    "gttSummaryId": "670745",
    "orderDetails": {
        "transactionType": "SELL",
        "symbol": "14366_NSE",
        "symbolName": "IDEA",
        "productType": "CNC",
        "orderType": "L",
        "target": {
            "quantity": "5",
            "triggerPrice": "13.5",
            "limitPrice": "13.5",
            "marketProtection": "",
            "type": "TARGET",
            "triggerId": "932060"
        },
        "stopLoss": {
            "quantity": "5",
            "triggerPrice": "10.5",
            "limitPrice": "10.5",
            "marketProtection": "",
            "type": "STOPLOSS",
            "triggerId": "932065"
        }
    }
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
gttSummaryId string gttSummaryId uniquely identifies GTT order, essential for modifying, retrieving status, and deleting.
transactionType string Determines whether the order is a buy or sell transaction.
symbol string The actual name of the symbol for the scrip.
symbolName string The name of the symbol representing the scrip.
productType string The product type of the order.
orderType string The type of order.
target object An object containing details about the target order.
stopLoss object An object containing details about the stop loss order.

Modify OCO

PUT /gttoco/modifyOco

Modifying a GTT OCO (Good Till Triggered, One-Cancels-the-Other) order involves adjusting the parameters of an existing GTT OCO order. This can include changing the trigger prices, adjusting the quantity of the order, or modifying the order types.

When modifying a GTT OCO order, investors can make changes to both legs of the OCO order, ensuring that the exit strategies remain aligned with their trading objectives and market conditions. For example, if market conditions change and the investor wants to adjust their profit target or stop-loss levels, they can modify the trigger prices accordingly.

Body parameter

requestBody={
    "exchange": "NSE",
    "symbolName": "IDEA",
    "transactionType": "SELL",
    "quantity": "25",
    "productType": "CNC",
    "orderType": "L",
    "targetTriggerPrice": "13.5",
    "targetLimitPrice": "13.5",
    "stoplossTriggerPrice": "10.5",
    "stoplossLimitPrice": "10.5",
    "marketProtection": "",
    "gttSummaryId" : 670745
}

Code samples

var headers = {
    'Content-Type' : 'application/json',
    'Accept' : 'application/json',
    'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938'
};

$.ajax({
  url: 'https://tradeapi.samco.in/gttoco/modifyOco',
  method: 'put',
  data : JSON.stringify(requestBody),
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
import json

headers = {
    'Content-Type' : 'application/json',
    'Accept' : 'application/json',
    'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.put('https://tradeapi.samco.in/gttoco/modifyOco'
, data=json.dumps(requestBody)
, headers = headers)

print (r.json())

Parameters

Name Type Required Description
exchange string true The valid exchange will remain the same as it was at the time of creating the GTT OCO . We cannot modify the exchange.
symbolName string true The symbol name will also remain the same as it was at the time of creating the GTT OCO. We cannot modify the symbol name.
transactionType string true Determines whether the order is a buy or sell transaction.
quantity string true Defines the number of units or shares of the asset to be bought or sold.
productType string true Product Type of the order. It can be CNC (Cash and Carry)NRML (Normal)
orderType string true Type of order user has placed . It can be one of the following, MKT - Market Order,L- Limit Order.
targetTriggerPrice string true The targetTriggerPrice at which the order will enter the market.
targetLimitPrice string true targetLimitPrice is a required field for limit orders. The targetLimitPrice at which the order will be executed on the exchange.
stoplossTriggerPrice string true The stoplossTriggerPrice at which the order will enter the market.
stoplossLimitPrice string true stoplossLimitPrice is a required field for limit orders. The stoplossLimitPrice at which the order will be executed on the exchange.
marketProtection string true MarketProtection is a required field for market orders. By default, MarketProtection is set to 3% to protect the order from potential market losses.
gttSummaryId number true Enter the gttSummaryId of the GTT OCO order you want to modify here.

Example responses

200 Response

{
    "serverTime": "04/04/24 13:53:23",
    "msgId": "432b12e6-6acc-4b38-98b3-3940e09d0c26",
    "status": "Success",
    "statusMessage": "GTT MODIFIED",
    "gttSummaryId": "671170",
    "orderDetails": {
        "transactionType": "SELL",
        "orderType": "L",
        "symbol": "14366_NSE",
        "symbolName": "IDEA",
        "productType": "CNC",
        "target": {
            "limitPrice": "13.5",
            "triggerId": "932815",
            "triggerPrice": "13.5",
            "type": "TARGET",
            "quantity": "25",
            "marketProtection": ""
        },
        "stopLoss": {
            "limitPrice": "10.5",
            "triggerId": "932820",
            "triggerPrice": "10.5",
            "type": "STOPLOSS",
            "quantity": "25",
            "marketProtection": ""
        }
    }
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
gttSummaryId string After the order is modified, a new gttSummaryId is generated. For any further operation, this gttSummaryId will be valid for this order and the gttSummaryId becomes invalid.
transactionType string transaction type describes whether it involves buying or selling.
orderType string The type of order.
symbol string The actual name of the symbol for the scrip.
symbolName string The name of the symbol representing the scrip.
productType string The product type of the order.
target object An object containing details about the target order.
stopLoss object An object containing details about the stop loss order.

Delete OCO

DELETE /gttoco/deleteOco

Deleting an OCO (One-Cancels-the-Other) order involves canceling both legs of the order simultaneously. In an OCO order, when one part of the order is executed, the other part is automatically canceled. However, if the investor decides to delete the entire OCO order before either part is executed, they can do so using the delete OCO API.

Body parameter


requestBody={
    "gttSummaryId" : 136045
}

Code samples

var headers = {
    'Content-Type' : 'application/json',
    'Accept' : 'application/json',
    'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938'
}

$.ajax({
  url: 'https://tradeapi.samco.in/gttoco/deleteOco',
  method: 'delete',
  data : JSON.stringify(requestBody),
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
import json

headers = {
    'Content-Type' : 'application/json',
    'Accept' : 'application/json',
    'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.delete('https://tradeapi.samco.in/gttoco/deleteOco'
, data=json.dumps(requestBody)
, headers = headers)

print (r.json())

Parameters

Name Type Required Description
gttSummaryId number true Enter the gttSummaryId of the GTT order you want to delete here.

Example responses

200 Response

{
    "serverTime": "28/02/24 12:49:19",
    "status": "Success",
    "msgId": "a62afb04-84a5-4d3d-ba5b-3299cce4fd77",
    "gttSummaryId": "136045",
    "statusMessage": "GTT OCO order Deleted",
    "orderDetails": {
        "userId": "RM1001"
    }
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
gttSummaryId string gttSummaryId of the order which is deleted.
userId string User ID of the user who deleted the order.

List GTT OCO

GET /gttoco/listGttOco

Using the list OCO, we can retrieve the list of active GTT OCO, triggered GTT OCO, and expired GTT OCO.

Code samples


var headers = {
  'Accept':'application/json',
  'x-session-token':'115aead43798e35cef8308c15cc79c7a'

};

$.ajax({
  url: 'https://tradeapi.samco.in/gttoco/listGttOco?listType=active',
  method: 'get',
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token':'115aead43798e35cef8308c15cc79c7a'
}

r = requests.get('https://tradeapi.samco.in/gttoco/listGttOco', params={
  'listType': 'active'
}
, headers = headers)

print (r.json())

Parameters

Name Type Required Description
listType string true Type of list. valid type is (active / triggered / expired). If the user does not provide a listType, by default considered as active.

Example responses

200 Response

{
    "serverTime": "04/04/24 14:18:54",
    "msgId": "ec67dc5b-d626-4e16-a3eb-461ac37bb93b",
    "status": "Success",
    "statusMessage": "List of GTT / OCO orders received.",
    "orderDetails": [
        {
            "summary": {
                "id": 136027,
                "userId": "RM1001",
                "symbol": "14366_NSE",
                "symbolName": "IDEA",
                "orderType": "L",
                "productType": "CNC",
                "gttType": "SINGLE",
                "validTill": "FOREVER",
                "createdAt": "2024-02-28 17:52:27",
                "deletedAt": "",
                "gttSummaryId": "136027",
                "isExpired": false,
            },
            "triggers": {
                "gtt": {
                    "status": "",
                    "triggeredAt": "",
                    "triggerId": "172714",
                    "gttId": "172714",
                    "quantity": "1",
                    "limitPrice": "13.25",
                    "marketProtection": "",
                    "ltpAtCreation": "16.30",
                    "triggerPrice": "13.50",
                    "transactionType": "BUY",
                    "rejectReason": "",
                    "orderNumber": ""
                }
            }
        }
    ]
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
summary object Summary data for GTT orders.
gtt object GTT order details availbale for GTT orders.
target object Target details availbale for OCO orders.
stopLoss oject Stoploss details availbale for OCO orders.

Span Margin

Span Margin

Body parameter

requestBody={
    "request":[
        {
            "exchange":"NFO",
            "tradingSymbol":"TECHM23DEC1220CE",
            "qty":"600"
        },
        {
            "exchange":"NFO",
            "tradingSymbol":"TECHM23DECFUT",
            "qty":"175"
        }
    ]
}

Code samples

var headers = {
    'Content-Type' : 'application/json',
    'Accept' : 'application/json',
    'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938'
};

$.ajax({
  url: 'https://tradeapi.samco.in/spanMargin',
  method: 'post',
  data: JSON.stringify(requestBody),
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
import json

headers = {
    'Content-Type' : 'application/json',
    'Accept' : 'application/json',
    'x-session-token' : 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.post('https://tradeapi.samco.in/spanMargin'
, data=json.dumps(requestBody)
, headers = headers)

print (r.json())

POST /spanMargin

Parameters

Name Type Required Description
exchange string true Name of the exchange
tradingSymbol string true Trading Symbol of the scrip.
qty string true Quantity asked for margin.

Example responses

200 Response

{
    "serverTime": "02/02/24 06:36:39",
    "msgId": "a62b91a3-2b74-450a-85a2-8e7a4fbb4cca",
    "status": "Success",
    "statusMessage": "Span margin calculated",
    "spanDetails": {
        "totalRequirement": "312258.00",
        "spanRequirement": "192258.00",
        "exposureMargin": "120000.00",
        "spreadBenefit": "00.00"
    }
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
totalRequirement string This is the total amount of margin required for a particular portfolio of futures and options positions. It includes the SPAN requirement, exposure margin, and any additional margin that may be required by the exchange.
spanRequirement string This is the margin requirement calculated using the SPAN algorithm, which is a risk-based margining system. The SPAN requirement takes into account factors such as price volatility, correlation between different positions, and the overall risk of the portfolio.
exposureMargin string Exposure margin is an additional margin that may be required by the exchange to cover potential losses beyond those accounted for by the SPAN requirement. It provides a buffer against adverse market movements and helps ensure that traders maintain sufficient margin to cover their positions.
spreadBenefit string Spread benefit refers to a reduction in margin requirements that may be applied when certain offsetting positions are held in the same account. This reduction reflects the reduced risk associated with offsetting positions and encourages traders to engage in spread trading strategies.

Quote

Index Quote

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/quote/indexQuote?indexName=Sensex',
  method: 'get',
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})


import requests
import json

headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/quote/indexQuote', params={
  'indexName': 'Sensex'
}, headers = headers)

print r.json()

GET /quote/indexQuote

Getting Index Quote details for a specific Indicies. This helps user with market picture of an specific Index Details.

Parameters

Name Type Required Description
indexName string true Index name of the scrip.

Example responses

200 Response

{
    "serverTime": "04/04/24 14:34:13",
    "msgId": "13f6cb1e-8c31-4c5c-a15b-df7b27ac15a5",
    "status": "Success",
    "statusMessage": "Index Quote details retrieved successfully",
    "indexDetails": [
        {
            "indexName": "SENSEX",
            "listingId": "-101",
            "lastTradedTime": "2024-04-04 14:34:12.0",
            "spotPrice": 74344.02,
            "changePercentage": 0.63,
            "averagePrice": 0,
            "openValue": 74413.82,
            "highValue": 74501.73,
            "lowValue": 73485.12,
            "closeValue": 73876.82,
            "totalBuyQuantity": 0,
            "totalSellQuantity": 0,
            "totalTradedValue": 0,
            "totalTradedVolume": 0,
            "change": 467.2
        }
    ]
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
indexName string Index Name of the indices.
listingId string Identifier assigned to the scrip by exchange in the format <>_<>
lastTradedTime string Time of the last transaction
spotPrice string Spot price. Applicable in case of Futures and Options
changePercentage string Percentage of change between the current value and the previous day's market close
averagePrice string average price of a market snapshot
openValue string Opening price of a market snapshot
highValue string High value of market snapshot
lowValue string Low value of market snapshot
closeValue string Close value of market snapshot
totalBuyQuantity string Total quantity of BUY transaction
totalSellQuantity string Total quantity of SELL transaction
totalTradedValue string Value of total trade made for the scrip
totalTradedVolume string Total volume of trading done
change string Change value is the difference between the current value and the previous day's market close.

Get Quote

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/quote/getQuote?symbolName=ASIANPAINT24APR2760PE&exchange=NFO',
  method: 'get',
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/quote/getQuote', params={
  'symbolName': 'ASIANPAINT24APR2760PE','exchange':'NFO'
}, headers = headers)

print r.json()

GET /quote/getQuote

Get market depth details for a specific equity scrip including but not limited to values like last trade price, previous close price, change value, change percentage, bids/asks, upper and lower circuit limits etc. This helps user with market picture of an equity scrip using which he will be able to place an order.

Parameters

Name Type Required Description
exchange string false Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ BFO/ MCX/ MFO/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, BFO, MFO, CDS and MCX, exchange is mandatory.
symbolName string true Symbol name of the scrip.For Equity enter SymbolName of the scrip & For Derivatives enter TradingSymbol of the scrip

Example responses

200 Response

{
    "serverTime": "04/04/24 15:47:05",
    "msgId": "4568350b-c552-4a53-8981-45241b5d20e7",
    "status": "Success",
    "statusMessage": "Quote details retrieved successfully",
    "quoteDetails": {
        "symbolName": "ASIANPAINT",
        "tradingSymbol": "ASIANPAINT24APR2760PE",
        "exchange": "NFO",
        "lastTradedTime": "04/04/2024 15:29:58",
        "lastTradedPrice": "09.95",
        "previousClose": "14.7",
        "changeValue": "-4.75",
        "changePercentage": "-32.31",
        "lastTradedQuantity": "200",
        "lowerCircuitLimit": "0.05",
        "upperCircuitLimit": "36.45",
        "averagePrice": "11.92",
        "openValue": "13.2",
        "highValue": "18.85",
        "lowValue": "7.65",
        "closeValue": "14.7",
        "totalBuyQuantity": "45200",
        "totalSellQuantity": "29000",
        "totalTradedValue": "31.4211200 (Lacs)",
        "totalTradedVolume": "263600",
        "yearlyHighPrice": "0",
        "yearlyLowPrice": "0",
        "tickSize": "0.05",
        "bestBids": [
            {
                "number": "1",
                "quantity": "200",
                "price": "9.6"
            },
            {
                "number": "2",
                "quantity": "200",
                "price": "9.55"
            },
            {
                "number": "3",
                "quantity": "200",
                "price": "9.5"
            },
            {
                "number": "4",
                "quantity": "200",
                "price": "9.45"
            },
            {
                "number": "5",
                "quantity": "6000",
                "price": "8.35"
            }
        ],
        "bestAsks": [
            {
                "number": "1",
                "quantity": "200",
                "price": "10.2"
            },
            {
                "number": "2",
                "quantity": "200",
                "price": "10.25"
            },
            {
                "number": "3",
                "quantity": "200",
                "price": "10.6"
            },
            {
                "number": "4",
                "quantity": "200",
                "price": "10.65"
            },
            {
                "number": "5",
                "quantity": "200",
                "price": "10.75"
            }
        ],
        "listingId": "73859_NFO",
        "openInterestChange": "-4200",
        "instrument": "OPTSTK",
        "expiryDate": "25 Apr 24",
        "lotQuantity": "200",
        "oIChangePer": "-9.95"
    }
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
symbolName string Symbol name of the scrip.
tradingSymbol string Trading Symbol of the scrip.
exchange string Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
companyName string Full name of the company
lastTradedTime string Time of the last transaction
lastTradedPrice string Price at which last transaction / trade is done
previousClose string Previous close refers to the prior day's final price of a security when the market officially closes for the day
changeValue string Change value is the difference between the current value and the previous day's market close
changePercentage string Percentage of change between the current value and the previous day's market close
lastTradedQuantity string Quantity of last transaction
lowerCircuitLimit string Limit below which a stock price cannot trade on a particular trading day
upperCircuitLimit string Limit above which a stock price cannot trade on a particular trading day
averagePrice string Average price of the trading
openValue string Opening price of a market snapshot
highValue string High value of market snapshot
lowValue string Low value of market snapshot
closeValue string Close value of market snapshot
totalBuyQuantity string Total quantity of BUY transaction
totalSellQuantity string Total quantity of SELL transaction
totalTradedValue string Value of total trade made for the scrip
totalTradedVolume string Total volume of trading done
yearlyHighPrice string 52 week high
yearlyLowPrice string 52 week low
tickSize string The value of a single price tick. Default value is 0.05
openInterest string Open interest is the Number of existing contracts held by buyers or sellers for any market for any given day.
bestBids [object] Most frequent trading bids for BUY
number string Sequence number for Bid/Ask
quantity string Quantity asked for trading.
price string Price asked for trading.
bestAsks [object] Most frequent trading asked for SELL
number string Sequence number for Bid/Ask
quantity string Quantity asked for trading.
price string Price asked for trading.
expiryDate string Expiry date of the scrip
spotPrice string Spot price. Applicable in case of Futures and Options
instrument string Instrument Name.
lotQuantity string Lot quantity. Applicable for F & O
listingId string Identifier assigned to the scrip by exchange in the format <>_<>
openInterestChange string It shows Open interest change in Number of contracts held for market
getoIChangePer string It will shows the change % based on Open Interest

Multi Quote

POST /quote/multiQuote

Body parameter


requestBody={
  "NSE":["TCS"],
  "MFO" :["SILVER24APR76250PE"] 
}

Code samples


var headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938',
}

$.ajax({
   url: 'https://tradeapi.samco.in/quote/multiQuote',
   method: 'POST',
   data: JSON.stringify(requestBody),
   headers: headers,
   success: function(data) {
      console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})


import requests
import json

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938',
}

r = requests.post('https://tradeapi.samco.in/quote/multiQuote'
, data=json.dumps(requestBody)
, headers = headers)

print (r.json())

Example responses

200 Response

{
    "serverTime": "05/04/24 10:46:55",
    "msgId": "6dd6d540-33a5-4516-9818-e223370f4846",
    "status": "Success",
    "statusMessage": "Multiquotes data retrieved successfully",
    "multiQuotes": [
        {
            "exchange": "NSE",
            "symbolName": "TCS",
            "tradingSymbol": "TCS-EQ",
            "companyName": "TATA CONSULTANCY SERV LT",
            "isin": "INE467B01029",
            "lotSize": "1",
            "averagePrice": "3840.50",
            "totalTradeVolume": "4311783",
            "symbol": "11536_NSE",
            "lastTradeTime": "28 Mar 2024, 07:11:43 PM",
            "lastTradeQuantity": "1",
            "lastTradePrice": "3876.30",
            "misMultiplier": "4.00",
            "change": "35.40",
            "changePercent": "0.92",
            "open": "3850.10",
            "close": "3876.30",
            "previousClose": "3840.90",
            "low": "3840.50",
            "high": "3915.00",
            "tickSize": "0.05",
            "bidSize": "782",
            "bidPrice": "3876.30",
            "totalTradedValue": "16732176051.06",
            "askSize": "0",
            "askPrice": "0.00",
            "iv": "0.00"
        },
        {
            "exchange": "MCX",
            "symbolName": "SILVER",
            "tradingSymbol": "SILVER24APR76250PE",
            "optionType": "PE",
            "instrumentType": "OPTCOM",
            "companyName": "SILVER",
            "lotSize": "30",
            "strikePrice": "76250.0000",
            "expiry": "24 Apr 24",
            "averagePrice": "0.00",
            "totalTradeVolume": "0",
            "symbol": "256981_MFO",
            "lastTradeTime": "01 Apr 2024, 04:34:41 PM",
            "lastTradeQuantity": "0",
            "lastTradePrice": "0.00",
            "misMultiplier": "100.00",
            "multiplier": "30",
            "openInterest": "0",
            "previousOpenInterest": "0",
            "change": "0.00",
            "changePercent": "0.00",
            "open": "0.00",
            "close": "1656.00",
            "previousClose": "0.00",
            "low": "0.00",
            "high": "0.00",
            "tickSize": "0.5",
            "bidSize": "0",
            "bidPrice": "0.00",
            "totalTradedValue": "0.00",
            "askSize": "0",
            "askPrice": "0.00",
            "delta": "0.00",
            "vega": "0.00",
            "theta": "0.00",
            "gamma": "0.0000",
            "iv": "0.00"
        }
    ]
}

Parameters

Name Type Required Description
BSE array false Assign the array of BSE symbol names to the BSE key.
NSE array false Assign the array of NSE symbol names to the NSE key.
BFO array false Assign the array of trading symbols to the BFO key.
NFO array false Include the NFO trading symbol in the array and assign it to the NFO key.
CDS array false Assign the array of CDS trading symbols to the CDS key.
MCX array false Assign the array of MCX trading symbols to the MCX key.
MFO array false Assign the array of MFO trading symbols to the MFO key.
INDEX array false Assign the array of index names to the INDEX key.

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
multiQuotes Object Get list of multiQuote.
exchange string Name of the exchange.
symbolName string Symbol name of the scrip.
tradingSymbol string Trading Symbol of the scrip.
optionType string Option Type (PE/CE).
instrumentType string Instrument Name.
companyName string Full name of the trading company.
isin string The standard ISIN representing stocks uniquely at international level. It is same for every exchange.
lotSize string Lot size of the symbol to be traded. At the time of placing order, the quantity should be in multiples of Broadlot Qty only.
strikePrice string The strike price is the predetermined price at which a put buyer can sell the underlying asset.
expiry string Shows expiry date of a trading symbol.
averagePrice string Average trading price of the equity or derivative.
totalTradeVolume string The total amount of shares or contracts that have been traded.
symbol string Actual symbol name of the scrip.
lastTradeTime string Last transaction time in milliseconds.
lastTradeQuantity string Quantity of last transaction.
lastTradePrice string Price at which last transaction / trade is done.
misMultiplier string The MIS multiplier indicates how many times a trader can exceed their available funds when purchasing shares."
change string Change value is the difference between the current value and the previous day's market close.
changePercent string Percentage of change between the current value and the previous day's market close.
open string Opening price of a market snapshot.
close string Close value of market snapshot.
previousClose string Previous close refers to the prior day's final price of security when the market officially closes for the day.
low string Low value of market snapshot.
high string High value of market snapshot.
tickSize string The value of a single price tick. Default value is 0.05 .
bidSize string the number of shares investors are trying to buy at a given price
bidPrice string The quantity of shares investors seek to purchase at a specified price.
totalTradedValue string
askSize string
askPrice string Ask Price that seller willing to take for the scrip
iv string

Search Equity & Derivative

Search Equity scrips

Code samples


var headers = {
  'Accept':'application/json',
  'x-session-token':'115aead43798e35cef8308c15cc79c7a'
};

$.ajax({
  url: 'https://tradeapi.samco.in/eqDervSearch/search?exchange=BFO&searchSymbolName=ZYDUSLIFE24MAYFUT',
  method: 'get',
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})


import requests
import json

headers = {
  'Accept': 'application/json',
  'x-session-token': '115aead43798e35cef8308c15cc79c7a'
}

r = requests.get('https://tradeapi.samco.in/eqDervSearch/search', params={
  'searchSymbolName': 'INFY'
}, headers = headers)

print r.json()

GET /eqDervSearch/search

This API is used to search equity, derivatives and commodity scrips based on user provided search symbol and exchange name.

Parameters

Name Type Required Description
exchange string false Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
searchSymbolName string true Trading Symbol of the scrip to be searched

Example responses

200 Response

{
    "serverTime": "05/04/24 16:44:12",
    "msgId": "c0c3fc7c-9000-4d74-8069-6f67009e7e63",
    "status": "Success",
    "statusMessage": "Request successful",
    "searchResults": [
        {
            "exchange": "BFO",
            "tradingSymbol": "ZYDUSLIFE24MAYFUT",
            "quantityInLots": "900",
            "instrument": "FUTSTK"
        }
    ]
}

Response Schema

Status Code 200

Name Type Description
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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
searchResults [object] Scrips Details available for the provided search text.
exchange string Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
scripDescription string scrip description
tradingSymbol string Trading Symbol of the scrip.
isin string The standard ISIN representing stocks uniquely at international level. It is same for every exchange.
bodLotQuantity string none
tickSize string The value of a single price tick. Default value is 0.05
instrument string Instrument Name.
quantityInLots string Lot size of the symbol to be traded. At the time of placing order, the quantity should be in multiples of Broadlot Qty only.

Option

Option Chain

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'115aead43798e35cef8308c15cc79c7a'
};

$.ajax({
  url: 'https://tradeapi.samco.in/option/optionChain?exchange=NFO&searchSymbolName=TCS&strikePrice=3800&optionType=CE&expiryDate=2024-04-25',
  method: 'get',
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})


import requests
import json

headers = {
  'Accept': 'application/json',
  'x-session-token': '115aead43798e35cef8308c15cc79c7a'
}

r = requests.get('https://tradeapi.samco.in/option/optionChain', params={
  'exchange':'NFO','searchSymbolName': 'TCS','strikePrice':'3800','optionType':'CE','expiryDate': '2024-04-25'
}, headers = headers)

print (r.json())

GET /option/optionChain

This API is used to search OptionChain for equity, derivatives and commodity scrips based on user provided search symbol and exchange name.

Parameters

Name Type Required Description
exchange string false Name of the exchange.Valid exchanges values (NFO/ BFO/ MCX/ CDS/ MFO).If the user does not provide an exchange name, by default considered as NFO.For trading with BFO, MFO, CDS and MCX, exchange is mandatory.
searchSymbolName string true Trading Symbol of the scrip to be searched
expiryDate string false From date in yyyy-MM-dd
strikePrice string true The strike price is the predetermined price at which a put buyer can sell the underlying asset
optionType string false Option Type (PE/CE).

Example responses

200 Response

{
    "serverTime": "10/04/24 12:22:26",
    "msgId": "2f030eb8-c689-4243-afb4-2e45e6fd0164",
    "status": "Success",
    "statusMessage": "OptionChain details retrived successfully. ",
    "optionChainDetails": [
        {
            "tradingSymbol": "TCS24APR3800CE",
            "exchange": "NSE",
            "symbol": "133428_NFO",
            "strikePrice": "3800.0000",
            "expiryDate": "2024-04-25",
            "instrument": "OPTSTK",
            "optionType": "CE",
            "underLyingSymbol": "TCS",
            "spotPrice": 3950.95,
            "lastTradedPrice": 190.95,
            "openInterest": 104300,
            "openInterestInLot": 596,
            "openInterestChange": 28350,
            "openInterestChangeInLot": 162,
            "oichangePer": "37.33",
            "volume": 55650,
            "bestBids": [
                {
                    "number": 1,
                    "quantity": "350",
                    "price": "190.90"
                },
                {
                    "number": 2,
                    "quantity": "525",
                    "price": "190.80"
                },
                {
                    "number": 3,
                    "quantity": "175",
                    "price": "190.50"
                },
                {
                    "number": 4,
                    "quantity": "350",
                    "price": "190.45"
                },
                {
                    "number": 5,
                    "quantity": "700",
                    "price": "190.35"
                }
            ],
            "bestAsks": [
                {
                    "number": 1,
                    "quantity": "175",
                    "price": "192.15"
                },
                {
                    "number": 2,
                    "quantity": "175",
                    "price": "192.20"
                },
                {
                    "number": 3,
                    "quantity": "175",
                    "price": "192.30"
                },
                {
                    "number": 4,
                    "quantity": "350",
                    "price": "192.40"
                },
                {
                    "number": 5,
                    "quantity": "350",
                    "price": "192.65"
                }
            ]
        }
    ]
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
optionChainDetails [object] Scrips Details available for the provided search text.
tradingSymbol string Trading Symbol of the scrip.
exchange string Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
symbol string Symbol Code of the trading Symbol
strikePrice string The strike price is the predetermined price at which a put buyer can sell the underlying asset.
expiryDate string Shows expiry date of a trading symbol.
instrument string Instrument Name.
optionType string Option Type (PE/CE).
underLyingSymbol string Root symbol of TradingSymbol
spotPrice string Spot price. Applicable in case of Futures and Options
lastTradedPrice string Price at which last transaction / trade is done
openInterest string Open interest is the Number of existing contracts held by buyers or sellers for any market for any given day.
openInterestChange string It shows Open interest change in Number of contracts held for market
oichangePer string It will shows the change % based on Open Interest
volume string Limit amount of a security traded on the specific day
bestBids [object] Most frequent trading bids for BUY
number string Sequence number for Bid/Ask
quantity string Quantity asked for trading.
price string Price asked for trading.
bestAsks [object] Most frequent trading asked for SELL
number string Sequence number for Bid/Ask
quantity string Quantity asked for trading.
price string Price asked for trading.

Future

Future Chain

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'e84ae32596c43f7d9260c9ece3d6b08e'
};

$.ajax({
  url: 'https://tradeapi.samco.in/future/futureChain?searchSymbolName=SENSEX&expiryDate=2024-04-12&exchange=BFO',
  method: 'get',
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
import json

headers = {
  'Accept': 'application/json',
  'x-session-token': 'e84ae32596c43f7d9260c9ece3d6b08e'
}

r = requests.get('https://tradeapi.samco.in/future/futureChain', params={
  'searchSymbolName': 'SENSEX','exchnage':'BFO','expiryDate':'2024-04-12'
}, headers = headers)

print (r.json())

GET /future/futureChain

This API is used to search futureChain for equity, derivatives, and commodity scripts based on the user-provided search symbol and exchange name.

Parameters

Name Type Required Description
exchange string false Name of the exchange.Valid exchanges values (NFO/BFO/CDS/MCX/MFO).If the user does not provide an exchange name, by default considered as NFO.For trading with CDS,BFO,MCX and MFO, exchange is mandatory.
searchSymbolName string true Trading Symbol of the scrip to be searched
expiryDate string false From date in yyyy-MM-dd

Example responses

200 Response

{
    "serverTime": "10/04/24 12:56:43",
    "msgId": "6f7ad177-15d9-44ee-a8c5-56b04e7f9afa",
    "status": "Success",
    "statusMessage": "Future chain details retrived successfully. ",
    "optionChainDetails": [
        {
            "tradingSymbol": "SENSEX24412FUT",
            "exchange": "BFO",
            "symbol": "859617_BFO",
            "expiryDate": "2024-04-12",
            "instrument": "IF",
            "underLyingSymbol": "SENSEX",
            "lastTradedPrice": "74871.0500",
            "openInterest": 1540,
            "openInterestInLot": 154,
            "openInterestChange": 1540,
            "openInterestChangeInLot": 154,
            "oichangePer": "Infinity",
            "volume": 2080,
            "bestBids": [
                {
                    "number": 1,
                    "quantity": "10",
                    "price": "74871.1016"
                },
                {
                    "number": 2,
                    "quantity": "10",
                    "price": "74855.8984"
                },
                {
                    "number": 3,
                    "quantity": "10",
                    "price": "74855.8516"
                },
                {
                    "number": 4,
                    "quantity": "10",
                    "price": "74855.2500"
                },
                {
                    "number": 5,
                    "quantity": "10",
                    "price": "74854.5000"
                }
            ],
            "bestAsks": [
                {
                    "number": 1,
                    "quantity": "10",
                    "price": "74877.7969"
                },
                {
                    "number": 2,
                    "quantity": "20",
                    "price": "74878.7031"
                },
                {
                    "number": 3,
                    "quantity": "10",
                    "price": "74878.7500"
                },
                {
                    "number": 4,
                    "quantity": "10",
                    "price": "74879.3984"
                },
                {
                    "number": 5,
                    "quantity": "10",
                    "price": "74879.6016"
                }
            ]
        }
    ]
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
futureChainDetails [object] Scrips Details available for the provided search text.
tradingSymbol string Trading Symbol of the scrip.
exchange string Exchange information indicates which exchange each trading symbol comes from.
symbol string Symbol Code of the trading Symbol
expiryDate string Shows expiry date of a trading symbol.
instrument string Instrument Name.
underLyingSymbol string Root symbol of TradingSymbol
spotPrice string Spot price. Applicable in case of Futures and Options
lastTradedPrice string Price at which last transaction / trade is done
openInterest string Open interest is the Number of existing contracts held by buyers or sellers for any market for any given day.
openInterestChange string It shows Open interest change in Number of contracts held for market
oichangePer string It will shows the change % based on Open Interest
volume string Limit amount of a security traded on the specific day
bestBids [object] Most frequent trading bids for BUY
number string Sequence number for Bid/Ask
quantity string Quantity asked for trading.
price string Price asked for trading.
bestAsks [object] Most frequent trading asked for SELL
number string Sequence number for Bid/Ask
quantity string Quantity asked for trading.
price string Price asked for trading.

User Limits

User Limits

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/limit/getLimits',
  method: 'get',
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/limit/getLimits'
,headers = headers)
print r.json()

GET /limit/getLimits

Gets the user cash balances, available margin for trading in equity and commodity segments.

Example responses

200 Response

{
    "serverTime": "10/04/24 13:29:07",
    "msgId": "77bb4c9b-17fc-4465-8e30-02e80eaff78c",
    "status": "Success",
    "statusMessage": "User Limit details retrieved successfully",
    "equityLimit": {
        "grossAvailableMargin": "0.00",
        "payInToday": "0",
        "notionalCash": "0",
        "marginUsed": "0",
        "netAvailableMargin": "0.00"
    },
    "commodityLimit": {
        "grossAvailableMargin": "0.00",
        "payInToday": "0",
        "notionalCash": "0",
        "marginUsed": "0",
        "netAvailableMargin": "0.00"
    }
}

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 The status of the API response. It can be either 'Success' or 'Failure'
statusMessage string A message describing the result of the API call.
grossAvailableMargin string Total amount of margins or balances available for trading. Opening balance for current day
payInToday string Current day deposited amount
notionalCash string Additional Limit that may or may not be given by RMS for Trading.
collateralMarginAgainstShares string Margin against shares offered by SAMCO to their clients for trading in stock and shares.
marginUsed string The amount deducted from opening balance for trading on the current day, and the amount blocked for creating a position when user places an order.
netAvailableMargin string Actual margin available with user for Trading after making all necessary adjustments.
grossAvailableMargin string Total amount of margins or balances available for trading. Opening balance for current day
payInToday string Current day deposited amount
notionalCash string Additional Limit that may or may not be given by RMS for Trading.
collateralMarginAgainstShares string Margin against shares offered by SAMCO to their clients for trading in stock and shares.
marginUsed string The amount deducted from opening balance for trading on the current day, and the amount blocked for creating a position when user places an order.
netAvailableMargin string Actual margin available with user for Trading after making all necessary adjustments.

Orders

Place Order

Body parameter

requestBody={
  "symbolName":"BANKEX24APR49800PE",
  "exchange":"BFO",
  "transactionType":"BUY",
  "orderType":"SL-M",
  "quantity": "15",
  "disclosedQuantity":"",
  "orderValidity":"DAY",
  "productType":"NRML",
  "afterMarketOrderFlag":"",
  "marketProtection":"2",
  "triggerPrice":"1"
}

Code samples

var headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'
};

$.ajax({
  url: 'https://tradeapi.samco.in/order/placeOrder',
  method: 'post',
  data: JSON.stringify(requestBody),
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
import json

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.post('https://tradeapi.samco.in/order/placeOrder'
, data=json.dumps(requestBody)
, headers = headers)

print (r.json())

POST /order/placeOrder

This API allows you to place an equity/derivative order to the exchange i.e the place order request typically registers the order with OMS and when it happens successfully, a success response is returned. Successful placement of an order via the API does not imply its successful execution. To be precise, under normal scenarios, the whole flow of order execution starting with order placement, routing to OMS and transfer to the exchange, order execution, and confirmation from exchange happen real time. But due to various reasons like market hours, exchange related checks etc. This may not happen instantly. So when an order is successfully placed the placeOrder API returns an orderNumber in response, and in scenarios as above the actual order status can be checked separately using the orderStatus API call.This is for Placing CNC, MIS and NRML Orders

Parameters

Name Type Required Description
symbolName string true Pass "name" in "symbolName" parameter for Equity Cash symbols and "Trading Symbol" for all the F&O contracts ('name' and 'tradingSymbol' is available in ScripMaster.csv).
exchange string true Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ BFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, BFO, CDS and MCX, exchange is mandatory.
transactionType string true Transaction type should be BUY or SELL
orderType string true Type of order. It can be one of the following, MKT - Market Order,L- Limit Order,SL - Stop Loss Limit,SL-M - Stop loss market
quantity string true Quantity with which order is being placed
disclosedQuantity string true If provided should be minimum of 10% of actual quantity
price string false Price mandatory when order type is L (Limit Order) OR SL(Stop Loss Limit)
priceType string true Price type required to place an order. Valid price type - LTP/ATP , default is LTP. Applicable for BO orders only.
marketProtection string true Percentage of MarketProtection required for ordertype MKT/SL-M to limit loss due to market price changes against the price with which order is placed. Default value is 3%.
orderValidity string true Order validity can be DAY / IOC .Day is an order type which is valid for the whole trading day and stays pending till it is executed in respective trading day. IOC(Immediate Or Cancel) order type is where once the user punches the order, the order hits the exchange and if not executed immediately, the order stands cancelled
afterMarketOrderFlag string true After Market Order Flag YES/NO
productType string true Product Type of the order. It can be CNC (Cash and Carry)NRML (Normal),MIS (Intraday)
triggerPrice string false The price at which an order should be triggered in case of SL, SL-M

Example responses

200 Response

{
    "serverTime": "15/04/24 11:57:43",
    "msgId": "aa1f9220-4a28-42ef-bc91-d363c1c6ac9f",
    "status": "Success",
    "orderNumber": "240415000064735",
    "statusMessage": "NRML Order request placed successfully",
    "exchangeOrderStatus": "REJECTED",
    "rejectionReason": "Required margin exceeds available margin.",
    "orderDetails": {
        "pendingQuantity": 0,
        "avgExecutionPrice": "0.00",
        "orderPlacedBy": "--",
        "tradingSymbol": "BANKEX24APR49800PE",
        "triggerPrice": "1.00",
        "exchange": "BFO",
        "totalQuantity": 15,
        "transactionType": "B",
        "productType": "NRML",
        "orderType": "SL",
        "quantity": 15,
        "filledQuantity": 0,
        "orderPrice": "0.65",
        "filledPrice": "0.00",
        "orderValidity": "DAY",
        "orderTime": "15/04/2024 11:57:43"
    }
}

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.
orderNumber string Unique Order identifier generated after placing an order which could be used for tracking order status
status string Status of the order. It would be success or failure
statusMessage string Order placement status Message
exchangeOrderStatus string Status of the order execution at Exchange side, Most common values are PENDING, COMPLETE, REJECTED, CANCELLED, and OPEN
rejectionReason string If an order is rejected, cause of order rejection which comes as user friendly textual description
orderDetails object none
pendingQuantity string Quantity which is in waiting state to be filled in a specific trade
avgExecutionPrice string Average price at which the quantities were bought/sold during the day
orderPlacedBy string Client code of the user who placed the order
tradingSymbol string Trading Symbol of the scrip.
triggerPrice string The price at which an order should be triggered in case of SL, SL-M.
exchange string Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
totalQuantity string Total Quantity
expiry string expiry date of trading symbol
transactionType string Type of the transaction, BUY / SELL.
productType string Product Type of order as placed by the user. It can be CNC (Cash and Carry),BO (Bracket Order),CO (Cover Order),NRML (Normal),MIS (Intraday).
orderType string Type of order user has placed . It can be one of the following, MKT - Market Order,L- Limit Order,SL - Stop Loss Limit,SL-M - Stop loss market.
quantity string Order Quantity as placed by the user
filledQuantity string Quantity which is filled in a specific trade. Can be less than or equal to the total quantity
orderPrice string Limit price entered at the time of placing the order.
filledPrice string Price at which exchange has filled the order
exchangeOrderNo string Order identifier at the exchange.
orderValidity string validity of the order
orderTime string Order placement time

Place BO Order

Body parameter

requestBody={
  "symbolName": "RELIANCE",
  "exchange": "NSE",
  "transactionType": "BUY",
  "orderType": "L",
  "quantity": "1",
  "disclosedQuantity": "1",
  "price": "1240.0",
  "priceType": "LTP",
  "orderValidity": "DAY",
  "productType": "BO",
  "squareOffValue": "5",
  "stopLossValue": "5",
  "valueType": "Ticks",
  "trailingStopLoss": "5"
}

Code samples

var headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'
};

$.ajax({
  url: 'https://tradeapi.samco.in/order/placeOrderBO',
  method: 'post',
  data: JSON.stringify(requestBody),
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
import json

headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.post('https://tradeapi.samco.in/order/placeOrderBO'
, data=json.dumps(requestBody)
, headers = headers)

print (r.json())

POST /order/placeOrderBO

This API allows you to place an equity/derivative order to the exchange i.e the place order request typically registers the order with OMS and when it happens successfully, a success response is returned. Successful placement of an order via the API does not imply its successful execution. To be precise, under normal scenarios, the whole flow of order execution starting with order placement, routing to OMS and transfer to the exchange, order execution, and confirmation from exchange happen real time. But due to various reasons like market hours, exchange related checks etc. This may not happen instantly. So when an order is successfully placed the placeOrder API returns an orderNumber in response, and in scenarios as above the actual order status can be checked separately using the orderStatus API call. This is for Placing BO Orders.

Parameters

Name Type Required Description
body object false none
symbolName string true Pass "name" in "symbolName" parameter for Equity Cash symbols and "Trading Symbol" for all the F&O contracts ('name' and 'tradingSymbol' is available in ScripMaster.csv)
exchange string true Name of the exchange.Valid exchanges values (NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with NFO, CDS and MCX, exchange is mandatory. BO orders not applicable to place in BSE exchange.
transactionType string true Transaction type should be BUY or SELL
orderType string true Type of order. It should be L- Limit Order
quantity string true Quantity with which order is being placed
disclosedQuantity string true If provided should be minimum of 10% of actual quantity
price string true Price at which the order will be placed
priceType string true Price type required to place an order. Valid price type - LTP/ATP , default is LTP. Applicable for BO orders only.
orderValidity string true Order validity should be DAY .Day is an order type which is valid for the whole trading day and stays pending till it is executed in respective trading day.
productType string true Product Type of the order. It can be BO (Bracket Order)
squareOffValue string true Price difference from entry price at which the order should be squared off to limit losses (eg: if Order price is 300. Profit target is 305. So target = 5). Applicable for BO orders only
stopLossValue string true Stoploss price difference from the entry price at which the order should be squared off (eg: if Order price is 300. Stoploss target is 295. So stop loss = 5). Applicable for both BO & CO
valueType string true ValueType required to place an Order. Applicable for both Stop Loss Value and Square off value. Valid value types - Absolute/Ticks. Default is Absolute.Applicable for BO orders only.
trailingStopLoss string true Incremental value set as % of change from the market price. Trailing stop moves as the price moves up. but, if the price starts to fall, the stop loss does not move (For example, if you buy a stock at Rs 100 and set a trailing stop loss value of Rs 2. If the stock price moves up to say Rs 105, the trailing stop loss value also would move up to be Rs 103 and stays Rs 2 less than the current market price. But if the stock price starts to fall and becomes Rs 103, trailing stop loss order will become a market order. Applicable for BO orders only

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "orderNumber": "190726000001077",
  "status": "Success",
  "exchangeOrderStatus": "Executed",
  "rejectionReason": "--",
  "statusMessage": "BO Order request placed successfully",
  "orderDetails": {
    "pendingQuantity": "0",
    "avgExecutionPrice": "1193.00",
    "orderPlacedBy": "DV9999",
    "tradingSymbol": "RELIANCE",
    "triggerPrice": "0.00",
    "exchange": "NSE",
    "totalQuantity": "1",
    "expiry": "--",
    "transactionType": "BUY",
    "productType": "BO",
    "orderType": "L",
    "quantity": "1",
    "filledQuantity": "1",
    "orderPrice": "1240.00",
    "filledPrice": "1240.0",
    "exchangeOrderNo": "1565067682526005486",
    "orderValidity": "DAY",
    "orderTime": "12/12/2019 16:20:09"
  }
}

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.
orderNumber string Unique Order identifier generated after placing an order which could be used for tracking order status
status string Status of the order. It would be success or failure
exchangeOrderStatus string Status of the order execution at Exchange side, Most common values are PENDING, COMPLETE, REJECTED, CANCELLED, and OPEN
rejectionReason string If an order is rejected, cause of order rejection which comes as user friendly textual description
statusMessage string Order placement status Message
orderDetails object none
pendingQuantity string Quantity which is in waiting state to be filled in a specific trade
avgExecutionPrice string Average price at which the quantities were bought/sold during the day
orderPlacedBy string Client code of the user who placed the order
tradingSymbol string Trading Symbol of the scrip.
triggerPrice string The price at which an order should be triggered in case of SL, SL-M.
exchange string Name of the exchange.Valid exchanges values (NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with NFO, CDS and MCX, exchange is mandatory. BO orders not applicable for BSE exchange.
totalQuantity string Total Quantity
expiry string expiry date of trading symbol
transactionType string Type of the transaction, BUY / SELL.
productType string Product Type of order as placed by the user is BO (Bracket Order)
orderType string Type of order user has placed . It can be one of the following, MKT - Market Order,L- Limit Order,SL - Stop Loss Limit,SL-M - Stop loss market.
quantity string Order Quantity as placed by the user
filledQuantity string Quantity which is filled in a specific trade. Can be less than or equal to the total quantity
orderPrice string Limit price entered at the time of placing the order.
filledPrice string Price at which exchange has filled the order
exchangeOrderNo string Order identifier at the exchange.
orderValidity string validity of the order
orderTime string Order placement time

Place CO Order

Code samples

var headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/order/placeOrderCO',
  method: 'post',
  data: JSON.stringify(requestBody),
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.post('https://tradeapi.samco.in/order/placeOrderCO'
, data=json.dumps(requestBody)
, headers = headers)

print r.json()

POST /order/placeOrderCO

This API allows you to place an equity/derivative order to the exchange i.e the place order request typically registers the order with OMS and when it happens successfully, a success response is returned. Successful placement of an order via the API does not imply its successful execution. To be precise, under normal scenarios, the whole flow of order execution starting with order placement, routing to OMS and transfer to the exchange, order execution, and confirmation from exchange happen real time. But due to various reasons like market hours, exchange related checks etc. This may not happen instantly. So when an order is successfully placed the placeOrder API returns an orderNumber in response, and in scenarios as above the actual order status can be checked separately using the orderStatus API call. This is for Placing CO Orders.

Body parameter

requestBody={
  "symbolName": "RELIANCE",
  "exchange": "BSE",
  "transactionType": "BUY",
  "orderType": "L",
  "quantity": "1",
  "disclosedQuantity": "1",
  "price": "1240.0",
  "orderValidity": "DAY",
  "productType": "CO",
  "triggerPrice": "1070.00"
}

Parameters

Name Type Required Description
body object false none
symbolName string true Pass "name" in "symbolName" parameter for Equity Cash symbols and "Trading Symbol" for all the F&O contracts ('name' and 'tradingSymbol' is available in ScripMaster.csv)
exchange string true Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
transactionType string true Transaction type should be BUY or SELL
orderType string true Type of order. It can be one of the following, MKT - Market Order,L- Limit Order
quantity string true Quantity with which order is being placed
disclosedQuantity string true If provided should be minimum of 10% of actual quantity
price string true Price at which the order will be placed
orderValidity string true Order validity should be DAY .Day is an order type which is valid for the whole trading day and stays pending till it is executed in respective trading day.
productType string true Product Type of the order. It can be CO (Cover Order))
triggerPrice string false The price at which an order should be triggered

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "orderNumber": "190726000001077",
  "status": "Success",
  "exchangeOrderStatus": "Executed",
  "rejectionReason": "--",
  "statusMessage": "CO Order request placed successfully",
  "orderDetails": {
    "pendingQuantity": "0",
    "avgExecutionPrice": "1193.00",
    "orderPlacedBy": "DV9999",
    "tradingSymbol": "RELIANCE",
    "triggerPrice": "0.00",
    "exchange": "BSE",
    "totalQuantity": "1",
    "expiry": "--",
    "transactionType": "BUY",
    "productType": "CO",
    "orderType": "L",
    "quantity": "1",
    "filledQuantity": "1",
    "orderPrice": "1240.00",
    "filledPrice": "1240.0",
    "exchangeOrderNo": "1565067682526005486",
    "orderValidity": "DAY",
    "orderTime": "12/12/2019 16:20:09"
  }
}

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.
orderNumber string Unique Order identifier generated after placing an order which could be used for tracking order status
status string Status of the order. It would be success or failure
exchangeOrderStatus string Status of the order execution at Exchange side, Most common values are PENDING, COMPLETE, REJECTED, CANCELLED, and OPEN
rejectionReason string If an order is rejected, cause of order rejection which comes as user friendly textual description
statusMessage string Order placement status Message
orderDetails object none
pendingQuantity string Quantity which is in waiting state to be filled in a specific trade
avgExecutionPrice string Average price at which the quantities were bought/sold during the day
orderPlacedBy string Client code of the user who placed the order
tradingSymbol string Trading Symbol of the scrip.
triggerPrice string The price at which an order should be triggered in case of SL, SL-M.
exchange string Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
totalQuantity string Total Quantity
expiry string expiry date of trading symbol
transactionType string Type of the transaction, BUY / SELL.
productType string Product Type of order as placed by the user is CO (Cover Order)
orderType string Type of order user has placed . It can be one of the following, MKT - Market Order,L- Limit Order,SL - Stop Loss Limit,SL-M - Stop loss market.
quantity string Order Quantity as placed by the user
filledQuantity string Quantity which is filled in a specific trade. Can be less than or equal to the total quantity
orderPrice string Limit price entered at the time of placing the order.
filledPrice string Price at which exchange has filled the order
exchangeOrderNo string Order identifier at the exchange.
orderValidity string validity of the order
orderTime string Order placement time

Get Order Status

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/order/getOrderStatus?orderNumber=190707000000004',
  method: 'get',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/order/getOrderStatus', params={
  'orderNumber': '190707000000004'
}, headers = headers)

print r.json()

GET /order/getOrderStatus

Get status of an order placed previously. This API returns all states of the orders,but not limited to open, pending, and partially filled ones.

Parameters

Name Type Required Description
orderNumber string true Order Number for which the user wants to check the order status

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "orderNumber": "190722000000243",
  "orderStatus": "Success",
  "statusMessage": "Requested MIS Order placed successfully",
  "orderDetails": {
    "pendingQuantity": "0",
    "avgExecutionPrice": "1193.00",
    "orderPlacedBy": "DV9999",
    "tradingSymbol": "RELIANCE",
    "triggerPrice": "0.00",
    "exchange": "BSE",
    "totalQuantity": "1",
    "expiry": "--",
    "transactionType": "BUY",
    "productType": "MIS",
    "orderType": "L",
    "quantity": "1",
    "filledQuantity": "1",
    "orderPrice": "1240.00",
    "filledPrice": "1240.0",
    "exchangeOrderNo": "1565067682526005486",
    "orderValidity": "DAY",
    "orderTime": "12/12/2019 16:20:09"
  }
}

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.
orderNumber string Unique number generated at the exchange while placing an order
orderStatus string Status of the order at Exchange side, Most common values are PENDING, COMPLETE, REJECTED, CANCELLED, and OPEN
statusMessage string Status Message of the order
orderDetails object none
pendingQuantity string Quantity which is in waiting state to be filled in a specific trade
avgExecutionPrice string Average price at which the quantities were bought/sold during the day
orderPlacedBy string Client code of the user who placed the order
tradingSymbol string Trading Symbol of the scrip.
triggerPrice string The price at which an order should be triggered in case of SL, SL-M.
exchange string Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
totalQuantity string Total Quantity
expiry string expiry date of trading symbol
transactionType string Type of the transaction, BUY / SELL.
productType string Product Type of order as placed by the user. It can be CNC (Cash and Carry),BO (Bracket Order),CO (Cover Order),NRML (Normal),MIS (Intraday).
orderType string Type of order user has placed . It can be one of the following, MKT - Market Order,L- Limit Order,SL - Stop Loss Limit,SL-M - Stop loss market.
quantity string Order Quantity as placed by the user
filledQuantity string Quantity which is filled in a specific trade. Can be less than or equal to the total quantity
orderPrice string Limit price entered at the time of placing the order.
filledPrice string Price at which exchange has filled the order
exchangeOrderNo string Order identifier at the exchange.
orderValidity string validity of the order
orderTime string Order placement time

Order Book

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/order/orderBook',
  method: 'get',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/order/orderBook'
, headers = headers)
print r.json()

GET /order/orderBook

Orderbook retrieves and displays details of all orders placed by the user on a specific day. This API returns all states of the orders, namely, open, pending, rejected and executed ones.

Parameters

Name Type Required Description

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "statusMessage": "Request successful",
  "orderBookDetails": [
    {
      "orderNumber": "191206000000079",
      "exchange": "BSE",
      "tradingSymbol": "RELIANCE",
      "symbolDescription": "RELIANCE INDUSTRIES LTD.",
      "transactionType": "BUY",
      "productCode": "MIS",
      "orderType": "L",
      "orderPrice": "1560.15",
      "quantity": "13",
      "disclosedQuantity": "1",
      "triggerPrice": "1090.00",
      "marketProtection": "3",
      "orderValidity": "DAY",
      "orderStatus": "Complete",
      "orderValue": "20281.95",
      "instrumentName": "NA",
      "orderTime": "06-Dec-2019 13:47:04",
      "userId": "DV99999",
      "filledQuantity": "13",
      "fillPrice": "1560.15",
      "averagePrice": "1560.15",
      "unfilledQuantity": "0",
      "exchangeOrderId": "1575608622401000995",
      "rejectionReason": "NA",
      "exchangeConfirmationTime": "06-Dec-2019 14:14:47",
      "cancelledQuantity": "0",
      "referenceLimitPrice": "0.00",
      "coverOrderPercentage": "0.00",
      "orderRemarks": "--",
      "exchangeOrderNumber": "1575608622401000995",
      "symbol": "52310_NFO",
      "displayStrikePrice": "0.00",
      "displayNetQuantity": "10",
      "status": "complete",
      "exchangeStatus": "complete",
      "expiry": "--",
      "pendingQuantity": "0",
      "instrument": "--",
      "scripName": "--",
      "totalQuanity": "13",
      "optionType": "--",
      "orderPlaceBy": "DV99999",
      "lotQuantity": "1",
      "parentOrderId": "200824000050316"
    }
  ]
}

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 Response status. Can be Success or Failure
statusMessage string status Message
orderBookDetails [object] List of all orders with details during the day
orderNumber string Unique Order identifier generated after placing an order
exchange string Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
tradingSymbol string Trading Symbol of the scrip.
symbolDescription string Scrip description
transactionType string Type of the transaction, BUY / SELL.
productCode string Product Type of order as placed by the user. It can be CNC (Cash and Carry),BO (Bracket Order),CO (Cover Order),NRML (Normal),MIS (Intraday).
orderType string Type of order user has placed . It can be one of the following, MKT - Market Order,L- Limit Order,SL - Stop Loss Limit,SL-M - Stop loss market.
orderPrice string Total price of a particular order
quantity string Total Quantity as placed by the user
disclosedQuantity string If provided should be minimun of 10% of actual quantity.
triggerPrice string The price at which an order should be triggered in case of SL, SL-M.
marketProtection string Percentage of MarketProtection required for ordertype MKT/SL-M to limit loss due to market price changes against the price with which order is placed. Default value is 3%.
orderValidity string Order validity can be DAY / IOC
orderStatus string Status of the order at Exchange side, either executed successfully or pending or rejected
orderValue string Value of the order
instrumentName string Name of the instrument
orderTime string Order placement time
userId string The client Code provided to you by SAMCO after opening an account.
filledQuantity string Quantity which is filled in a specific trade. Can be less than or equal to the total quantity
fillPrice string Price at which exchange has filled the order
averagePrice string Average trading price of the equity
unfilledQuantity string Quantity which is not filled in a partially filled order. Can be less than or equal to the total quantity
exchangeOrderId string Unique Order identifier generated from exchange
rejectionReason string If order is rejected, Cause of order Rejection
exchangeConfirmationTime string Order confirmation time at exchange
cancelledQuantity string cancelled quantity for partial cancelled orders
referenceLimitPrice string Limit Price reference
coverOrderPercentage string Percentage of cover order
orderRemarks string Remarks about order
exchangeOrderNumber string Unique Order identifier generated after placing an order
symbol string symbol about stock
displayStrikePrice string Shows the strick price
displayNetQuantity string Display the limit quantity of order
status string Status will display Executed/Pending/Rejected
exchangeStatus string ExchangeStatus will display Executed/Pending/Rejected
expiry string shows ExpiryDate of the stock
pendingQuantity string PendingQuantity will show pending quantity stock
instrument string Instrument is about the type of stock. FUT/OPT
scripName string Name of the scrip
totalQuanity string Total Quantity
optionType string Option Type (PE/CE).
orderPlaceBy string Client code of the user who placed the order
lotQuantity string lotQuantity represents the number of contracts contained in one derivative security.Applicable for F & O
parentOrderId string order Id of the parent order(it is applicable for only BO/CO orders)

TriggerOrders

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/order/getTriggerOrders?orderNumber=190707000000004',
  method: 'get',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/order/getTriggerOrders', params={
  'orderNumber': '190707000000004'
}, headers = headers)

print r.json()

GET /order/getTriggerOrders

This API allows you to get the trigger order numbers in case of BO and CO orders so that their attribute values can be modified for BO orders, it will give the order identifiers. For Stop loss leg and target leg. Similarly for CO orders, it will return order identifier of stop loss leg only. Using the order identifier, the user would be able to modify the order attributes using the modifyOrder API. Refer modifyOrder API documentation for the parameters details.

Parameters

Name Type Required Description
orderNumber string true Order Number for which the user wants to check the order status

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "statusMessage": "SubOrder details retrieved successfully.",
  "triggerOrders": [
    {
      "stopLossOrderNo": "191219000000063",
      "orderStatus": "Complete",
      "orderPrice": "351.20",
      "triggerPrice": "331.20"
    }
  ]
}

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 Response status. Can be Success or Failure
statusMessage string status Message
triggerOrders [object] Trigger order Details available for the provided OrderNumber.
stopLossOrderNo string Unique Order identifier generated from exchange
orderStatus string Status of the order at Exchange side, either executed successfully complete or trigger pending or cancelled
orderPrice string price of a particular order
triggerPrice string The price at which an order should be triggered

Modify Order

Code samples

var headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/order/modifyOrder/{orderNumber}',
  method: 'put',
  data: JSON.stringify(requestBody),
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.put('https://tradeapi.samco.in/order/modifyOrder/{orderNumber}'
, data=json.dumps(requestBody)
, headers = headers)

print r.json()

PUT /order/modifyOrder/{orderNumber}

User would be able to modify some attributes of an order as long as it is with open/pending status in system. For modification order identifier is mandatory. With order identifier you need to send the optional parameter(s) which needs to be modified. In case the optional parameters aren't sent, the default will be considered from the original order. Modifiable attributes include quantity, Order Type (L,MKT, SL,SL-M). This API cannot be used for modifying attributes of an executed/rejected/cancelled order. Only the attribute that needs to be modified should be sent in the request alongwith the Order Identifier.

Body parameter

requestBody={
  "orderType": "L",
  "quantity": "3",
  "disclosedQuantity": "1",
  "orderValidity": "DAY",
  "price": "1240.00",
  "triggerPrice": "1070.00",
  "parentOrderId": "190707000000004",
  "marketProtection": "5"
}

Parameters

Name Type Required Description
orderNumber string true Unique Order identifier of the order which needs to be modified
body object false Type of order. MKT - Market Order,L - Limit Order, SL - Stop Loss Limit, SL-M - Stop Loss Market
orderType string false Type of order user has placed . It can be one of the following, MKT - Market Order,L- Limit Order,SL - Stop Loss Limit,SL-M - Stop loss market.
quantity string false Quantity of the order user wants to modify
disclosedQuantity string false Quantity to disclose publicly
orderValidity string true Order validity can be DAY or IOC
price string false Price at which the order was placed
triggerPrice string false The price at which an order should be triggered in case of SL, SL-M.
parentOrderId string true ParentOrderId required to modify an order (applicable for BO orders only)
marketProtection string false Percentage of MarketProtection required for ordertype MKT/SL-M to limit loss due to market price changes against the price with which order is placed. Default value is 3%.

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "orderNumber": "191206000000079",
  "status": "Success",
  "statusMessage": "MIS Order request placed successfully",
  "exchangeOrderStatus": "complete",
  "rejectionReason": "--",
  "orderDetails": {
    "pendingQuantity": "0",
    "avgExecutionPrice": "1193.00",
    "orderPlacedBy": "DV9999",
    "tradingSymbol": "RELIANCE",
    "triggerPrice": "0.00",
    "exchange": "BSE",
    "totalQuantity": "1",
    "expiry": "--",
    "transactionType": "BUY",
    "productType": "MIS",
    "orderType": "L",
    "quantity": "1",
    "filledQuantity": "1",
    "orderPrice": "1240.00",
    "filledPrice": "1240.0",
    "exchangeOrderNo": "1565067682526005486",
    "orderValidity": "DAY",
    "orderTime": "12/12/2019 16:20:09"
  }
}

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.
orderNumber string Unique Order identifier generated after placing an order which could be used for tracking order status
status string Status of the order. It would be success or failure
statusMessage string Order placement status Message
exchangeOrderStatus string Status of the order execution at Exchange side, Most common values are PENDING, COMPLETE, REJECTED, CANCELLED, and OPEN
rejectionReason string If an order is rejected, cause of order rejection which comes as user friendly textual description
orderDetails object none
pendingQuantity string Quantity which is in waiting state to be filled in a specific trade
avgExecutionPrice string Average price at which the quantities were bought/sold during the day
orderPlacedBy string Client code of the user who placed the order
tradingSymbol string Trading Symbol of the scrip.
triggerPrice string The price at which an order should be triggered in case of SL, SL-M.
exchange string Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
totalQuantity string Total Quantity
expiry string expiry date of trading symbol
transactionType string Type of the transaction, BUY / SELL.
productType string Product Type of order as placed by the user. It can be CNC (Cash and Carry),BO (Bracket Order),CO (Cover Order),NRML (Normal),MIS (Intraday).
orderType string Type of order user has placed . It can be one of the following, MKT - Market Order,L- Limit Order,SL - Stop Loss Limit,SL-M - Stop loss market.
quantity string Order Quantity as placed by the user
filledQuantity string Quantity which is filled in a specific trade. Can be less than or equal to the total quantity
orderPrice string Limit price entered at the time of placing the order.
filledPrice string Price at which exchange has filled the order
exchangeOrderNo string Order identifier at the exchange.
orderValidity string validity of the order
orderTime string Order placement time

Cancel BO Order

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/order/exitBO?orderNumber=190707000000004',
  method: 'delete',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.delete('https://tradeapi.samco.in/order/exitBO', params={
  'orderNumber': '190707000000004'
}, headers = headers)

print r.json()

DELETE /order/exitBO

For Cancellation/exit of BO orders pass main leg Order number. If main leg is in Open/Pending state that order will be cancelled. If the main leg is executed and the sublegs are created and in open/Trigger pending state, the order will be exited. If the main leg is executed and if either of Stop loss or target is hit, API will return error message "SubOrder is in Executed status. Cannot exit/cancel such orders."

Parameters

Name Type Required Description
orderNumber string true The main order identifier provided as an input which needs to be exited.

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "orderNumber": "190722000000243",
  "statusMessage": "Order cancellation request placed successfully"
}

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
orderNumber string Unique Order identifier generated after placing an order
statusMessage string Status Message for the order cancellation request

Cancel CO Order

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/order/exitCO?orderNumber=190707000000004',
  method: 'delete',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.delete('https://tradeapi.samco.in/order/exitCO', params={
  'orderNumber': '190707000000004'
}, headers = headers)

print r.json()

DELETE /order/exitCO

For Cancellation/exit of CO orders pass main leg Order number. If main leg is in Open/Pending state that order will be cancelled. If the main leg is executed and the sublegs are created and in open/Trigger pending state, the order will be exited. If the main leg is executed and if Stop loss is hit, API will return error message "SubOrder is in Executed status. Cannot exit/cancel such orders."

Parameters

Name Type Required Description
orderNumber string true The main order identifier provided as an input which needs to be exited.

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "orderNumber": "190722000000243",
  "statusMessage": "Order cancellation request placed successfully"
}

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
orderNumber string Unique Order identifier generated after placing an order
statusMessage string Status Message for the order cancellation request

Cancel Order

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/order/cancelOrder?orderNumber=190707000000004',
  method: 'delete',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.delete('https://tradeapi.samco.in/order/cancelOrder', params={
  'orderNumber': '190707000000004'
}, headers = headers)

print r.json()

DELETE /order/cancelOrder

An order which is open or pending in system can be cancelled. In other words, cancellation cannot be initiated for already Executed, Rejected orders.This is for CNC, MIS and NRML Orders.

Parameters

Name Type Required Description
orderNumber string true The order identifier provided as an input which needs to be cancelled

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "orderNumber": "190722000000243",
  "statusMessage": "Order cancellation request placed successfully"
}

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
orderNumber string Unique Order identifier generated after placing an order
statusMessage string Status Message for the order cancellation request

TradeBook

Trade Book

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/trade/tradeBook',
  method: 'get',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/trade/tradeBook'
, headers = headers)

print r.json()

GET /trade/tradeBook

Details of all successfully executed orders placed by the user.

Parameters

Name Type Required Description

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "statusMessage": "Request successful",
  "tradeBookDetails": [
    {
      "orderNumber": "191206000000079",
      "exchange": "BSE",
      "tradingSymbol": "RELIANCE",
      "symbolDescription": "RELIANCE INDUSTRIES LTD.",
      "transactionType": "BUY",
      "productCode": "MIS",
      "orderType": "L",
      "orderPrice": "1560.15",
      "quantity": "13",
      "disclosedQuantity": "1",
      "triggerPrice": "0.00",
      "marketProtection": "3",
      "orderValidity": "DAY",
      "orderStatus": "Complete",
      "orderValue": "20281.95",
      "instrumentName": "NA",
      "orderTime": "06-Dec-2019 13:47:04",
      "userId": "DV99999",
      "filledQuantity": "13",
      "unfilledQuantity": "0",
      "exchangeConfirmationTime": "05:06:12",
      "coverOrderPercentage": "%",
      "exchangeOrderNumber": "1571202357797000054",
      "tradeNumber": "195300",
      "tradePrice": "1560.15",
      "tradeDate": "06DEC2019",
      "tradeTime": "02:14:47 PM",
      "strikePrice": "800.00",
      "optionType": "XX",
      "lastTradePrice": "2,077.00",
      "expiry": "NA"
    }
  ]
}

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 Response status. Can be Success or Failure
statusMessage string status Message
tradeBookDetails [object] Get list of TradeBookEntries.
orderNumber string Unique Order identifier generated after placing an order
exchange string Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
tradingSymbol string Trading Symbol of the scrip.
symbolDescription string Scrip description
transactionType string Type of the transaction, BUY / SELL.
productCode string Product Type of order as placed by the user. It can be CNC (Cash and Carry),BO (Bracket Order),CO (Cover Order),NRML (Normal),MIS (Intraday).
orderType string Type of order user has placed . It can be one of the following, MKT - Market Order,L- Limit Order,SL - Stop Loss Limit,SL-M - Stop loss market.
orderPrice string Limit price of a particular order
quantity string It is the order quantity
disclosedQuantity string Quantity to disclose to public in the market
triggerPrice string The price at which an order should be triggered in case of SL, SL-M.
marketProtection string Percentage of MarketProtection required for ordertype MKT/SL-M to limit loss due to market price changes against the price with which order is placed. Default value is 3%.
orderValidity string Order validity can be DAY / IOC
orderStatus string Status of the order at Exchange side, either executed successfully or pending or rejected
orderValue string Value of the order
instrumentName string Name of the instrument
orderTime string Order placement time
userId string The client Code provided to you by SAMCO after opening an account.
filledQuantity string Quantity which is filled in a specific trade. Can be less than or equal to the total quantity
unfilledQuantity string Quantity which is not filled in a partially filled order. Can be less than or equal to the total quantity
exchangeConfirmationTime string Order confirmation time at exchange
coverOrderPercentage string Percentage of cover order
exchangeOrderNumber string Unique Order identifier generated after placing an order.
tradeNumber string Unique trade identifier generated for every trade.
tradePrice string Price of a trade.
tradeDate string Date of a trade.
tradeTime string Time of a trade.
strikePrice string The strike price is the predetermined price at which a put buyer can sell the underlying asset.
optionType string Option Type (PE/CE).
lastTradePrice string Price at which last transaction/trade is done
expiry string Shows expiry date of a trading symbol.

Positions

User Positions

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/position/getPositions?positionType=DAY',
  method: 'get',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/position/getPositions', params={
  'positionType': 'DAY'
}, headers = headers)

print r.json()

GET /position/getPositions

Get position details of the user (The details of equity, derivative, commodity, currency borrowed or owned by the user).

Parameters

Name Type Required Description
positionType string true Position type can be DAY/NET. If Position type is “DAY”, fetch current day position details, If Position Type is “NET”, fetch carry forward position details

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "statusMessage": "Request successful",
  "positionSummary": {
    "gainingTodayCount": "2",
    "losingTodayCount": "2",
    "totalGainAndLossAmount": "0.00",
    "dayGainAndLossAmount": "-4910.00"
  },
  "positionDetails": [
    {
      "averagePrice": "1560.15",
      "exchange": "BSE",
      "markToMarketPrice": "-182.70",
      "lastTradedPrice": "1,550.00",
      "previousClose": "1552.55",
      "productCode": "CNC",
      "symbolDescription": "RELIANCE INDUSTRIES LTD.",
      "tradingSymbol": "RELIANCE",
      "calculatedNetQuantity": "18.0",
      "averageBuyPrice": "1560.15",
      "averageSellPrice": "0.00",
      "boardLotQuantity": "1",
      "boughtPrice": "28082.70",
      "buyQuantity": "18",
      "carryForwardQuantity": "0",
      "carryForwardValue": "0.00",
      "multiplier": "1",
      "netPositionValue": "-182.70",
      "netQuantity": "18",
      "netValue": "-182.70",
      "positionType": "DAY",
      "positionConversions": "CNC, NRML",
      "soldValue": "0.00",
      "transactionType": "BUY",
      "realizedGainAndLoss": "0.00",
      "unrealizedGainAndLoss": "-182.70",
      "companyName": "RELIANCE INDUSTRIES LTD.",
      "expiryDate": "--",
      "optionType": "--"
    }
  ]
}

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 Response status. Can be Success or Failure
statusMessage string status Message
positionSummary object none
gainingTodayCount string Count of scrips which are gaining in value in a trading day
losingTodayCount string Count of scrips which are losing in value in a trading day
totalGainAndLossAmount string Total amount of Gain / Loss for all existing positions since their creation
dayGainAndLossAmount string Amount of Gain / Loss for all positions on a specific trading day
positionDetails [object] Details of Day/Net positions as queried
averagePrice string Average trading price of the equity
exchange string Name of the exchange.Valid exchanges values (BSE/ NSE) If the user does not provide an exchange name, by default considered as NSE.
markToMarketPrice string Price change between previous close price and current price
lastTradedPrice string Price at which last transaction/trade is done
previousClose string Previous close refers to the prior day's final price of security when the market officially closes for the day.
productCode string Type of the product, allowable type is CNC
symbolDescription string Scrip Description
tradingSymbol string Symbol name of the scrip.
calculatedNetQuantity string Quantity left after the day
averageBuyPrice string Average price at which the quantities were bought
averageSellPrice string Average price at which the quantities were sold
boardLotQuantity string The standardized number of shares decided by the exchange as a trading unit
boughtPrice string Price at which quantities were bought during the day
buyQuantity string Total quantity brought and added to the position during the day
carryForwardQuantity string Quantity bought or sold in previous session
carryForwardValue string Net value of the position in previous session
multiplier string The lot size multiplier used to calculate Profit and Loss
netPositionValue string Net value of the position during the day
netQuantity string Limit quantity of the position
netValue string Net value of the bought quantities
positionType string Type of the position, Ex -Day/Net
positionConversions [string] Different Product types the user can Convert an existing position to
soldValue string Total value of sold quantities
transactionType string Type of the transaction, BUY / SELL.
realizedGainAndLoss string The Profit and Loss returns from a closed position
unrealizedGainAndLoss string The Profit and Loss returns from a open position
companyName string Full name of the trading company
expiryDate string Expiry date of the scrip
optionType string Option Type (PE/CE).

Position Conversion

Code samples

var headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/position/convertPosition',
  method: 'post',
  data: JSON.stringify(requestBody),
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.post('https://tradeapi.samco.in/position/convertPosition'
, data=json.dumps(requestBody)
, headers = headers)

print r.json()

POST /position/convertPosition

Convert an existing position of a margin product to a different margin product type. All or a subset of an existing position quantity can be converted to a different product type.The available margin product types are MARGIN_INTRADAY_SQUAREOFF(MIS), CASHNCARRY(CNC), NORMAL(NRML).

Body parameter

requestBody={
  "symbolName": "RELIANCE",
  "exchange": "BSE",
  "transactionType": "BUY",
  "positionType": "DAY",
  "netQuantity": "18",
  "quantityToConvert": "2",
  "fromProductType": "MIS",
  "toProductType": "CNC"
}

Parameters

Name Type Required Description
body object false none
symbolName string true Symbol name of the scrip
exchange string true Name of the exchange. If the user does not provide an exchange name, by default considered as NSE
transactionType string true Transaction type can be either BUY or SELL
positionType string true DAY or NET
netQuantity string true Total quantity of the position
quantityToConvert string true Quantity to be converted. Can be less than or equal to netQuantity
fromProductType string true The existing product type of the position . It can be CNC (Cash and Carry),NRML (Normal),MIS (Intraday)
toProductType string true The target product type user wants to convert to . It can be CNC (Cash and Carry),NRML (Normal),MIS (Intraday)

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "statusMsg": "Position Conversion from MIS to CNC successful"
}

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 position conversion request.Success / Failure
statusMsg string Status message of position conversion request

Position Square Off

Code samples

var headers = {
  'Content-Type':'application/json',
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/position/squareOff',
  method: 'post',
  data: JSON.stringify(requestBody),
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.post('https://tradeapi.samco.in/position/squareOff'
, data=json.dumps(requestBody)
, headers = headers)

print r.json()

POST /position/squareOff

SqareOff existing position. Mostly used in day trading, in which user buy or sell a particular quantity of a stock and later in the day reverse the transaction to earn a profit.

Body parameter

requestBody={

  "positionSquareOffRequestList": [
    {
      "exchange": "NSE",
      "symbolName": "TCS",
      "productType": "MIS",
      "netQuantity": "250",
      "transactionType": "BUY"
    },
    {
      "exchange": "BSE",
      "symbolName": "INFY",
      "productType": "MIS",
      "netQuantity": "25",
      "transactionType": "SELL"
    }
  ]
}

Parameters

Name Type Required Description
body object false none
positionSquareOffRequestList [object] false List of the position squareOff user wants to do
exchange string false Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
symbolName string false Symbol name of the scrip.
productType string false Product type of the existing position.It can be CNC (Cash And Carry),NRML (Normal),MIS (Intraday)
netQuantity string false Total quantity held in existing position
transactionType string false Type of the transaction, BUY / SELL.
positionSquareOffList [object] false none
userId string true The client Code provided to you by SAMCO after opening an account.
exchange string false Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
symbolName string false Symbol name of the scrip.
productType string false Product type of the existing position.It can be CNC (Cash And Carry),NRML (Normal),MIS (Intraday)
netQuantity string false Total quantity held in existing position
transactionType string false Type of the transaction, BUY / SELL.

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "positionSquareOffResponseList": [
    {
      "serverTime": "12/12/19 16:20:11",
      "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
      "status": "Success",
      "statusMessage": "Request successful"
    }
  ]
}

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.
positionSquareOffResponseList [object] List of the PositionSquareOff end of the day
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 Response status. Can be Success or Failure
statusMessage string status Message

Holdings

User Holdings

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/holding/getHoldings',
  method: 'get',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/holding/getHoldings'
, headers = headers)
print r.json()

GET /holding/getHoldings

Get the details of the Stocks which client is holding. Here, you will be able to get the Client holdings which are bought under ‘CNC’ product type and are not sold yet.

Parameters

Name Type Required Description

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "statusMessage": "Request successful",
  "holdingSummary": {
    "gainingTodayCount": "2",
    "losingTodayCount": "2",
    "totalGainAndLossAmount": "0.00",
    "dayGainAndLossAmount": "-4910.00",
    "portfolioValue": "343.80"
  },
  "holdingDetails": [
    {
      "averagePrice": "1560.15",
      "exchange": "BSE",
      "markToMarketPrice": "-182.70",
      "lastTradedPrice": "1,550.00",
      "previousClose": "1552.55",
      "productCode": "CNC",
      "symbolDescription": "RELIANCE INDUSTRIES LTD.",
      "tradingSymbol": "RELIANCE",
      "totalGainAndLoss": "0.00",
      "calculatedNetQuantity": "18.0",
      "holdingsQuantity": "3",
      "collateralQuantity": "2",
      "holdingsValue": "436.46",
      "isin": "INE917I01010",
      "sellableQuantity": "1",
      "totalMarketToMarketPrice": "0"
    }
  ]
}

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 Response status. Can be Success or Failure
statusMessage string status Message
holdingSummary object none
gainingTodayCount string Count of scrips which are gaining in value in a trading day
losingTodayCount string Count of scrips which are losing in value in a trading day
totalGainAndLossAmount string Total amount of Gain / Loss for all existing positions since their creation
dayGainAndLossAmount string Amount of Gain / Loss for all positions on a specific trading day
portfolioValue string Value of the portfolio.
holdingDetails [object] Details of the user holdings.
averagePrice string Average trading price of the equity
exchange string Name of the exchange.Valid exchanges values (BSE/ NSE) If the user does not provide an exchange name, by default considered as NSE.
markToMarketPrice string Price change between previous close price and current price
lastTradedPrice string Price at which last transaction/trade is done
previousClose string Previous close refers to the prior day's final price of security when the market officially closes for the day.
productCode string Type of the product, allowable type is CNC
symbolDescription string Scrip Description
tradingSymbol string Trading Symbol of the scrip.
totalGainAndLoss string Total Gain/Loss for all existing positions since their creation
calculatedNetQuantity string Quantity left after the day
holdingsQuantity string Currently holding(CNC) quantity
collateralQuantity string Quantity of loan against shares offered by SAMCO to their clients for trading in stock and shares.
holdingsValue string Limit value of the available holdings.
isin string The standard ISIN representing stocks uniquely at international level. It is same for every exchange.
sellableQuantity string Quantity which is open for sale.
totalMarketToMarketPrice string Total price change between previous close price and current price

IntraDay candle data

Intraday candle data

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/intraday/candleData?symbolName=INFY&fromDate=2019-11-11%2010%3A00%3A00',
  method: 'get',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/intraday/candleData', params={
  'symbolName': 'INFY',  'fromDate': '2019-11-11 10:00:00'
}, headers = headers)

print r.json()

GET /intraday/candleData

Gets the Intraday candle data such as Open, high, low, close and volume within specific time period per min for a specific symbol.

Parameters

Name Type Required Description
exchange string false Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
symbolName string true Symbol name of the scrip.
fromDate string true From date in yyyy-MM-dd hh:mm:ss
toDate string false To date in yyyy-MM-dd hh:mm:ss
interval string false Interval of data, By default interval is considered as 1 min

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "statusMessage": "Request successful",
  "intradayCandleData": [
    {
      "dateTime": "2019-11-11 10:01:00",
      "open": "689.9",
      "high": "694.0",
      "low": "682.75",
      "close": "688.0",
      "volume": "600344"
    }
  ]
}

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 Response status. Can be Success or Failure
statusMessage string status Message
intradayCandleData [object] Get List of IntraDayCandleData .
dateTime string Date for which CandleData shown
open string Opening price of a market snapshot
high string High value of market snapshot
low string Low value of market snapshot
close string Close value of market snapshot
volume string Limit amount of a security traded on the specific day

Index IntraDay candle data

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/intraday/indexCandleData?indexName=SENSEX&fromDate=2020-03-11%2010%3A00%3A00',
  method: 'get',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/intraday/indexCandleData', params={
  'indexName': 'SENSEX',  'fromDate': '2020-03-11 10:00:00'
}, headers = headers)

print r.json()

GET /intraday/indexCandleData

Gets the Index intraday candle data such as Open, high, low, close and volume within specific time period per min for a specific index.

Supports Following List of Index names:

BSE CGSENSEXBSE CDNIFTY50 PR 1x INV
BSE ITMETALOILGASNIFTY50 PR 2x LEV
BSEIPOGREENXPOWERNIFTY50 TR 1x INV
CARBONBASMTRCDGSNIFTY50 TR 2x LEV
BSEFMCBSE HCALLCAPNIFTY50 TR 2x LEV
REALTYSMEIPODOL30NIFTY Mid LIQ 15
LRGCAPMIDSELSMLSELNIFTY100 LIQ 15
SNXT50SNSX50NIFTY 50NIFTY Quality 30
NIFTY BANKNIFTY NEXT 50DOL100NIFTY MIDCAP 50
NIFTY 100NIFTY 200NIFTY 500NIFTY FIN SERVICE
NIFTY AUTONIFTY FMCGNIFTY ITNIFTY COMMODITIES
NIFTY MEDIANIFTY METALNIFTY PHARMANIFTY CONSUMPTION
NIFTY PSU BANKNIFTY PVT BANKNIFTY REALTYNIFTY GROWSECT 15
NIFTY CPSENIFTY ENERGYNIFTY INFRANIFTY DIV OPPS 50
NIFTY MNCNIFTY PSENIFTY SERV SECTORNIFTY MID100 FREE
DOL200TECKBSEPSUNIFTY SML100 FREE
AUTOBANKEXINDIA VIXNIFTY50 VALUE 20

Parameters

Name Type Required Description
indexName string true Index name of the scrip
fromDate string true From date in yyyy-MM-dd hh:mm:ss
toDate string false To date in yyyy-MM-dd hh:mm:ss
interval string false Interval of data, By default interval is considered as 1 min

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "statusMessage": "Index details retrieved successfully.",
  "indexIntraDayCandleData": [
    {
      "dateTime": "2019-11-11 10:01:00",
      "open": "689.9",
      "high": "694.0",
      "low": "682.75",
      "close": "688.0",
      "volume": "600344"
    }
  ]
}

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 It would be success or failure
statusMessage string Status message of the Index request
indexIntraDayCandleData [object] Get List of IndexIntraDayCandleData .
dateTime string Date for which CandleData shown
open string Opening price of a market snapshot
high string High value of market snapshot
low string Low value of market snapshot
close string Close value of market snapshot
volume string Limit amount of a security traded on the specific day

Historical candle data

Historical candle data

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/history/candleData?symbolName=INFY&fromDate=2019-10-11',
  method: 'get',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/history/candleData', params={
  'symbolName': 'INFY',  'fromDate': '2019-10-11'
}, headers = headers)

print r.json()

GET /history/candleData

Gets the historical candle data such as Open, high, low, close, last traded price and volume within specific dates for a specific symbol. From date is mandatory. End date is optional and defaults to yesterday.

Parameters

Name Type Required Description
exchange string false Name of the exchange.Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
symbolName string true Symbol name of the scrip.
fromDate string true From date in yyyy-MM-dd
toDate string false To date in yyyy-MM-dd

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "statusMessage": "Request successful",
  "historicalCandleData": [
    {
      "date": "2019-11-01",
      "open": "689.9",
      "high": "694.0",
      "low": "682.75",
      "close": "688.0",
      "ltp": "688.0",
      "volume": "600344"
    }
  ]
}

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 Response status. Can be Success or Failure
statusMessage string status Message
historicalCandleData [object] Get List of CandleData .
date string Date for which CandleData shown
open string Opening price of a market snapshot
high string High value of market snapshot
low string Low value of market snapshot
close string Close value of market snapshot
ltp string Price at which last transaction / trade is done
volume string Limit amount of a security traded on the specific day

Index Historical CandleData

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'c5c81c20f0fe81ceb45f93d3621d0938'

};

$.ajax({
  url: 'https://tradeapi.samco.in/history/indexCandleData?indexName=SENSEX&fromDate=2020-03-09',
  method: 'get',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': 'c5c81c20f0fe81ceb45f93d3621d0938'
}

r = requests.get('https://tradeapi.samco.in/history/indexCandleData', params={
  'indexName': 'SENSEX',  'fromDate': '2020-03-09'
}, headers = headers)

print r.json()

GET /history/indexCandleData

Gets the Index historical candle data such as Open, high, low, close, last traded price and volume within specific dates for a specific index. From date is mandatory. End date is optional and defaults to Today.

Supports Following List of Index names:

BSE CGSENSEXBSE CDNIFTY50 PR 1x INV
BSE ITMETALOILGASNIFTY50 PR 2x LEV
BSEIPOGREENXPOWERNIFTY50 TR 1x INV
CARBONBASMTRCDGSNIFTY50 TR 2x LEV
BSEFMCBSE HCALLCAPNIFTY50 TR 2x LEV
REALTYSMEIPODOL30NIFTY Mid LIQ 15
LRGCAPMIDSELSMLSELNIFTY100 LIQ 15
SNXT50SNSX50NIFTY 50NIFTY Quality 30
NIFTY BANKNIFTY NEXT 50DOL100NIFTY MIDCAP 50
NIFTY 100NIFTY 200NIFTY 500NIFTY FIN SERVICE
NIFTY AUTONIFTY FMCGNIFTY ITNIFTY COMMODITIES
NIFTY MEDIANIFTY METALNIFTY PHARMANIFTY CONSUMPTION
NIFTY PSU BANKNIFTY PVT BANKNIFTY REALTYNIFTY GROWSECT 15
NIFTY CPSENIFTY ENERGYNIFTY INFRANIFTY DIV OPPS 50
NIFTY MNCNIFTY PSENIFTY SERV SECTORNIFTY MID100 FREE
DOL200TECKBSEPSUNIFTY SML100 FREE
AUTOBANKEXINDIA VIXNIFTY50 VALUE 20

Parameters

Name Type Required Description
indexName string true Index name of the scrip
fromDate string true From date in yyyy-MM-dd
toDate string false To date in yyyy-MM-dd

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "statusMessage": "Index details retrieved successfully.",
  "indexCandleData": [
    {
      "date": "2019-11-01",
      "open": "689.9",
      "high": "694.0",
      "low": "682.75",
      "close": "688.0",
      "ltp": "688.0",
      "volume": "600344"
    }
  ]
}

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 It would be success or failure
statusMessage string Status message of the Index request
indexCandleData [object] Get List of IndexData .
date string Date for which CandleData shown
open string Opening price of a market snapshot
high string High value of market snapshot
low string Low value of market snapshot
close string Close value of market snapshot
ltp string Price at which last transaction / trade is done
volume string Limit amount of a security traded on the specific day

Streaming Data

Streaming Market Data

Code samples





import json
import websocket
import threading
import pandas as pd
from typing import Any
from snapi_py_client.snapi_bridge import StocknoteAPIPythonBridge
samco = StocknoteAPIPythonBridge()
samco.set_session_token(sessionToken="17f72da7e320807ba324f20566135fda")
symbol_list=["3880_NSE","10753_NSE","14847_NSE","2866_NSE","30125_NSE","2495_NSE","9223_NSE","11471_NSE"]
df_symbols = pd.DataFrame({"symbol": symbol_list})
# Convert the DataFrame to a JSON string
json_data = df_symbols.to_json(orient="records")
count = 0
start_time = None
quit_flag = False
def on_message(ws, msg):
    global count, start_time,quit_flag
    print("Actual Market Data  Value::"+msg)
def on_error(ws, error):
    print (error)
def on_close(ws):
    print ("Connection Closed")
def on_open(ws):
    print ("Sending json")
    data = (
        '{"request":{"streaming_type":"quote2", "data":{"symbols":'
        + json_data
        + '},"request_type":"subscribe", "response_format":"json"}}'
    )
    ws.send(data)
    ws.send("\n")
headers = {'x-session-token':session}
websocket.enableTrace(True)
def connect_websocket():
    ws = websocket.WebSocketApp("wss://stream.stocknote.com",on_open = on_open, on_message = on_message, on_error = on_error, on_close = on_close, header = headers)
    wst = threading.Thread(target=ws.run_forever())
if __name__ == "__main__":
    try:
        connect_websocket()
    except Exception as err:
        print(err)
        print("connect failed")

wss:/stream.stocknote.com/.

Samco Trade API platform provides the Broadcast API, as the most effective way to receive market data for instruments across all exchanges during live market hours. The API provides continuous streaming data of market data based on user request, and primarily consists of fields such as 5 levels of bid/offer market depth data etc.

The API uses WebSocket protocol to establish a dedicated TCP connection after an HTTP handshake to receive streaming quotes and thereby provides seamless streaming of market data. You need to use a WebSocket client to connect to our broadcast API. If you have already subscribed to our Trade API services, you will be able to access broadcast API too.

Body parameter

requestBody={
  "streaming_type": "quote2",
  "symbols": "[{'symbol':'-23'},{'symbol':'30125_NSE'},{'symbol':'3880_NSE'}]",
  "request_type": "subscribe",
  "response_format": "JSON"
}

Parameters

Name Type Required Description
body object false none
streaming_type string true Streaming type.Added for future use.Pass this value as “marketdata” always
symbols [string] true List of symbols contains listing nos used to get marketdata.
request_type string true Request type.This can be Subscribe/Unsubscribe. Subscribe - Receive continuous quote data. UnSubscribe - Stop receiving the continuous quote data. *It's important to unsubscribe when the streaming is no longer needed.
response_format string true Response data format. Currently supports json only

Example responses

200 Response

{
  "response": {
    "data": {
      "askValues": [
        {
          "no": "5",
          "price": "89.20",
          "qty": "4034"
        },
        {
          "no": "21",
          "price": "89.25",
          "qty": "11106"
        },
        {
          "no": "24",
          "price": "89.30",
          "qty": "8507"
        },
        {
          "no": "18",
          "price": "89.35",
          "qty": "12157"
        },
        {
          "no": "24",
          "price": "89.40",
          "qty": "17005"
        }
      ],
      "bidValues": [
        {
          "no": "10",
          "price": "89.15",
          "qty": "4779"
        },
        {
          "no": "82",
          "price": "89.10",
          "qty": "53802"
        },
        {
          "no": "69",
          "price": "89.05",
          "qty": "64430"
        },
        {
          "no": "390",
          "price": "89.00",
          "qty": "176882"
        },
        {
          "no": "17",
          "price": "88.95",
          "qty": "10078"
        }
      ],
      "delta": "0.00",
      "gamma": "0.00",
      "iv": "0.00",
      "ltt": "05/09/2023 12:33:44",
      "lttUTC": "05/09/2023 07:03:44",
      "symbol": "10753_NSE",
      "taq": "5471990",
      "tbq": "1778050",
      "theta": "0.00",
      "vega": "0.00"
    },
    "streaming_type": "quote2"
  }
}

Response Schema

Status Code 200

Name Type Description
askValues [object] Get List of AskValues .
no string Sequence number for Bid/Ask
price string Price asked for trading.
qty string Quantity asked for trading.
bidValues [object] Get List of BidValues .
no string Sequence number for Bid/Ask
price string Price asked for trading.
qty string Quantity asked for trading.
delta string the change in an option’s price with respect to the underlying asset’s price movements.
gamma string Gamma is an Option Chain Greek
iv string Implied Volatility is the expected volatility in a stock or security or asset
ltt string Last transaction time in milliseconds
lttUTC string Last transaction time in UTC time zone format
symbol string Actual symbol name of the scrip
taq string Total ask quantity
tbq string Total bid quantity
theta string change in an options contract's price with respect to the time left for expiry
vega string the value of an options contract has a positive correlation

Streaming Quote Data

Code samples



import websocket

def on_message(ws, msg):
print ("Message Arrived:" + msg)

def on_error(ws, error):
print (error)

def on_close(ws):
print ("Connection Closed")

def on_open(ws):
print ("Sending json")
data='{"request":{"streaming_type":"quote", "data":{"symbols":[{"symbol":"532826_BSE"}]}, "request_type":"subscribe", "response_format":"json"}}'
ws.send(data)
ws.send("\n")

headers = {'x-session-token':'12a8a2b304142425a1e52f109ff02cb2'}

websocket.enableTrace(True)

ws = websocket.WebSocketApp("wss://stream.stocknote.com", on_open = on_open, on_message = on_message, on_error = on_error, on_close = on_close, header = headers)

ws.run_forever()

wss:/stream.stocknote.com

Samco Trade API platform provides the Broadcast API, as the most effective way to receive quote data for instruments across all exchanges during live market hours. The API provides continuous streaming data of quote based on user request, and primarily consists of fields such as last traded price, open, high, low, close, last traded quantity, last traded volume, last traded time etc.

The API uses WebSocket protocol to establish a dedicated TCP connection after an HTTP handshake to receive streaming quotes and thereby provides seamless streaming of quote data. You need to use a WebSocket client to connect to our broadcast API. If you have already subscribed to our Samco Trade API services, you will be able to access broadcast API too.

Body parameter

requestBody={
  "streaming_type": "quote",
  "symbols": "[{'symbol':'-53'},{'symbol':'89017_NFO'}]",
  "request_type": "subscribe",
  "response_format": "JSON"
}

Parameters

Name Type Required Description
body object false none
streaming_type string true Streaming type.Added for future use.Pass this value as “quote” always
symbols [string] true List of symbols contains listing nos used to get quote.
request_type string true Request type.This can be Subscribe/Unsubscribe. Subscribe - Receive continuous quote data. UnSubscribe - Stop receiving the continuous quote data. *It's important to unsubscribe when the streaming is no longer needed.
response_format string true Response data format. Currently supports json only

Example responses

200 Response

{
  "aPr": "44561.00",
  "bPr": "44554.00",
  "aSz": "1",
  "bSz": "1",
  "sym": "2885_NSE",
  "avgPr": "44371.85",
  "c": "44119.00",
  "h": "44786.00",
  "l": "43969.00",
  "o": "44105.00",
  "oI": "361290",
  "oIChg": "22350.00",
  "ch": "435.00",
  "chPer": "0.99",
  "lTrdT": "01 Oct 2019, 06:47:03 PM",
  "ltp": "44554.00",
  "ltq": "1",
  "ltt": "01 Oct 2019, 06:47:03 PM",
  "lttUTC": "01 Oct 2019, 01:17:03 PM",
  "tBQ": "973",
  "tSQ": "610",
  "ttv": "782763833.41",
  "vol": "782763833.41",
  "yH": "44786.00",
  "yL": "0.00",
  "streaming_type": "quote"
}

Response Schema

Status Code 200

Name Type Description
aPr string Ask Price that seller willing to take for the scrip
bPr string Bid Price that buyer willing to pay for the scrip
aSz string Ask size/quantity for trading
bSz string Bid size/quantity for trading
sym string Actual symbol name of the scrip
avgPr string Average trading price of the equity or derivative
c string Close value of market snapshot
h string High value of market snapshot
l string Low value of market snapshot
o string Opening price of a market snapshot
oI string Open interest is the total number of outstanding derivative contracts that have not been settled
oIChg string open interest changed value
ch string Change value is the difference between the current value and the previous day's market close
chPer string Percentage of change between the current value and the previous day's market close
lTrdT string Time of the last transaction
ltp string Price at which last transaction / trade is done
ltq string Quantity of last transaction
ltt string Last transaction time in milliseconds
lttUTC string Last transaction time in UTC time zone format
tBQ string Total quantity of BUY transaction
tSQ string Total quantity of SELL transaction
ttv string Total volume of trading done
vol string Total amount of a security traded Today
yH string 52 week high
yL string 52 week low
streaming_type string Streaming type. Added for future use.Pass this value as “quote” always

User Logout

User Logout

Code samples

var headers = {
  'Accept':'application/json',
  'x-session-token':'3f38c6dd6b950e48a23ebd16b04eb74e'

};

$.ajax({
  url: 'https://tradeapi.samco.in/logout',
  method: 'delete',

  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Accept': 'application/json',
  'x-session-token': '3f38c6dd6b950e48a23ebd16b04eb74e'
}

r = requests.delete('https://tradeapi.samco.in/logout'
, headers = headers)

print r.json()

DELETE /logout

Logging out user from the application

Parameters

Name Type Required Description

Example responses

200 Response

{
  "serverTime": "12/12/19 16:20:11",
  "msgId": "786cdd94-2fc9-4c38-8f14-672ec64dd032",
  "status": "Success",
  "statusMessage": "Request successful"
}

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 Response status. Can be Success or Failure
statusMessage string status Message

Samco Publisher

Easily copy and paste trade buttons to embed them on your website.

What is its purpose?

Integrating buttons into websites and apps to enable users to execute trades. The Samco Publisher buttons can seamlessly become part of your website by copying and pasting a few lines of HTML and JavaScript code.

Why?

Enhance the user experience for your audience, whether they're readers of your financial blog or consumers of your market analysis. Offer them a unique trading experience while also presenting the opportunity for additional revenue for you.

Is there any fees?

No, Samco Publisher is available free of charge.

How do I get my trade buttons?

First create a Publisher app and obtain API keys via /publihser/createApp API. Use these keys along with the necessary HTML/Javascript lines to embed buttons on your website as documented here.

Create App

Code samples

var headers = {
  'Content-Type':'application/json',
  'Accept':'application/json'
};

$.ajax({
  url: 'https://tradeapi.samco.in/publisher/createApp',
  method: 'post',
  data: JSON.stringify(requestBody),
  headers: headers,
  success: function(data) {
    console.log(JSON.stringify(data));
  },
  error : function(error){
    console.log(error);
  }
})

import requests
headers = {
  'Content-Type': 'application/json',
  'Accept': 'application/json'
}

r = requests.post('https://tradeapi.samco.in/publisher/createApp'
, data=json.dumps(requestBody)
, headers = headers)

print r.json()

POST /publisher/createApp

This Publisher create API is to create a Publisher app and obtain API keys.

Body parameter

requestBody={
  "appName": "My App",
  "redirectURL": "https://www.example.com/",
  "description": "Description about the App"
}

Parameters

Name Type Required Description
body object false none
appName string true Name of the App. you want to create
redirectURL string true Wherever you want to redirect the page after order execution.
description string true Description about the App

Example responses

200 Response

{
    "serverTime": "06/02/24 14:02:03",
    "msgId": "d3001338-4312-45ca-8195-9edc6873577a",
    "status": "Success",
    "apiKey": "5TmpmCtzBnxq2MbDb",
    "statusMessage": "Publisher App created & api key generated"
}

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 Login Success or Failure.
statusMessage string status Message
apiKey string apiKey is required while creating HTML / JSON trade button.

Offsite order execution

The offsite order execution functionality enables users to be redirected to Samco's order execution page from your application, allowing them to seamlessly place orders and return, similar to a payment gateway. This eliminates the need for you to develop or upkeep order execution screens. Samco's Publisher program leverages offsite order execution to offer embeddable Javascript+HTML trade buttons, eliminating the need for any API integrations.

Code Sample

Example JSON basket

let json_data = [
  {
    "transaction_type": "BUY",
    "exchange": "NSE",
    "trading_symbol": "TCS",
    "order_type": "MARKET",
    "quantity": 10
  },
  {
    "transaction_type": "SELL",
    "exchange": "NFO",
    "trading_symbol": "NIFTY24FEBFUT",
    "order_type": "LIMIT",
    "price": 21803,
    "quantity": 50
  },
  {
    "transaction_type": "BUY",
    "exchange": "NSE",
    "trading_symbol": "IDEA",
    "order_type": "LIMIT",
    "product": "CO",
    "price": 14.15,
    "quantity": 1,
    "trigger_price": 13
  }
]

Post the JSON data

<form
  method="post"
  id="basket-form"
  action="https://web2.samco.in/publisher/basket"
>
  <input type="hidden" name="api_key" value="xxx" />
  <input type="hidden" id="basket" name="data" value="" />
</form>

<script>
  document.getElementById("basket").value = JSON.stringify(json_data);
  document.getElementById("basket-form").submit();
</script>

Please review the code sample on the right for preparing orders and submitting the JSON basket data via an HTML form.

Sending multiple orders is feasible, where users confirm them via a shopping basket-like interface. To do this, you need to assemble a JSON list of stocks to be traded, complete with the necessary order parameters. Then, POST this list as a form field named data along with your api_key to https://web2.samco.in/publisher/basket.

This request needs to happen on the user's device, either through a web browser or a mobile app's webview. While the backend can handle preparing the shopping basket, the easiest way to send the request is by creating a hidden form, adding the JSON data to it, and using JavaScript to submit it automatically.

If you're setting up the basket directly on your web application, you can simplify the process by utilizing Samco's Publisher JavaScript plugin.

Request parameters

Name Type Required Description
body object false none
trading_symbol string true Pass "symbol" in "trading_symbol" parameter for Equity Cash symbols and "Trading Symbol" for all the F&O contracts ('symbol' and 'tradingSymbol' is available in ScripMaster.csv).
exchange string true Name of the exchange. Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
transaction_type string true Transaction type should be BUY or SELL
order_type string true Type of order. It can be one of the following, MARKET - Market Order,LIMIT - Limit Order, SL - Stop Loss Limit, SL-M - Stop loss market
quantity string true Quantity with which order is being placed
product string false Product Type of the order. It can be CNC (Cash and Carry), NRML (Normal), MIS (Intraday), CO, BO, If not passed default will be CNC
price string true Price at which the order will be placed
trigger_price string false The price at which an order should be triggered in case of SL, SL-M
disclosed_quantity string true If provided should be minimum of 10% of actual quantity
validity string true Order validity can be DAY / IOC. Day is an order type which is valid for the whole trading day and stays pending till it is executed in respective trading day.
is_amo string true After Market Order Flag YES/NO (1/0)

JS Plugin

The Samco Publisher JavaScript plugin allows you to integrate one-click trade buttons into your webpage. Operating similar to a combination of a shopping basket and a payment gateway, it initiates a new window on your webpage, assisting users through the trading process before returning them to your page.

Using the JavaScript plugin, you have the flexibility to dynamically add one or more stocks to the basket, with a maximum limit of 10. Alternatively, you can embed straightforward static buttons using plain HTML for a simpler approach.

Create your buttons

<script src="https://web2.samco.in/publisher.js?v=1"></script>

To integrate Samco Publisher into your webpage, simply insert the above script tag at the end of your webpage, right before the closing tag. You only need to include this script once, and it will enable the rendering of any number of buttons on the page.

Branded HTML5 buttons

<!--  Here's a simple HTML link that would initiate a market buy of the IDEA stock:  -->
<samco-button
  href="#"
  data-samco="your-api-key"
  data-exchange="NSE"
  data-trading_symbol="IDEA"
  data-transaction_type="BUY"
  data-quantity="1"
  data-order_type="MARKET"
  >Buy IDEA stock</samco-button>

To render branded Samco buttons that initiate a trade with a single click, you can use the custom HTML5 tag . These buttons function similarly to social media buttons and can be included as many times as needed on a page.

Custom HTML5 buttons

<!--  Here's a simple HTML link that would initiate a MARKET BUY of the IDEA stock:  -->
<a
  href="#"
  data-samco="your-api-key"
  data-exchange="NSE"
  data-transaction_type="BUY"
  data-trading_symbol="IDEA"
  data-order_type="MARKET"
  data-quantity="1"
  >Buy IDEA stock</a>


<!--  Here's a simple HTML button that would initiate a LIMIT SELL of the TCS stock: //-->
<button
  data-samco="your-api-key"
  data-exchange="NSE"
  data-transaction_type="SELL"
  data-trading_symbol="TCS"
  data-order_type="LIMIT"
  data-quantity="1"
  data-price="4095"
>
  Sell TCS
</button>

<!--  Here's a simple HTML button that would initiate a CO order of the RELIANCE stock: //-->
<button
  data-samco="your-api-key"
  data-exchange="NSE"
  data-transaction_type="BUY"
  data-trading_symbol="RELIANCE"
  data-order_type="LIMIT"
  data-quantity="1"
  data-product="CO"
  data-price="2860"
  data-trigger_price="2840"
>
  Buy RELIANCE (Cover Order)
</button>

You can leverage HTML5 data attributes on any HTML element to transform it into a trade button, which can then be activated with a single click. The examples below demonstrate how a link and a button can be converted into trade buttons.

Generating dynamic buttons with Javascript

Dynamic buttons with Javascript


<!-- A Samco button will be generated within the specified container. //-->
<p id="default-button"></p>

<!-- The basket will be linked to the 'onClick' event of this element. //-->
<button id="custom-button">Buy the basket</button>

<!-- Include the plugin //-->
<script src="https://web2.samco.in/js/publisher/publisher.js?v=1"></script>

<script>
  // Only run your custom code once SamcoPublisher has fully initialised.
  // Use SamcoPublisher.ready() to achieve this.
  SamcoPublisher.ready(function () {
    // Initialize a new Publisher instance.
    // You can initialize multiple instances if you need.
    var publisher = new SamcoPublisher("your-api-key");

    // Add a stock to the basket
    publisher.add({
      exchange: "NSE",
      transaction_type: "BUY",
      trading_symbol: "IDEA",
      order_type: "MARKET",
      quantity: 1,
    });

    // Add another stock (Intra day)
    publisher.add({
      exchange: "NSE",
      transaction_type: "SELL",
      trading_symbol: "TCS",
      order_type: "LIMIT",
      quantity: 1,
      price: 4080,
      product: "MIS"
    });

    //Add a Cover Order
    publisher.add({
      exchange: "NSE",
      transaction_type: "BUY",
      trading_symbol: "RELIANCE",
      order_type: "LIMIT",
      product: "CO",
      price: 2862.5,
      quantity: 1,
      stoploss: 2850
    });

    //Add a Bracket Order
    publisher.add({
      exchange: "NSE",
      transaction_type: "BUY",
      trading_symbol: "SBIN",
      order_type: "LIMIT",
      product: "BO",
      quantity: 1,
      squareoff : 680,
      price: 670,
      stoploss: 660,
      trailing_stoploss : 5
    });

    // Register an (optional) callback.
    publisher.finished(function (status) {
      alert("Finished. Status is " + status);
    });

    // Render the in-built button inside a given target
    publisher.renderButton("#default-button");

    // OR, link the basket to any existing element you want
    publisher.link("#custom-button");
  });
</script>

You have the option to create a basket of stocks and have the plugin render a Samco button that executes it. Alternatively, you can link the basket to your own button or any HTML element of your choice.

To ensure proper initialization of your custom SamcoPublisher calls, it's essential to execute them after the plugin's assets have loaded asynchronously. You can achieve this by utilizing the SamcoPublisher.ready() function. This function ensures that your custom calls are executed only when the plugin is fully loaded and ready to be utilized.

Parameters

Name Type Required Description
body object false none
trading_symbol string true Pass "symbol" in "trading_symbol" parameter for Equity Cash symbols and "Trading Symbol" for all the F&O contracts ('symbol' and 'tradingSymbol' is available in ScripMaster.csv).
exchange string true Name of the exchange. Valid exchanges values (BSE/ NSE/ NFO/ MCX/ CDS).If the user does not provide an exchange name, by default considered as NSE.For trading with BSE, NFO, CDS and MCX, exchange is mandatory.
transaction_type string true Transaction type should be BUY or SELL
order_type string true Type of order. It can be one of the following, MARKET - Market Order,LIMIT - Limit Order, SL - Stop Loss Limit, SL-M - Stop loss market
quantity string true Quantity with which order is being placed
product string false Product Type of the order. It can be CNC (Cash and Carry), NRML (Normal), MIS (Intraday), CO, BO, If not passed default will be CNC
price string true Price at which the order will be placed
trigger_price string false The price at which an order should be triggered in case of SL, SL-M
disclosed_quantity string true If provided should be minimum of 10% of actual quantity
validity string true Order validity can be DAY / IOC. Day is an order type which is valid for the whole trading day and stays pending till it is executed in respective trading day.
is_amo string true After Market Order Flag YES/NO (1/0)

Methods

Method Arguments Description
body false none
SamcoPublisher.ready() function() A secure wrapper for all API calls that asynchronously waits for all assets to load.
add() entry It incorporates an object literal {} containing the parameters outlined in the preceding section, representing a single trading entry, into the basket.
get() Returns an array[] of all added entries.
count() Returns the number of added entries.
setOption() key, value Sets the value for certain supported keys.
renderButton() element_selector It displays a branded Samco button within the specified target element. When clicked, this button initiates the transaction in a new window tab. The element_selector refers to an HTML selector, such as #buy-button or .buttons.
link() element_selector Associates the basket with the designated HTML element, enabling the initiation of the transaction in a new window tab upon clicking. The element_selector denotes an HTML selector, such as #buy-button or .buttons.
html() Generates an HTML form with the required hidden fields and the basket payload serialized. You can append this form to the document body and submit it to initiate the transaction.
finished() function(status) Set up a callback function that activates after the order placement process is completed.