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.
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.
You don't necessarily need to start a login process using the login API to engage in offsite order execution. If a user isn't logged in yet, they'll be prompted to do so, whereas if they're already logged in, they'll be directed straight to the order basket. Regardless, you'll ultimately receive status updates.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
body | object | false | This parameter can be used to include additional data in the request. |
trading_symbol | string | true | For Equity Cash symbols, use "symbol"; for F&O contracts, use "Trading Symbol". Both can be found in ScripMaster.csv. |
exchange | string | true | The exchange where the order is to be placed. Valid values include BSE, NSE, NFO, MCX, CDS. Default is NSE if not provided. |
transaction_type | string | true | Specifies the transaction type: BUY or SELL. |
order_type | string | true | The type of order. Possible values are MARKET (Market Order), LIMIT (Limit Order), SL (Stop Loss Limit), SL-M (Stop Loss Market). |
quantity | string | true | The quantity for which the order is being placed. |
product | string | false | The product type of the order. Options include CNC (Cash and Carry), NRML (Normal), MIS (Intraday), CO (Cover Order), BO (Bracket Order). Default is CNC if not specified. |
price | string | true | The price at which the order is to be placed. |
trigger_price | string | false | The price at which the order should be triggered, applicable for SL and SL-M orders. |
disclosed_quantity | string | true | The disclosed quantity should be a minimum of 10% of the actual order quantity. |
validity | string | true | Order validity. Can be DAY (valid for the whole trading day) or IOC (Immediate Or Cancel). |
is_amo | string | true | After Market Order flag. Use YES (1) or NO (0) to indicate if the order is an after-market order. |
Sample 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>