Introduction

This document describes the MOFSL Trading APIs specifications which can be consumed by MOFSL Clients and Third party Vendor emplaned with MOFSL to integrate their trading solution with MOFSL Trading System. The API end points cannot be called directly through browsers.

All inputs request and response are in JSON format. Standard HTTP codes are used to indicate success and error states accompanied with JSON data.

User will get one key (API Key) while App registration. User has to register a redirection URL where user will be sent after successful login.

Disclaimer: The information is only for consumption by the registered client/Vendors and such material should not be redistributed.

Note: API key has to be create by client itself not anyone else. Please do not share trading id / Password with anyone.


Libraries and SDKs

Below is a list of pre-built client libraries for MOSLAPI written in various programming languages that can be used to interact with the APIs without having to make raw HTTP calls.


Request Format

All request parameters as application/json parameters. Header parameters are mandatory in all requests.


Responses Format

Responses from the API will be in JSON

Successful Response

{ "status": “SUCCESS”, "message”: “SUCCESS”, "errorcode":"", "data":{} }

Failed Response

{ "status”: “FAILURE", "message”: “Login Id/Password Is Invalid", "errorcode":"MOSL100", "data”: “null" }

The status field in the response contains the value SUCCESS/FAILURE. Message field contains actual description of the error. The errorcode field contains the error-code mentioned in Error Codes and Description section.


Header Parameters

Parameter Value Description
Accept application/json application/json
User-Agent MOSL/V.1.1.0 Product and Its Version
Authorization 774aac4a0a8846cc865d7df05c095b13_M Used in all API’s excluding login API.
ApiKey bxga2zcjpqa5u542peag Api Key of App
ClientLocalIp 1.2.3.4 System Local IP Address
ClientPublicIp 1.2.3.4 Public IP Address
MacAddress 00:00:00:00:00:00 System Mac Address
SourceId WEB WEB|MOBILE|DESKTOP
vendorinfo T0240 For client pass client code and for vendor pass vendor short name
osname Windows 10 Operating System name
osversion 10.0.19041 Operating System version
devicemodel AHV Device Model
manufacturer DELL Device Manufacturer
productname Your Product Name Your Product Name
productversion Your Product Version Your Product Version
installedappid AppID Mandatory for DESKTOP|MOBILE
imeino 15 Digit IMEI No. Mandatory for MOBILE
browsername Chrome Mandatory for WEB
browserversion 105.0 Mandatory for WEB

Login through Portal

This Login Flow shall be used to redirect users to third party vendor portal. To implement this flow, Third party vendor/user needs to call given login page URL along with their APP Key (provided by MOFSL) and where MOFSL user will have to enter their Trading Login ID / Password to authenticate.

Live login endpoint

https://invest.motilaloswal.com/OpenAPI/Login.aspx?apikey={apikey}

UAT login endpoint

http://uattrade.motilaloswal.com/OpenAPI/Login.aspx?apikey={apikey}

Ex . If your API Key = abc then URL will be

http://uattrade.motilaloswal.com/OpenAPI/Login.aspx?apikey=abc

After successful login, user gets redirected to the URL specified under My Apps Dashboard with authtoken as query parameter.

Ex. Assume redirection url is : https://google.com Redirected to below URL with authtoken https://www.google.com/?authtoken=d3bcc86824264c689bf18052bb724fa5_M

TOTP Secret Key

User will get the TOTP secret key i.e. 32 character from profile dashboard shown as below


Authentication/Profile

Authentication token will be expired at every day morning 6 a.m. due to exchange compliance.

Login through API

This API authenticates the user and creates a session for the user in the Host System. The session is identified by an alphanumeric login key in the response.

Ex . Password = abc and APIKey = 123

SHA-256(Password + APIKey) = SHA-256(abc123)

Sample Request (Body)

TOTP

{ "userid":"AA017", "password" :"23812bd4c1f3e980d86a16260b307d4a38dd6079577c9e9a22e9ccb75fcd59eb", "2FA":"18/10/1988", "totp": "Authenticator 6 digit Code" }

OTP

{ "userid":"AA017", "password" :"23812bd4c1f3e980d86a16260b307d4a38dd6079577c9e9a22e9ccb75fcd59eb", "2FA":"18/10/1988" }

Note -

TOTP – Send the 6 digit OTP on login using any Authenticator App.

OR

OTP – do not pass the otp parameter or pass it as blank..

Sample Response

{ "status": "SUCCESS", "message": "Return Auth Token SUCCESS", "errorcode": "", "AuthToken": "774aac4a0a8846cc865d7df05c095b13_M", "isAuthTokenVerified": "TRUE" }

The AuthToken returned in response is Authorization Token used in header of each API.


Resend OTP

Sample Response

(You Will receive an OTP at your mobile and Email)

{ “status": "SUCCESS", "message": "OTP SEND SUCCESSFULLY", "errorcode": "" }

Verify OTP

Request JSON

Field Type Mandatory Description
otp Number(6) Y 6 digit Code sent to your mobile/mail

Sample Request (Body)

{ “otp”: 6 digit Code sent to your mobile/ mail }

Sample Response

{ “status": "SUCCESS", "message": "OTP VERFIED SUCCESSFULLY", "errorcode": "" }

Get Profile

This API allows to fetch the complete information of the user who is logged in

Method POST
Production URL https://openapi.motilaloswal.com/rest/login/v1/getprofile
Test URL https://uatopenapi.motilaloswal.com/rest/login/v1/getprofile
Request None or JSON(In case of Dealer)
Response JSON

Request JSON

Field Type Mandatory Description
Clientcode String(15) N Its mandatory in case of Dealer

Sample Request (Body)

{ “clientcode":"AA017” //in case of dealer else not required }

Sample Response

{ “status": "SUCCESS", "message": "Profile Data", "errorcode": "", "data": { "clientcode": "AA017", "name": "Amit Kumar", "exchanges": ["NSE","BSE","NSEFO","NSECD","NSEEX","MCX","BSECD"], "products": ["Normal","Delivery"], "usertype":"Investorclient" } }

Response JSON

Field Type Description
Clientcode String(20) Client ID
Name String(30) Name of Client or user
Exchanges String(50) Name of the Exchanges - LIST
Products String(50) Name of products - LIST
Usertype String(20) User Type - Dealer Or Investor Client

Logout

This API closes the current session in the HOST system.

Sample Request (Body)

{ “userid":"AA017” //in case of dealer else not required }

Sample Response

{ "status": "SUCCESS", "message": "LOGOUT SUCCESSFULL", "errorcode": "" }

Orders

Place Order

The status of the order is not known at the moment of placing order.

Method POST
Production URL https://openapi.motilaloswal.com/rest/trans/v1/placeorder
Test URL https://uatopenapi.motilaloswal.com/rest/trans/v1/placeorder
Request None or JSON (in case of Dealer)
Response JSON

Request JSON

Field Type Mandatory Description
clientcode String(15) N Client ID Mandatory in case of Dealer
exchange String(15) Y Name of the Exchange
symboltoken Number Y Exchange Scrip code or Symbol Token is unique identifier
buyorsell String(10) Y Transaction Type (BUY, SELL)
ordertype String(10) N Order Type(LIMIT, MARKET, STOPLOSS)
producttype String(15) Y Product type (NORMAL, DELIVERY, SELLFROMDP, VALUEPLUS, BTST,MTF)
orderduration String(10) Y Order duration (DAY,GTC,GTD,IOC)
price Decimal(15,4) Y Price in Rupees. Up to 4 decimal places.
triggerprice Decimal(15,4) N Price in Rupees. Up to 4 decimal places.
quantityinlot Number Y Quantity to transact. In terms of Lots
disclosedquantity Number N Quantity to disclose (for equity)
amoorder String(1) Y AMO-Order (Y or N)
goodtilldate String(11) N DD-MMM-YYYY
algoid String(10) N Algo Id or Blank for Non-Algo Orders
tag String(10) N Echo back to identify order.
participantcode String(20) N Participant Code

Sample Request (Body)

{ "clientcode":"", // Client code required only in case of Dealer "exchange":"NSE", "symboltoken":1660, "buyorsell":"BUY", "ordertype":"LIMIT", "producttype":"Normal", "orderduration":"DAY", "price":235.5, "triggerprice":0, "quantityinlot":2, "disclosedquantity":0, "amoorder":"N", "algoid":"", "goodtilldate":"30-Jan-2022", "tag":" ", // max 10 characters "participantcode": "218450147IH" }

Sample Response (Success)

{ "status": "SUCCESS", "message": "Order Placed Successfully", "errorcode": "", "uniqueorderid": "2400155AA020" }

Sample Response (Failure)

{ "status": "ERROR", "message": "Invalid Product Type Parameter", "errorcode": "MO1057" }
Field Type Description
uniqueorderid String(50) Unique Order ID as received in Order place

Modify Order

As long as an order is open or pending in the system, certain attributes of it may be modified.

Method POST
Production URL https://openapi.motilaloswal.com/rest/trans/v2/modifyorder
Test URL https://uatopenapi.motilaloswal.com/rest/trans/v2/modifyorder
Request None or JSON(In case of Dealer)
Response JSON

Request JSON

Field Type Mandatory Description
clientcode String(15) N Client ID Mandatory in case of Dealer
uniqueorderid String(50) Y Unique Order ID as received in Order Entry Response
newordertype String(10) Y Order Type(LIMIT, MARKET, STOPLOSS)
neworderduration String(10) Y Order duration (DAY,GTC,GTD,IOC)
newprice Decimal(15,4) Y Price in Rupees. Up to 4 decimal places.
newtriggerprice Decimal(15,4) N Price in Rupees. Up to 4 decimal places.
newquantityinlot Number Y Quantity to transact in terms of lot
newdisclosedquantity Number N Quantity to disclose (for equity)
newgoodtilldate String(11) N DD-MMM-YYYY
lastmodifiedtime String(20) Y dd-MMM-yyyy HH:mm:ss
qtytradedtoday Number Y Number of quantity traded today

Sample Request (Body)

{ "clientcode":"", // Client code required only in case of Dealer "uniqueorderid ":"1101823KAL005", "newordertype":"LIMIT", "neworderduration":"DAY", " newquantityinlot ":100, "newdisclosedquantity":0, "newprice":235.50, "newtriggerprice":0, "newgoodtilldate":"", "lastmodifiedtime": "14-May-2022 11:31:25", "qtytradedtoday": 0 }

Sample Response (Success)

{ “status": "SUCCESS", "message": "Modify Order Request Sent Successfully", "errorcode": "" }

Sample Response (Failure)

{ “status": "ERROR", "message": "Invalid Order Duration Parameter", "errorcode": "MO1054" }

Cancel Order

As long as an order is open or pending in the system, it can be cancelled.

Method POST
Production URL https://openapi.motilaloswal.com/rest/trans/v1/cancelorder
Test URL https://uatopenapi.motilaloswal.com/rest/trans/v1/cancelorder
Request None or JSON(In case of Dealer)
Response JSON

Request JSON

Field Type Mandatory Description
clientcode String(15) N Client ID Mandatory in case of Dealer
uniqueorderid String(50) Y Unique Order ID as received in Order Entry Response

Sample Request (Body)

{ "clientcode":"", // Client code required only in case of Dealer "uniqueorderid":"1101823KAL005" }

Sample Response (Success)

{ "status": "SUCCESS", "message": "Cancel Order Request Sent", "errorcode": "" }

Sample Response (Failure)

{ "status": "ERROR", "message": "Invalid Order Id Input Parameter", "errorcode": "MO1060" }

OrderBook

This API allows to fetch the complete information of the Orders of the Users

Method POST
Production URL https://openapi.motilaloswal.com/rest/book/v2/getorderbook
Test URL https://uatopenapi.motilaloswal.com/rest/book/v2/getorderbook
Request None or JSON(In case of Dealer)
Response JSON

Request JSON

Field Type Mandatory Description
clientcode String(15) N Its Mandatory in case of Dealer

Sample Request (Body)

{ "clientcode":"AA017" // in case of dealer else not required }

Sample Response

{ "status": "SUCCESS", "message": "Order Data", "errorcode": "" "data": [ { "ordercategory": "NORMAL", "clientid": "AA020", "exchange": "BSE", "symboltoken": 500116, "symbol": "IDBI", "series": "A", "expirydate": "0", "strikeprice": 0, "optiontype": "XX ", "orderid": "1120001", "orderinitiatorid": "27120", "ordertype": "Market", "orderduration": "Day", "producttype": "NORMAL", "error": "Market/Close price not available.", "orderstatus": "Error", "buyorsell": "Buy", "totalqtyremaining": 1, "orderqty": 1, "qtytradedtoday": 0, "disclosedqty": 0, "price": 0, "triggerprice": 0, "entrydatetime": "0", "lastmodifiedtime": "0", "vendor": "NewOrder", "uniqueorderid": "1000001AA020", "goodtilldate": "0", "algoid": 0, "algocategory": 0 "averageprice": 394305, "totalqtytraded": 1, "lotsize": 1, "tag":" ", "recordinserttime": 14-Feb-2023 10:52:50, "participantcode": "218450147IH" }, {...}... ] }

Response JSON

Field Type Description
ordercategory String(15) Category of order by default NORMAL
clientid String(50) Client Id
exchange String(50) Name of the Exchange
symboltoken Number Exchange Scrip code or Symbol Token i.e. unique identifier
symbol String(40) Symbol
series String(2) Series
expirydate String(20) Expiry date of scrip
strikeprice Number Strike Price
optiontype String(2) Option Type
orderid String(50) Order ID
orderinitiatorid String(50) Contains logged in ID from which order is generated
ordertype String(10) Order Type(LIMIT, MARKET, STOPLOSS)
orderduration String(50) Order duration (DAY,GTC,GTD,IOC)
producttype String(20) Product type (Normal, Delivery etc.)
error String(1000) Error in case of order is not executed
orderstatus String(50) Current status of the order
buyorsell String(10) Order Transaction Type (BUY, SELL)
totalqtyremaining Number Total quantityremaining for the order
orderqty Number Order Quantity for transactaion
qtytradedtoday Number It contains quantity traded today for the order
disclosedqty Number Order Quantity to be disclosed (for equity)
price Decimal(15,4) Price in Rupees. Up to 4 decimal places.
triggerprice Decimal(15,4) the price at which an order will be triggered
entrydatetime String(40) Time when fresh order is executed
lastmodifiedtime String(40) Time which order last modified
vendor String(50) Name of the vendor
uniqueorderid String(50) Unique Order ID as received in Order
goodtilldate String(40) Date up to which order should be retained
algoid Number Algo Id or Blank for Non-Algo Orders
algocategory Number Algo category
averageprice Decimal(15,4) Average price at which the order was executed
totalqtytraded Number Quantity traded
lotsize Number Quantity of a single lot
tag String(10) Echo back to identify order
recordinserttime String(20) Record Insert Time
participantcode String(20) Participant Code

Trade Book

This API allows to fetch the complete information of the Trades of the Users

Method POST
Production URL https://openapi.motilaloswal.com/rest/book/v1/gettradebook
Test URL https://uatopenapi.motilaloswal.com/rest/book/v1/gettradebook
Request None or JSON(In case of Dealer)
Response JSON

Request JSON

Field Type Mandatory Description
clientcode String(15) N Its mandatory in case of Dealer

Sample Request (Body)

{ "clientcode":"AA017" // in case of dealer else not required }

Sample Response

{ "status": "SUCCESS", "message": "Trade Data", "errorcode": "" "data": [ { "clientid": "AA020", "exchange": "NCDEX", "symboltoken": "48725", "producttype": "NORMAL", "symbol": "COCUDAKL", "instrumenttype": "FUTCOM", "series": "XX", "strikeprice": -1, "optiontype": "XX", "expirydate": "20/01/2022", "lotsize": 10, "precision": 2, "multiplier": 10, "tradeprice": 278400, "tradeqty": 20, "tradevalue": 5568000, "buyorsell": "Sell", "orderid": "O08mlCpNjtYU", "tradeno": "T27vvFpS6e", "tradetime": "10/01/2022", "uniqueorderid": "2700002AA020", }, {...}... ] }

Order Detail

This API allows to fetch the complete information of the Orders based on uniqueorderid

Request JSON

Field Type Mandatory Description
clientcode String(15) N Its mandatory in case of Dealer
uniqueorderid String(50) Y Unique Order ID

Sample Request (Body)

{ "clientcode":"", // In case of dealer else not required "uniqueorderid":"1000001AA020" }

Sample Response

{ "status": "SUCCESS", "message": "Order Data", "errorcode": "", "data": [ { "ordercategory": "NORMAL", "clientid": "AA020", "exchange": "BSE", "symboltoken": 500116, "symbol": "IDBI", "series": "A", "expirydate": "0", "strikeprice": 0, "optiontype": "XX ", "orderid": "1120001", "orderinitiatorid": "27120", "ordertype": "C", "booktype": "Market", "orderduration": "Day", "producttype": "NORMAL", "error": "Market/Close price not available.", "orderstatus": "Error", "buyorsell": "Buy", "totalqtyremaining": 1, "orderqty": 1, "qtytradedtoday": 0, "disclosedqty": 0, "price": 0, "triggerprice": 0, "entrydatetime": "0", "lastmodifiedtime": "0", "vendor": "NewOrder", "stoploss": 0, "squareoff": 0, "trailingstoploss": 0, "uniqueorderid": "1000001AA020", "goodtilldate": "0", "algoid": 0, "algocategory": 0, "averageprice": 394305, "totalqtytraded": 1, "lotsize": 1, "recordinserttime": 14-Feb-2023 10:52:50, "participantcode": "218450147IH" }, {...}... ] }

Trade Detail

This API allows to fetch the complete information of the Trades of the Users based on uniqueorderid

Request JSON

Field Type Mandatory Description
clientcode String(15) N Its mandatory in case of Dealer
uniqueorderid String(50) Y Unique Order ID

Sample Request (Body)

{ "clientcode":"AA017", // In case of dealer else not required "uniqueorderid":"2700002AA020" }

Sample Response

{ "status": "SUCCESS", "message": "Trade Data", "errorcode": "", "data": [ { "clientid": "AA020", "exchange": "NCDEX", "symboltoken": "48725", "producttype": "NORMAL", "symbol": "COCUDAKL", "instrumenttype": "FUTCOM", "series": "XX", "strikeprice": -1, "optiontype": "XX", "expirydate": "20/01/2022", "lotsize": 10, "precision": 2, "multiplier": 10, "tradeprice": 278400, "tradeqty": 20, "tradevalue": 5568000, "buyorsell": "Sell", "orderid": "112000321", "tradeno": "12343", "tradetime": "10/01/2022", "uniqueorderid": "2700002AA020", }, {...}... ] }

Portfolio

Holding

This API allows to fetch the complete information of the DP Holding of the Users

Method POST
Production URL https://openapi.motilaloswal.com/rest/report/v1/getdpholding
Test URL https://uatopenapi.motilaloswal.com/rest/report/v1/getdpholding
Request None or JSON (in case of Dealer)
Response JSON

Request JSON

Field Type Mandatory Description
clientcode String(15) N Client ID Mandatory in case of Dealer

Sample Request (Body)

{ "clientcode":"AA017", // In case of dealer else not required }

Sample Response

{ "status": "SUCCESS", "message": "DP Holding Data", "errorcode": "", "data": [ { "clientcode": "AA020", "scripisinno": "INE131B01039", "dpquantity": 1119, "blockedquantity": 0, "scripname": "RELAXO EQ", "buyavgprice": 813.66, "poaquantity": 41, "collateralquantity": 1078, "outstandingquantity": 0, "debitstockquantity": 0, "nonpoaquantity": 0, "rmssellingquantity": 0, "btstquantity": 0, "buybackquantity": 0, "tpinquantity": 0, "slbmquantity": 0, "nbfcquantity": 0, "bsescripcode":50001, "nsesymboltoken":123 }, {....}.. ] }
Field Type Description
clientcode String(20) Client
scripisinno String(20) Unique Identifier of Scrip
dpquantity Number Total Quantity
blockedquantity Number Quantity Blocked against executed or pending orders
scripname String(30) Name of scrip
buyavgprice Decimal(15,4) Average price at which all shares were bought
poaquantity Number POA Quantity
collateralquantity Number Collateral Quantity
outstandingquantity Number Share purchased on T-2 Days
debitstockquantity Number CUSA Stock
nonpoaquantity Number Non POA Quantity
rmssellingquantity Number RMS Selling Quantity
btstquantity Number Share Purchased on T-1 Day
buybackquantity Number Quantity blocked against Buyback Orders
tpinquantity Number Quantity which required EDIS to sell
slbmquantity Number SLBM Quantity
nbfcquantity Number NBFC Quantity
bsescripcode Number BSE Scrip code i.e. unique identifier
nsesymboltoken Number NSE Symbol Token i.e. unique identifier

Position

This API allows to fetch the complete information of the DP Holding of the Users

Method POST
Production URL https://openapi.motilaloswal.com/rest/book/v1/getposition
Test URL https://uatopenapi.motilaloswal.com/rest/book/v1/getposition
Request None or JSON(In case of Dealer)
Response JSON

Request JSON

Field Type Mandatory Description
clientcode String(15) N Client ID Mandatory in case of Dealer

Sample Request (Body)

{ "clientcode":"AA017", // in case of dealer else not required }

Sample Response

{ "status": "SUCCESS", "message": "Position Data", "errorcode": "", "data": [ { "exchange": "NSE", "clientcode": "AA020", "productname": "NORMAL", "symboltoken": 1660, "symbol": "INFY", "buyquantity": 0, "buyamount": 0, "sellquantity": 0, "sellamount": 0, "daybuyquantity": 0, "daybuyamount": 0, "daysellquantity": 0, "daysellamount": 0, "LTP": 0, "marktomarket": 0, "bookedprofitloss": 0, "cfbuyquantity": 0, "cfbuyamount": 0, "cfsellquantity": 0, "cfsellamount": 0, "actualbookedprofitloss": 0, "actualmarktomarket": 0, "series": "EQ", "expirydate": "0", "strikeprice": 0, "optiontype": "XX" } ] }

Field Type Description
exchange String(50) Name of the Exchange
clientcode String(50) Client ID
productname String(20) Name of product
symboltoken Number Exchange Scrip code or Symbol Token i.e.unique identifier
symbol String(40) Symbol
buyquantity Number Buy Order Quantity for transactaion i.e.carryforward + traded
buyamount Decimal(15,4) Buy Amount for transactaion i.e.carryforward (based on last day close) + traded
sellquantity Number Sell Order Quantity for transactaion i.e.carryforward + traded
sellamount Decimal(15,4) Sell Amount for transactaion i.e.carryforward (based on last day close) + traded
daybuyquantity Number Buy Order Quantity in a Day for transactaion i.e.todays traded
daybuyamount Decimal(15,4) Buy Amount in a day for transactaion i.e.today traded
daysellquantity Number Sell Order Quantity in a Day for transactaion i.e.today traded
daysellamount Decimal(15,4) Sell Amount in a day for transactaion i.e.today traded
LTP Decimal(15,4) Last Traded Price
marktomarket Decimal(15,4) Unrealized Loss / Profit
bookedprofitloss Decimal(15,4) Realized Loss / Profit
cfbuyquantity Number Buy Order Quantity in a Day for transactaion i.e. caryforward
cfbuyamount Decimal(15,4) Buy Amount in a day for transactaion i.e.caryforward (on actual buy amount)
cfsellquantity Number Sell Order Quantity in a Day for transactaion i.e.caryforward
cfsellamount Decimal(15,4) Sell Amount in a day for transactaion i.e.caryforward (on actual sell amount)
actualbookedprofitloss Decimal(15,4) Unrealized Loss / Profit based on Actual Avg Price
actualmarktomarket Decimal(15,4) Realized Loss / Profit based on Actual Avg Price
series String(2) Series
expirydate String(40) Expiry date of scrip
strikeprice Decimal(15,4) Price when order will excute
optiontype String(2) Option type

Position Conversion

As long as an order is open or pending in the system, it can be cancelled.

Request JSON

Field Type Mandatory Description
clientcode String(15) N Client ID Mandatory in case of Dealer
exchange String(10) Y Name of the Exchange
scripcode Number Y Scrip code or Symbol Token is unique identifier
quantity Number Y Quantity for position conversion
oldproduct String(15) Y Type of Old Product
newproduct String(15) Y Type of new Product

Sample Request (Body)

{ "clientcode":"KAL005", // in case of dealer else not required "exchange":"NSE", "scripcode":1660, "quantity":100, "oldproduct":"Normal", "newproduct":"ValuePlus" }

Sample Response (Success)

{ "status": "SUCCESS", "message": "Position Conversion Request Sent Successfully", "errorcode": "" }

Sample Response (Failure)

{ "status": "ERROR", "message": "Invalid Product Type Parameter",", "errorcode": "MO1057" }

Position Detail

This API is used to get Position Detail for a clientcode.

Method POST
Production URL https://openapi.motilaloswal.com/rest/book/v1/getpositiondetail
Test URL https://uatopenapi.motilaloswal.com/rest/book/v1/getpositiondetail
Request None or JSON(In case of Dealer)
Response JSON

Sample Request (Body)

{ "clientcode":"AA020" // In case of dealer only }

Sample Response (Success)

{ "status": "SUCCESS", "message": "Position Data in Detail", "errorcode": "", "data": [ { "clientcode": "AA020", "transactiondate": "23-Jun-2023", "exchange": "NSECD", "symbol": "USDINR 29-Aug-2023 PE 81", "expirydate": "29-Aug-2023", "strikeprice": 81, "optiontype": "PE", "symboltoken": 13330, "openquantity": -2000, "openprice": 0.05 }, { "clientcode": "AA020", "transactiondate": "04-Jul-2023", "exchange": "NSECD", "symbol": "USDINR 27-Dec-2023 PE 82", "expirydate": "27-Dec-2023", "strikeprice": 82, "optiontype": "PE", "symboltoken": 12302, "openquantity": -5000, "openprice": 0.44 } ] }

Margin Summary

This API is used to get margin report summary

Request JSON

Field Type Mandatory Description
clientcode String(15) N It's mandatory in case of Dealer

Sample Request (Body)

{ "clientcode":"AA017", // In case of dealer else not required }

Sample Response

{ "status": "SUCCESS", "message": "REPORT MARGIN SUMMARY", "errorcode": "", "data": [ { "srno": 102, "particulars": "Total Available Margin for Cash", "amount": 999998900000 }, { "srno": 103, "particulars": "Total Available Margin for FNO", "amount": 999998900000 }, { "srno": 104, "particulars": "Total Available Margin for Curr", "amount": 999998900000 }, { "srno": 105, "particulars": "Total Available Margin for Comm", "amount": 999998900000 }, { "srno": 106, "particulars": "Total Available Margin for Other", "amount": 0 }, { "srno": 201, "particulars": "Cash deposit", "amount": 1000000000000 }, { "srno": 220, "particulars": "Non cash deposit", "amount": 0 }, { "srno": 301, "particulars": "Margin Usage(B) Cash", "amount": 0 }, { "srno": 321, "particulars": "Margin Usage(B) FO", "amount": 560127.5 }, { "srno": 340, "particulars": "Margin Usage(B) Currency", "amount": 0 }, { "srno": 360, "particulars": "Margin Usage(B) Commodity", "amount": 547544 }, { "srno": 381, "particulars": "Margin Usage(B) Brokerage", "amount": 0 }, { "srno": 600, "particulars": "Total Profit and Loss(MTM)", "amount": 16050.07 }, { "srno": 700, "particulars": "Total Profit and Loss(BPL)", "amount": 0 } ] }

Margin Detail

This API is used to get margin report summary in Detail

Request JSON

Field Type Mandatory Description
clientcode String(15) N It's mandatory in case of Dealer

Sample Request (Body)

{ "clientcode":"AA017", // In case of dealer else not required }

Sample Response

{ "status": "SUCCESS", "message": "REPORT MARGIN DETAIL", "errorcode": "", "data": [ { "srno": 100, "particulars": "Total Available Margin(A-B-C-D)", "amount": 49833896 }, { "srno": 101, "particulars": "Credit Limit", "amount": 0 }, { "srno": 102, "particulars": "Available for Cash / SLBM Segment", "amount": 49833896 }, { "srno": 103, "particulars": "Available for FO Segment", "amount": 49833896 }, { "srno": 104, "particulars": "Available for Currency Segment", "amount": 49833896 }, { "srno": 105, "particulars": "Available for Commodity Segment", "amount": 49833896 }, { "srno": 106, "particulars": "Available for IPO/MF/FD/BOND / Option Buy", "amount": 0 }, { "srno": 200, "particulars": "Total Margin (A)", "amount": 50474920 }, { "srno": 201, "particulars": "Cash Balance(Cash Margin)", "amount": 50000000 }, { "srno": 202, "particulars": "Cash Balance(Ledger Balance)", "amount": 50000000 }, { "srno": 203, "particulars": "Add: Normal Fund Transfer", "amount": 0 }, { "srno": 204, "particulars": "Add: MTF Loss", "amount": 0 }, { "srno": 205, "particulars": "Add: Credit from stock sold from DMAT", "amount": 0 }, { "srno": 507, "particulars": "Add: Scrip Capital Cash", "amount": 0 }, { "srno": 206, "particulars": "Add: Option Premium Received", "amount": 0 }, { "srno": 207, "particulars": "Add : Max Realize Cheque Amunt", "amount": 0 }, { "srno": 220, "particulars": "Non-Cash Balance(Non-Cash Margin)", "amount": 474919.06 }, { "srno": 221, "particulars": "Demat Stock Margin after Haircut", "amount": 474919.06 }, { "srno": 222, "particulars": "Stock Margin after Haircut Segment - Intra", "amount": 0 }, { "srno": 223, "particulars": "Stock Margin after Haircut Segment - Delivery", "amount": 0 }, { "srno": 224, "particulars": "Stock Margin after Haircut Segment - FO", "amount": 0 }, { "srno": 225, "particulars": "Stock Margin after Haircut Segment - Currency", "amount": 0 }, { "srno": 226, "particulars": "Stock Margin after Haircut Segment - Commodity", "amount": 0 }, { "srno": 507, "particulars": "Stock Capital Cash", "amount": 0 }, { "srno": 508, "particulars": "Stock Capital Approved", "amount": 474919.06 }, { "srno": 250, "particulars": "Add: Additional Limit", "amount": 0 }, { "srno": 251, "particulars": "Additional Cash Limit - Cash", "amount": 0 }, { "srno": 252, "particulars": "Additional Cash Limit - FO", "amount": 0 }, { "srno": 253, "particulars": "Additional Cash Limit - Currency", "amount": 0 }, { "srno": 254, "particulars": "Additional Cash Limit - Commodity", "amount": 0 }, { "srno": 255, "particulars": "Add: MutualFund/NCD/BOND/FD", "amount": 0 }, { "srno": 509, "particulars": "Add: Mutual Fund Cash", "amount": 0 }, { "srno": 510, "particulars": "Add: Mutual Fund Approved", "amount": 0 }, { "srno": 300, "particulars": "Margin Usage Details (B)", "amount": 622432.4 }, { "srno": 301, "particulars": "Equities", "amount": 674.75 }, { "srno": 302, "particulars": "Margin on orders/Trades", "amount": 674.75 }, { "srno": 303, "particulars": "Mutual Fund / IPO / BOND", "amount": 0 }, { "srno": 304, "particulars": "MTF Margin", "amount": 0 }, { "srno": 321, "particulars": "FO", "amount": 362139.88 }, { "srno": 322, "particulars": "Add: FO Span Margin on Order/Trade and Premium Paid", "amount": 303062.5 }, { "srno": 323, "particulars": "Add: FO exposure margin on order/trade", "amount": 59077.38 }, { "srno": 324, "particulars": "Add: FO Special margin on order/trade", "amount": 0 }, { "srno": 325, "particulars": "Add: FO Additional margin on order/trade", "amount": 0 }, { "srno": 340, "particulars": "Currency", "amount": 1854.91 }, { "srno": 341, "particulars": "Add: Currency Span Margin on Order/Trade and Premium Paid", "amount": 1465.27 }, { "srno": 342, "particulars": "Add: Currency exposure margin on order/trade", "amount": 389.64 }, { "srno": 343, "particulars": "Add: Currency Special margin on order/trade", "amount": 0 }, { "srno": 344, "particulars": "Add: Currency Additional margin on order/trade", "amount": 0 }, { "srno": 360, "particulars": "Commodity", "amount": 257500 }, { "srno": 361, "particulars": "Add: Commodity Span Margin on Order/Trade and Premium Paid", "amount": 257500 }, { "srno": 362, "particulars": "Add: Commodity exposure margin on order/trade", "amount": 0 }, { "srno": 363, "particulars": "Add: Commodity Special margin on order/trade", "amount": 0 }, { "srno": 364, "particulars": "Add: Commodity Additional margin on order/trade", "amount": 0 }, { "srno": 380, "particulars": "SLBM", "amount": 262.84 }, { "srno": 381, "particulars": "Brokerage", "amount": 0 }, { "srno": 400, "particulars": "Profit / Loss (MTM) Details C", "amount": -18590 }, { "srno": 401, "particulars": "Equities", "amount": 0 }, { "srno": 402, "particulars": "Add: Unrealised (Net)", "amount": 0 }, { "srno": 403, "particulars": "Add: Realised P/L (Net)", "amount": 0 }, { "srno": 421, "particulars": "FO", "amount": -18590 }, { "srno": 422, "particulars": "Add: Unrealised (Net)", "amount": -18590 }, { "srno": 423, "particulars": "Add: Realised P/L (Net)", "amount": 0 }, { "srno": 441, "particulars": "Currency", "amount": 0 }, { "srno": 442, "particulars": "Add: Unrealised (Net)", "amount": 0 }, { "srno": 443, "particulars": "Add: Realised P/L (Net)", "amount": 0 }, { "srno": 461, "particulars": "Commodity", "amount": 0 }, { "srno": 462, "particulars": "Add: Unrealised (Net)", "amount": 0 }, { "srno": 463, "particulars": "Add: Realised P/L (Net)", "amount": 0 }, { "srno": 481, "particulars": "SLBM ", "amount": 0 }, { "srno": 482, "particulars": "Add: Unrealised (Net)", "amount": 0 }, { "srno": 483, "particulars": "Add: Realised P/L (Net)", "amount": 0 }, { "srno": 500, "particulars": "Others(D)", "amount": 0 }, { "srno": 501, "particulars": "Fund withdrawal Request (Transfer to Bank)", "amount": 0 }, { "srno": 502, "particulars": "Max Fund Withdrawal for the day", "amount": 0 }, { "srno": 503, "particulars": "Unrealize Cheque Amount", "amount": 0 }, { "srno": 504, "particulars": "Option Obligation(F & O)", "amount": 0 }, { "srno": 505, "particulars": "Option Obligation(Currency)", "amount": 0 }, { "srno": 506, "particulars": "Option Obligation(Commodity)", "amount": 0 }, { "srno": 600, "particulars": "Total Profit and Loss(MTM)", "amount": -18590 }, { "srno": 700, "particulars": "Total Profit and Loss(BPL)", "amount": 0 } ] }

Price/LTP

This API is used to get market data

Method POST
Production URL https://openapi.motilaloswal.com/rest/report/v1/getltpdata
Test URL https://uatopenapi.motilaloswal.com/rest/report/v1/getltpdata
Request None or JSON (in case of Dealer)
Response JSON

Request JSON

Field Type Mandatory Description
clientcode String(15) N Client ID Mandatory in case of Dealer
exchange String(10) Y Name of the Exchange
scripcode Number Y Scrip code or Symbol Token is unique identifier

Sample Request (Body)

{ "clientcode":"AA020", // In case of dealer else not required "exchange":"BSE", "scripcode":500317 }

Sample Response

{ "status": "SUCCESS", "message": "LTP DATA", "errorcode": "", "data": { "exchange": "BSE", "scripcode": 500317, "open": 3131, "high": 3249, "low": 3131, "close": 3189, "ltp": 3224, "volume": 7017, "ask": 3239, "bid": 3230 } }

Note : The values of open, high, low, close and ltp are in paisa


Master Data

Scrip/Instrument

This API is used to get exchange data by name in json format

Request JSON

Field Type Mandatory Description
clientcode String(15) N Client ID Mandatory in case of Dealer
exchangename String(10) Y Name of the Exchange

Sample Request (Body)

{ "clientcode":"AA020", // In case of dealer else not required "exchangename":"NSEFO" }

Sample Response

{ "status": "SUCCESS", "message": "Scrips Data", "errorcode": "", "data": [ { "exchange": 2, "exchangename": "NSEFO", "scripcode": 35020, "scripname": "BANKNIFTY 03-Feb-2022 PE 32300", "marketlot": 25, "scripshortname": "BANKNIFTY", "issuspended": "N", "instrumentname": "OPTIDX", "expirydate": 1328365800, "strikeprice": 32300, "optiontype": "PE", "markettype": " ", "foexposurepercent": 0, "lowercircuitprice": 0.05, "uppercircuitprice": 26.6, "ticksize": 0.05, "scripisinno": "", "indicesidentifier": 0, "isbanscrip": "N", "scripfullname": "BANKNIFTY 03-Feb-2022 PE 32300", "facevalue": 0, "calevel": 0 }, { ….} ] }

Scrip/Instrument (CSV Format)

This Downloads exchange data in .CSV file

Method GET
Production URL https://openapi.motilaloswal.com/getscripmastercsv?name=NSEFO

name = exchangename in URL and you will get CSV file for that exchange

Test URL https://uatopenapi.motilaloswal.com/getscripmastercsv?name=NSEFO

name = exchangename in URL and you will get CSV file for that exchange

Response File Download in .csv Format

Format as below

exchange exchangename scripcode scripname marketlot scripshortname issuspended
instrumentname expirydate strikeprice optiontype markettype foexposurepercent ticksize
scripisinno indicesidentifier isbanscrip scripfullname facevalue calevel maxqtyperorder

DPR Data

This API is used to get daily price range of BANKNIFTY OR NIFTY scripts in json format

Request JSON

Field Type Mandatory Description
clientcode String N It's mandatory in case of Dealer only
Symbol String Y It's either BANKNIFTY or NIFTY

Sample Request (Body)

{ "clientcode":"", // In case of dealer else not required "symbol:"BANKNIFTY" }

Sample Response

{ "status": "SUCCESS", "message": "DPR Data", "errorcode": "", "data": [ { "exchangename": "NSEFO", "exchange": 2, "scripcode": 60605, "scripname": "BANKNIFTY 24-Nov-2022 PE 38300", "scripshortname": "BANKNIFTY", "strikeprice": 38300, "optiontype": "PE", "instrumentname": "OPTIDX", "expirydate": 1353767400, "lowercircuitprice": 218.7, "uppercircuitprice": 1918 },{......} ] }

DPR CSV

This API is used to get daily price range of BANKNIFTY OR NIFTY scripts in CSV format

Symbol Parameters define

Field Type Mandatory Description
symbol String Y It''s either NIFTY or BANKNIFTY

Sample File Format

exchangename,exchange,scripcode,scripname,scripshortname,strikeprice,optiontype,instrumentname ,expirydate,lowercircuitprice,uppercircuitprice NSEFO,2,52826,NIFTY 13-Oct-2022 PE 16500,NIFTY,16500.000,PE,OPTIDX,1350138600,0.050,17.400 NSEFO,2,52827,NIFTY 13-Oct-2022 CE 16550,NIFTY,16550.000,CE,OPTIDX,1350138600,0.050,1548.050

Error Codes And Description

These are the error codes and their relative description which are received in a faliure response body in case off a failed API responsse.

Error Code Description
MO8000 Technical Error
MO8001 Invalid Token
MO8002 Token Expired
MO8003 Token missing
MO8050 Invalid Refresh Token
MO8051 Refresh Token Expired
MO8052 Invalid Dashboard Session
MO1000 Invalid UserId Or Password
MO1001 Invalid User Id
MO1002 Invalid Password Length
MO1003 Client Already Exists
MO1004 Invalid API Key
MO1005 API Key Not Found
MO1006 User Has Not Been Authorized For Live
MO1007 Invalid 2FA
MO1008 Invalid Request Check SUM
MO1011 Client Not Login
MO1012 Invalid Product Type
MO1013 Order Not Found
MO1014 TradeNot Found
MO1015 Holding Not Found
MO1016 Position Not Found
MO2000 Maximum Active Session Exceeded
MO5000 Server Connectivity Failed
MO5001 Request Sent Failed Due To Network Issue
MO5002 Response Receive Failed Due To Network Issue
MO5003 Invalid Order Input Parameter
MO1050 Invalid Input Parameter
MO1051 Invalid Exchange Input Parameter
MO1052 Invalid BuySell Input Parameter
MO1053 Invalid BookType Input Parameter
MO1054 Invalid Order Duration Parameter
MO1055 Invalid Quantity Parameter
MO1056 Invalid Disclose Quantity Parameter
MO1057 Invalid Product Type Parameter
MO1058 Invalid Scrip Code Input Parameter
MO1059 Invalid Quantity In Multiple of Marketlot Input Parameter
MO1060 Invalid Order Id Input Parameter
MO1061 Invalid AMO Order Input Parameter
MO1062 Please Provide Client Code In Input Parameter
MO1063 Invalid Good Till Date In Input Parameter
MO1064 Invalid Algo Id Input Parameter
MO1065 Order Status Is Uknown
MO1066 Order Is Already Cancelled
MO1067 Order Is Already Traded
MO1068 Order Is Already Rejected
MO1069 Order Status Is Error
MO1070 Please Provide UniqueOrderId In Input Parameter
MO1071 Invalid Input DisQty Ioc Combination
MO1072 Invalid Market Order For ProductType
MO1073 Limit Price Is Less Than LCL
MO1074 Limit Price Is More Than UCL
MO1075 Trigger Price Is Required
MO1076 Invalid Trigger Price
MO1077 Trigger Price Must be Less Then Order Price
MO1078 Trigger Price Must be More Then Order Price
MO1079 Invalid Trigger Price Order Type Combination
MO1080 Invalid Input Tag Field Length
MO1081 Invalid Input Tag Field Special Char
MO1082 Invalid Input Exch Dis Qty Combination
MO1083 Invalid Input OrderType Price Combination
MO1084 Invalid Input Exch ProductType Combination
MO1085 Invalid Input Order Duration GTD Combination
MO1086 Invalid Input Exch GTC Combination
MO1087 ClientCode Input Cannot Be DealerId
MO1088 ClientCode Input Cannot Be VendorId
MO1089 Invalid Input ModifyOrder LastModifiedTimeStr
MO1090 Invalid Input ModifyOrder QtyTradedToday
MO1091 Invalid URL ModifyOrder
MO1092 Invalid Consent Check
MO1093 Invalid TOTP
MO1094 Invalid TOTP Key
MO1095 Invalid OTP Session
MO1096 Invalid OTP Attempt Count
MO1097 Invalid Authorization Verification
MO1098 Invalid Dealer Access
MO1099 Invalid OTP Format
MO1100 Invalid Login Access
MO1101 Invalid Time Format
MO1102 Invalid Input ParticipantCode
MO1103 BracketOrder Input Cannot Be Modified
MO1104 BracketOrder Input Cannot Be Cancelled
MO2001 Method Not Allowed
MO2002 InVaild JSON format in Body Request
MO2003 Accept is InVaild In Header Parameter
MO2004 UserAgent is InVaild In Header Parameter
MO2005 ApiKey is InVaild In Header Parameter
MO2006 ApiSecretKey is InVaild In Header Parameter
MO2007 Authorization is InVaild In Header Parameter
MO2008 MacAddress is InVaild In Header Parameter
MO2009 ClientLocalIP is InVaild In Header Parameter
MO2010 ClientPublicIP is InVaild In Header Parameter
MO2011 SourceID is InVaild In Header Parameter
MO2012 Vendor Tag is Invalid In Header Parameter
MO2013 Version Number is Invalid In Header Parameter
MO2014 OS Name is Invalid In Header Parameter
MO2015 OS Version is Invalid In Header Parameter
MO2016 Device Model is Invalid In Header Parameter
MO2017 Manufacturer is Invalid In Header Parameter
MO2018 Product Name is Invalid In Header Parameter
MO2019 Product Version is Invalid In Header Parameter
MO2020 Installed AppID is Invalid In Header Parameter
MO2021 IMEI NO is Invalid In Header Parameter
MO2022 Browser Name is Invalid In Header Parameter
MO2023 Browser Version is Invalid In Header Parameter
MO2024 Latitude is Invalid In Header Parameter
MO2025 Longitude is Invalid In Header Parameter
MO2026 SDK Version is Invalid In Header Parameter
MO3001 Multiple record found

Parameters / Constants

These are the parameters and their relative constant value for the API.

Parameter Value Description
Ordertype LIMIT
MARKET
STOPLOSS
Producttype NORMAL
DELIVERY
VALUEPLUS
SELLFROMDP
BTST
Exchange NSE
BSE
NSEFO
NSECD
MCX
BSEFO
NSE CASH
BSE CASH
Buyorsell BUY
SELL
Ordercategory NORMAL
Orderduration DAY,GTC,GTD,IOC
PossibleOrder Status
Unknown
Sent
Confirm
Cancel
Partial
Traded
Rejected
Error

WebSocket Broadcast

The WebSocket API used to receive different type of quotes for instrument/Exchanges during market hours , only for those scrips which are registered. The API uses WebSocket protocols to establish a TCP connection after an HTTP handshake .To connect with the OpenAPI WebSocket, you will need a WebSocket client library in your choice of programming language

AuthValidation is necessary before using OpenAPI WebSocket Broadcast.

Connecting To WebSocket End Point

CAfter Login Authentication for Connecting with OpenAPI WebSocket call

Mofsl.connect()

Index Register

To register an Index, pass a single parameter Exchange (BSE or NSE) with function call

Mofsl.IndexRegister("NSE")

Index Unregister

To Unregister an Index, pass a single parameter Exchange (BSE or NSE) with function call

Mofsl.IndexUnregister("NSE")

Scrip Register

To Register a script, pass three parameters Exchange (BSE or NSE), Exchange Type (CASH or DERIVATIVES), Scrip Code (eg 532540, 532543)

Mofsl.Register("BSE", "CASH", 532540)

Scrip Unregister

To unregister, pass the same information with UnRegister() function call

Mofsl.UnRegister("BSE", "CASH", 532540)

Quote packet structures

DayOHLC

{'Exchange': 'BSE', 'Scrip Code': 532540, 'Time': '2022-03-09 12:45:35', 'Open': 3610.0, 'High': 3644.0, 'Low': 3599.0, 'PrevDayClose': 3599.95}

LTP

{'Exchange': 'BSE', 'Scrip Code': 532540, 'Time': '2022-03-09 12:45:35', 'LTP_Rate': 3636.8,'LTP_Qty': 4, 'LTP_Cumulative Qty': 75937, 'LTP_AvgTradePrice': 3627.39, 'LTP_Open Interest': 0}

DPR

{'Exchange': 'BSE', 'Scrip Code': 532540, 'Time': '2022-03-09 12:45:35', 'UpperCktLimit': 3959.9, 'LowerCktLimit': 3240.0}

MarketDepth

{'Exchange': 'BSE', 'Scrip Code': 532540, 'Time': '2022-03-09 12:45:35', 'BidRate': 3636.8, 'BidQty': 10, 'BidOrder': 1, 'OfferRate': 3638.95, 'OfferQty': 51, 'OfferOrder': 1, 'Level': 1}

OpenInterest

{'Exchange': 'NSE', 'Scrip Code': 532540, 'Time': '2022-03-09 12:45:35', 'Open Interest': 0, 'Open Interest High': 0,'Open Interest Low': 0}

Index

{'Exchange': 'N', 'Scrip Code': 26000, 'Time': '2022-03-09 12:57:15', 'Rate': 16284.25}


Trade WebSocket

Websocket Trade Status API will function in providing trade status updates through websocket server connection and provide Trade responses. The connection can be made to the Websocket Server API using below url and input parameters.

Websocket endpoint UAT URL is :-

wss://uatopenapi.motilaloswal.com/ws

Websocket endpoint Live URL is :- (WIP)

wss://openapi.motilaloswal.com/ws

The message format to send messages to the Server to make the connection as a JSON object is as below :-

Request for Authorization

{ “clientid”: “AA020”, “authtoken”: “auth_token” “apikey”: “api_key” }

The message format to send messages to the Server to make subscription request after connection is made as a JSON object is as below :-

Request for TradeSubscription

{ “clientid”: “AA020”, “action”: “TradeSubscribe” }

Similarly all the possible action values are as follows :-

action = TradeSubscribe, TradeUnsubscribe, OrderSubscribe, OrderUnsubscribe, logout and heartbeat.

Request for TradeUnsubscription

{ “clientid”: “AA020”, “action”: “TradeSubscribe” }

Request for OrderSubscription

{ “clientid”: “AA020”, “action”: “OrderSubscribe” }

Request for OrderUnsubscription

{ “clientid”: “AA020”, “action”: “OrderUnsubscribe” }

Request for Logout

{ “clientid”: “AA020”, “action”: “logout” }

Request for Heartbeat

{ “clientid”: “AA020”, “action”: “heartbeat” }

Sample Trade JSON response

{ "clientid": "AA020", "exchange": "NSE", "symboltoken": 11536, "producttype": "NORMAL", "symbol": "TCS EQ", "instrumenttype": "", "series": "EQ", "strikeprice": 0, "optiontype": "EQ", "expirydate": "0", "lotsize": 1, "precision": 2, "multiplier": 1, "tradeprice": 3597.05, "tradeqty": 1, "tradevalue": 3597.05, "buyorsell": "BUY", "orderid": "1100000000160907", "tradeno": "50160094", "tradetime": "15-Mar-2022 18:44:54", "uniqueorderid": "1500006T024312" }

Sample Order JSON response

{ "ordercategory": "NORMAL", "clientid": "T024312", "exchange": "NSE", "symboltoken": 22, "symbol": "ACC EQ", "series": "EQ", "expirydate": "0", "strikeprice": 0, "optiontype": "EQ", "orderid": "1000000000131639", "orderinitiatorid": "T024312", "ordertype": "Market", "orderduration": "Day", "producttype": "NORMAL", "error": "", "orderstatus": "Confirm", "buyorsell": "BUY", "totalqtyremaining": 50, "orderqty": 50, "qtytradedtoday": 0, "disclosedqty": 0, "price": 0, "triggerprice": 0, "entrydatetime": "17-Jun-2022 16:07:55", "lastmodifiedtime": "17-Jun-2022 16:07:55", "vendor": "MOFSL", "uniqueorderid": "1700001T024312", "goodtilldate": "0", "algoid": 0, "algocategory": 0, "averageprice": 0, "totalqtytraded": 0, "lotsize": 1, "tag": "KTEST1" }

WebSocket Server Error Codes

Sr. No Error Code Description
1 MO1001 Invalid User Id Or Auth Token
2 MO8000 Technical Error
3 MO2012 Invalid Action Request.

Webhook

Trade Webhook

Webhook Trade Status API will function in providing trade status updates through webhook URL and provide Trade responses. The Webhook functionality can be called using below url and input parameters.

Method GET
Production URL https://openapi.motilaloswal.com/webhook
Test URL https://uatopenapi.motilaloswal.com/webhook
Request JSON
Response JSON

Sample Request (Body)

{ "clientid": "AA020", "authtoken": "166d2344567848wfgreg2334esa222_M", "apikey": "" }

Sample JSON response

{ "clientid": "AA020", "exchange": "NSE", "symboltoken": 11536, "producttype": "NORMAL", "symbol": "TCS EQ", "instrumenttype": "", "series": "EQ", "strikeprice": 0, "optiontype": "EQ", "expirydate": "0", "lotsize": 1, "precision": 2, "multiplier": 1, "tradeprice": 3597.05, "tradeqty": 1, "tradevalue": 3597.05, "buyorsell": "BUY", "orderid": "1100000000160907", "tradeno": "50160094", "tradetime": "15-Mar-2022 18:44:54", "uniqueorderid": "1500006T024312" }

Webhook Server Error Codes

Sr. No Error Code Description
1 MO1001 Invalid User Id Or Auth Token
2 MO8000 Technical Error
3 MO2012 Invalid Action Request.

Participant Detail

This API is used to get Participant Detail for a clientcode

Request JSON

Field Type Mandatory Description
clientcode String(15) N Client ID Mandatory in case of Dealer

Sample Request (Body)

{ "clientcode":"AA020"// in case of dealer only }

Sample Response

{ "status": "SUCCESS", "message": "Participants DATA", "errorcode": "", "data": [ { "clientcode": "PAWZ1431", "participantid": "218450147IH", "exchangename": "NSE", "participanname": "RAJUL M " }, { "clientcode": "PAWZ1431", "participantid": "E5986615IH", "exchangename": "NSE", "participanname": "JAYAN A" } ] }

Brokerage Detail

This API is used to get Brokerage and Other Charges Detail

Request JSON

Field Type Mandatory Description
clientcode String N Client ID Mandatory in case of Dealer
ExchangeName String Y Name of the Exchange E.g. NSE,BSE,NSEFO,NSECD,MCX and Others
Series String Y Name of ScripGroup E.g.F,O,A,EQ,BE and Others

Sample Request (Body)

{ "clientcode":"AA020"//in case of dealer else not required “exchangename”:”NSEFO”, “series”:”F” }

Sample Response

{ "status": "SUCCESS", "message": "Brokerage Detail" "errorcode": "", "data": [ { “clientcode”:”EAOP2917”, “segment”:”FO”, “exchange” :”NSEFO”, “scripgroup”:”F”, “futurebrokeragevaluetype” : “PER”, “futurebuy”:”0.0350”, “futuresell”:”0.0350”, “optionbrokeragevaluetype”:”LOT”, “optionbuy”:”45.0000”, “optionsell” :”45.0000”, “gst” : “18.0000”, “sebi”:”0.0001”, “futurebuystt”:”0.0000”, “futuresellstt” :”0.0100”, “optionbuystt” :”0.0000”, “optionsellstt” :”0.0500”, “futurebuystamp”:”0.0020”, “futuresellstamp” :”0.0000”, “optionbuystamp” :”0.0030”, “optionsellstamp”:”0.0000”, “transactioncharge”:”0.0020” } ] }

Example Two

Sample Request (Body)

{ "clientcode":"AA020"//in case of dealer else not required “exchangename”:”NSE”, “series”:”A” }

Sample Response

{ "status": "SUCCESS", "message": "Brokerage Detail" "errorcode": "", "data": [ { “clientcode”:”EAOP2917”, “segment”:”EQ”, “exchange” :”NSE”, “scripgroup”:”A”, “tradingbuy”:”0.0350”, “tradingsell”:”0.0350”, “deliverybuy”:”0.0350”, “deliverysell” :”0.0350”, “gst” : “18.0000”, “sebi”:”0.0001”, “intrabuystt”:”0.0000”, “intrasellstt” :”0.0250”, “delbuystt” :”0.1000”, “delsellstt” :”0.1000”, “intrabuystamp”:”0.0030”, “intrasellstamp” :”0.0000”, “delbuystamp” :”0.0150”, “delsellstamp”:”0.0000”, “transactioncharge”:”0.0028” } ] }

EOD Data

EOD API

This API is used to get end of day data (OHLC,Volume) for different exchanges in json format

Request JSON

Field Type Mandatory Description
clientcode String N It's mandatory in case of Dealer only
exchangename String Y NSE,BSE,NSEFO,NSECD,NCDEX,MCX,NSECO,BSECO,BSECD

Sample Request (Body)

{ "clientcode":"AA020", // In case of dealer else not required "exchangename":"NSEFO" }

Sample Response

{ "status": "SUCCESS", "message": "EOD Data", "errorcode": "", "data": [ { "exchange": "NSE", "scripcode": 4934, "open": 218.9, "high": 223.95, "low": 217.55, "close": 222.45, "volume": 99235, "date": "09-02-2023", "scripfullname": "INDIA PESTICIDES LIMITED-IPL EQ", "scripshortname": "IPL", "instrumentname": " ", "expirydate": "0", "strikeprice": 0, "optiontype": " " }, {….} ] }

EOD (CSV Format)

This API is used to get end of day data (OHLC,Volume) for different exchanges in CSV format

Method GET
Production URL https://openapi.motilaloswal.com/geteoddatacsv?name=NSE

name = exchangename in URL and you will get CSV file for that exchange

Test URL https://uatopenapi.motilaloswal.com/geteoddatacsv?name=NSE

name = exchangename in URL and you will get CSV file for that exchange

Response File Download in .csv Format

Sample File Format

exchange,scripcode,open,high,low,close,volume,date,scripfullname,scripshortname,instrumentname,expirydate,strikeprice,optiontype NSE,4934,218.900,223.950,217.550,222.450,99235,09-02-2023,INDIA PESTICIDES LIMITED-IPL EQ,IPL," ",0,0.00," " NSE,20030,1134.300,1134.300,1134.300,1134.300,1,09-02-2023,7.74% TAX FREE NCD-IREDA N7,IREDA," ",0,0.00," " NSE,29605,0.000,0.000,0.000,1093.000,0,09-02-2023,BOND 6.88% PA TAX FREE S1-IRFC N5,IRFC," ",0,0.00," " NSE,29607,0.000,0.000,0.000,1096.000,0,09-02-2023,BOND 7.04% PA TAX FREE S2-IRFC N6,IRFC," ",0,0.00," "

Index Data

INDEX DATA API

This API is used to get index data for BSE,NSE in json format

Request JSON

Field Type Mandatory Description
clientcode String N It's mandatory in case of Dealer only
exchangename String Y NSE,BSE

Sample Request (Body)

{ "clientcode":"AA020", // In case of dealer else not required "exchangename":"NSE" }

Sample Response

{ "status": "SUCCESS", "message": "EOD Data", "errorcode": "", "data": [ { "exchange": "NSE", "indexcode": 26009, "indexname": "Nifty Bank", }, { "exchange": "NSE", "indexcode": 26012, "indexname": "Nifty 100", }, { "exchange": "NSE", "indexcode": 26065, "indexname": "Nifty 200", },{..},{..},.... }

INDEX DATA (CSV Format)

This API is used to get index data for BSE,NSE in CSV format

Symbol Parameters Define

Field Type Mandatory Description
name String Y NSE,BSE
Response File Download in .csv Format

Sample File Format

exchangename,indexcode,indexname BSE,999902,BSE100 BSE,999903,BSE 200 BSE,999904,BSE 500 BSE,999913,BSE AUTO BSE,999912,BSE BANKEX BSE,999907,BSE CAPGOOD BSE,999926,BSE CARBON BSE,999908,BSE CONSDUR BSE,999929,BSE CPSE

INDEX LTP DATA API

This API is used to get Open,High,Low,Close,LTP for different indexes of BSE and NSE in json format

Request JSON

Field Type Mandatory Description
clientcode String N Client ID Mandatory in case of Dealer
exchangename String Y NSE,BSE
scripcode String Y Index Code from Index data

Sample Request (Body)

{ "clientcode":"AA020", // In case of dealer else not required "exchange":"NSE", "scripcode":"26000" }

Sample Response

{ "status": "SUCCESS", "message": "INDEX LTP DATA", "errorcode": "", "data": [ { "exchange": "NSECASH", "scripcode": 26000, "open": 17451.25, "high": 17579, "low": 17427.7, "close": 17321.9, "ltp": 17566.6 } ] }

Contact Us

Please write on tradingapi@motilaloswal.com.