Skip to content

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.

Excel Icon 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

NameTypeRequiredDescription
bodyobjectfalseThis parameter can be used to include additional data in the request.
trading_symbolstringtrueFor Equity Cash symbols, use "symbol"; for F&O contracts, use "Trading Symbol". Both can be found in ScripMaster.csv.
exchangestringtrueThe exchange where the order is to be placed. Valid values include BSE, NSE, NFO, MCX, CDS. Default is NSE if not provided.
transaction_typestringtrueSpecifies the transaction type: BUY or SELL.
order_typestringtrueThe type of order. Possible values are MARKET (Market Order), LIMIT (Limit Order), SL (Stop Loss Limit), SL-M (Stop Loss Market).
quantitystringtrueThe quantity for which the order is being placed.
productstringfalseThe 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.
pricestringtrueThe price at which the order is to be placed.
trigger_pricestringfalseThe price at which the order should be triggered, applicable for SL and SL-M orders.
disclosed_quantitystringtrueThe disclosed quantity should be a minimum of 10% of the actual order quantity.
validitystringtrueOrder validity. Can be DAY (valid for the whole trading day) or IOC (Immediate Or Cancel).
is_amostringtrueAfter Market Order flag. Use YES (1) or NO (0) to indicate if the order is an after-market order.

Sample JSON basket

json
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

html
<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>