API Documentation
TOTP Login
We are offering TOTP based Login API which will accept ClientId/EmailId/MobileNo, TOTP, MPIN as Input and provide Request Token in Response.
You need to use Request token to fetch Access Token with help of GetAccessToken API. Which is mentioned in OAUTH Login Documentation.
Validation - Only user key is allowed in Input , Vendor/Partner Key is not allowed as this API is designed to facilitate clients only.
Please note Request token is valid for 30 sec.
REQUEST:
curl --location 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/TOTPLogin' \
--header 'Content-Type: application/json' \
--data '{
"head": {
"Key": "{UserKey}"
},
"body": {
"Email_ID": "{ClientId/MobielNo/EmailId}",
"TOTP": "{TOTP from Authenticator App}",
"PIN": "{MPIN}"
}
}'
REQUEST:
from py5paisa import FivePaisaClient
cred={
"APP_NAME":"YOUR APP_NAME",
"APP_SOURCE":"YOUR APP_SOURCE",
"USER_ID":"YOUR USER_ID",
"PASSWORD":"YOUR PASSWORD",
"USER_KEY":"YOUR USERKEY",
"ENCRYPTION_KEY":"YOUR ENCRYPTION_KEY"
}
client = FivePaisaClient(cred=cred)
client.get_totp_session('Your ClientCode','TOTP from authenticator app','Your Pin')
#Now Can directly call client.place_order()
REQUEST:
// Configuration for your app
const conf = {
appSource: "",
appName: "",
userId: "",
password: "",
userKey: "",
encryptionKey: ""
};
const { FivePaisaClient } = require("5paisajs");
var client = new FivePaisaClient(conf);
// This client object can be used to login multiple users.
client
.get_TOTP_Session("Client code", "TOTP", "PIN")
.then(response => {
// Fetch holdings, positions or place orders here.
// Some things to try out are given below.
})
.catch(err => {
// Oh no :/
console.log(err);
});
OAUTH Login
Oauth Login Page
https://dev-openapi.5paisa.com/WebVendorLogin/VLogin/Index?VendorKey=<Your Vendor Key>&ResponseURL=<Redirect URL>&State=<Pass reference value if needed>
On Successful login the page will redirect to the Response URL with Request Token and state variables passed to it.
Please note the request token is valid for 30sec. You need to call Access Token API within 30sec to fetch the Access token if not then Access token API will response Token Expired.
Access Token API
API provides access token for given Request Token.
The access token is valid for a day.
Request Body
Field Name | Description | Data Type (max length) | Sample Value |
key | VendorKe / UserKey generated at the time of registration | String | ue73jHVeEzBswG5ss9ugyrAasdasdyKYxg |
RequestToken | Token Received on URL redirection | eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjU2NTY1NDAxIiwicm9sZSI6IkNsaWVudCIsIm5iZiI6MTYyMDczNDQ4MiwiZXhwIjoxNjI4NTEwNDgyLCJpYXQiOjE2MjA3MzQ0ODJ9.imlJ6rvaWbY_o9UtcZiBulyeXMJofEiRqxLiYTgWoOc |
REQUEST:
curl --location 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/GetAccessToken' \
--header 'Content-Type: application/json' \
--data '{
"head": {
"Key": "ziQloatyGcXADwxM05uWHiOW2QOWNLcs"
},
"body": {
"RequestToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjUwMDUyNzcwIiwicm9sZSI6ImdpUUlvYXR5R2NYQUR3eFYwNXVXSGlPVzJRT1dOTGNzIiwibmJmIjoxNjgxMzcwMzk0LCJleHAiOjE2ODEzNzA0MjQsImlhdCI6MTY4MTM3MDM5NH0.q7kkfnsZPkVowiFXOE5EIM28oxOVVJuMAvg-tWfOTA0",
"EncryKey": "slXKxViN7yLMIbDc3RpCJaZeqwSgYbu7",
"UserId": "adiUnA2mHNK"
}
}'
REQUEST:
cred={
"APP_NAME":"YOUR APP_NAME",
"APP_SOURCE":"YOUR APP_SOURCE",
"USER_ID":"YOUR USER_ID",
"PASSWORD":"YOUR PASSWORD",
"USER_KEY":"YOUR USERKEY",
"ENCRYPTION_KEY":"YOUR ENCRYPTION_KEY"
}
client = FivePaisaClient(cred=cred)
client.get_access_token('Your Response Token')
REQUEST:
This Login method is not available for NodeJS as of now. Documentation will be updated once its available.
Holdings
This function is used to provide athe client’s holdings as of beginning of the day.
REQUEST BODY
Field Name | Description | Data Type (max length) | Sample Value |
---|---|---|---|
ClientCode | Pass the registered client code of the user. | String(10) | 12345678 |
RESPONSE BODY
Field Name | Type | Description |
---|---|---|
Exch | char | Gets the Exchange of the scrip.(N-Nse,B-Bse) |
ExchType | Char | Exchangesegmentofthescrip(C-Cash,D-Derivative,U-Currency) |
NseCode | Integer | NSEScripCode |
BseCode | Integer | BSEScripCode |
Symbol | String | Symbolofthescrip |
FullName | String | Full Name of that Scrip |
Quantity | Long | AvailableBODquantity |
CurrentPrice | Double | Currentpriceoftheshare(symbol) |
PoolQty | Integer | Qty of that scrip in Broker Beneficiary account |
DPQty | Integer | Qty of that Scrip in Client’s DP account |
POASigned | Char | Whether POA is Signed |
REQUEST:
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V3/Holding' \
--header 'Authorization: bearer {Your Access Token}' \
--header 'Content-Type: application/json' \
--header 'Cookie: NSC_JOh0em50e1pajl5b5jvyafempnkehc3=ffffffffaf103e0f45525d5f4f58455e445a4a423660' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ClientCode": "{Your Client Code}"
}
}'
/code>
REQUEST:
REQUEST:
client.holdings()
REQUEST:
REQUEST:
client.getHoldings().then((holdings) => {
console.log(holdings)
}).catch((err) => {
console.log(err)
});
Margin (Funds)
This API is used to fetch Client’s Margin related details
Request Body
Field Name | Description | Data Type (max length) | Sample Value |
---|---|---|---|
ClientCode | Pass the registered client code of the user. | String(10) | 12345678 |
RESPONSE BODY
Field Name | Description | Data Type (max length) | Sample Value |
---|---|---|---|
Status | Returns the status of the response. | Integer | A.-1 B.0 C.1 D.2 |
Message | Returns the message of the reponse. | String | "Server Unable to process your request" “Success” “No records found” “Invalid input parameters.” |
ClientCode | Returns client code | String | 12345678 |
EquityMargin | Array List of Margin Details | Array List of Margin Details | - |
TimeStamp | It gives the server time when Margin summary is provided by server | DateTime | /Date(1538377480067+0530)/ |
MARGIN DETAILS
Field Name | Description | Data Type (max length) |
---|---|---|
ALB | Ledger Balance at the beginning of the day | Double |
Adhoc | Adhoc margin provided to customer for the day | Double |
AvailableMargin | Actual Available margin available to the customer for trading | Double |
GHV | Gross Holding Value | Double |
GHVPer | Gross Holding Value Cover % | Double |
GrossMargin | Gross Margin of the customer | Double |
Mgn4PendOrd | Margin blocked for pending orders | Double |
Mgn4Position | Margin blocked for open positions | Double |
OptionsMtoMLoss | Margin blocked for M2M loss in Options position | Double |
Payments | Any funds withdrawn from 5paisa today | Double |
Receipts | Any funds added to the ledger today | Double |
THV | Total Holding Value | Double |
PDHV | Adjusted Holding Value post any applicable Haircut | Double |
REQUEST:
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V4/Margin' \
--header 'Authorization: bearer {Your Access Token}' \
--header 'Content-Type: application/json' \
--header 'Cookie: NSC_JOh0em50e1pajl5b5jvyafempnkehc3=ffffffffaf103e0c45525d5f4f58455e445a4a423660' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ClientCode": "{Your Client Code}"
}
}'
/code>
REQUEST:
REQUEST:
client.margin()
REQUEST:
REQUEST:
client.getMargin().then((marginDetails) => {
console.log(marginDetails)
}).catch((err) => {
console.log(err)
});
Positions
Field Name | Description | Data Type (max length) | Sample Value |
---|---|---|---|
ClientCode | Pass the registered client code of the user. | String(10) | 12345678 |
Field Name | Description | Data Type (max length) | List Values | Sample Value |
---|---|---|---|---|
Message | If error code is not 0 then use the message field otherwise it will be empty. | String | A. "Invalid head parameters." B. "Invalid Body Parameters." C. “Success” D. “Error while processing your request.” |
Success |
Status | If Error code is not 0 then there is an issue while processing client request, In such a case use Message field only. | Integer | A. -1 = Exception B. 0 = success C. 1=No Record Found D. 2- Invalid Input/ head parameters |
0 |
NetPositionDetail | This class contain the all Net Postion details of Client | List | - | - |
FieldName | Type | Description |
---|---|---|
Exch | Char | Exchange in which order has been Placed. N- NSE, B-BSE, M-MCX |
ExchType | Char | Exchange segment C-Cash, D-Derivatives, U-Currency |
ScripCode | Int32 | Scrip Code of the particular stock |
ScripName | String | Scrip Name of the scrip. |
BuyQty | Int32 | Number of Shares bought in particular scrip. |
BuyAvgRate | Double | Average buying rate for a particular scrip |
BuyValue | Double | Average buying rate Multiply by bought quantity |
SellQty | Int32 | Number of shares sold in particular scrip. |
SellAvgRate | Double | Average Selling Rate. |
SellValue | Double | Average Selling rate Multiply by sold quantity. |
NetQty | Int32 | Bought Quantity – sold Quantity. |
BookedPL | Double | Profit or Loss booked by client for particular scrip. |
LTP | Double | Last traded Price. |
OrderFor | Char | I-Intraday , D- Delivery. |
Multiplier | Double | Scrip multiplier |
BodQty | Int32 | Bod quantity |
MTOM | Double | MTOM profit and loss. |
PreviousClose | Double | Previous close |
REQUEST:
REQUEST:
curl --location --request POST '
https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V2/NetPositionNetWise' \
--header 'Authorization: bearer abc' \
--header 'Content-Type: application/json' \
--data-raw '{
"head": {
"key": ""
},
"body": {
"ClientCode": ""
}
}'
REQUEST:
REQUEST:
client.positions()
REQUEST:
REQUEST:
client.getPositions().then((positions) => {
console.log(positions)
}).catch((err) => {
console.log(err)
});
Position Conversion
Request Body:-
Name | Desc | Compulsory* | DataType |
---|---|---|---|
Exch | Pass the Exchange. | Y | String |
ExchType | Pass the Exchange Type. | Y | String |
ScripCode | Pass the Scrip Code of current position | Y | Integer |
ConvertFrom | Convert From segment (Intraday/Delivery) | Y | String |
ConvertQty | Quantity to be converted | Y | Integer |
ConvertTo | Convert From segment (Intraday/Delivery) | N | String |
TradeType | Buy/Sell | N | String |
ClientCode | Pass the Client Code. | N | String |
AppSource | Pass the App Source. | N | Integer |
Response Body:-
Name | Desc |
---|---|
Status | 0 for success In case of non zero code, check following field for error in body |
Message | Error description incase of non zero status or "Success". |
ClientCode | Returns the ClientCode. |
RMSResponseCode | Returns the RMS Response Code. |
Status | 0 for success In case of non zero code, refer following field for error description |
Message | Error description incase of non zero status or "Success". |
ScripCode | Returns the Scrip Code. |
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/PositionConversion' \
--header 'Authorization: Bearer null' \
--header 'Content-Type: application/json' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ClientCode": "null",
"Exch":"N",
"ExchType":"C",
"ScripCode":"{{Scrip code of current open position}}",
"TradeType":"{{B/S}}",
"ConvertQty":"1",
"ConvertFrom":"I",
"ConvertTo":"D"
}
}'
REQUEST:
client.position_convertion("N","C","BPCL_EQ","B",5,"D","I")
REQUEST:
client.position_convertion("N","C","BPCL_EQ","B",5,"D","I")
Live Quotes
Websocket provides realtime Data of MarketFeeds, MarketDepth, OpenInterest, Indices.
Order Updates Through Websocket -
We also provide real-time Order Status (Place, Modify, Cancel, Trigger) updates over websocket. For this you don't need to subscribe with any message, the updates will be pushed directly.
Websocket connection for Order Updates -
We have 2 websocket connection URL's ,Please follow below method to connect to relevant weboscket for order updates.
1. Decode the access token
Sample Payload:{
"unique_name": "53814671",
"role": "9165",
"State": "",
"RedirectServer": "C",
"nbf": 1656068442,
"exp": 1656095399,
"iat": 1656068442
}
2. After decoding JWT token As per RedirectServer value
for "RedirectServer": "C" ->https://openfeed.5paisa.com/
for "RedirectServer": "A" ->https://aopenfeed.5paisa.
for "RedirectServer": "B" ->https://bopenfeed.5paisa.
Please note if you connect to incorrect websocket URL the order updates will not be pushed. Also this connection mechanism is needed only for order updates for other features like Market Feed etc you can connect to any URL.
Connecting to WebSocket :
Websocket URL:- wss://openfeed.5paisa.com/Feeds/api/chat?Value1=<Access_Token(JWT)>|<Client_Code>
Value1 contains JWT Token which we get at the time of Login API(in response body) same as access token.
After Connecting to Websocket It will start giving you order status updates and feeds as per request.
*Note :- At a time only one websocket connection will be connected if trying to connect concurrently older websocket connection will be disconnected.
Response Structure for Order Status updates
Field Name |
Description |
Data Type (max length) |
Sample Value |
ReqType |
This field shown shows the updated order status. |
String |
|
ClientCode |
Returns Client Code |
String |
51201912 |
Exch |
Returns Exchange |
String |
|
ExchType |
Returns Instrument Type |
String |
|
ScripCode |
Request traded script code |
String |
1660 |
Symbol |
Returns traded script symbol |
String |
ITC |
Series |
Returns Script Series |
String |
EQ |
BrokerOrderID |
Returns Broker Order Id |
String |
824863636 |
ExchOrderID |
Returns Exchange order id |
String |
1100000019296811 |
ExchOrderTime |
Returns Exch Order Time |
String |
2022-10-28 15:05:46 |
BuySell |
Returns Buy or Sell |
String |
|
Qty |
Returns order quantity |
String |
5 |
Price |
Returns order price |
String |
345.2 |
ReqStatus |
Returns Req Status |
String |
0 |
Status |
Returns Order Status |
String |
|
OrderRequestorCode |
Returns Order Requestor code |
String |
50052770 |
AtMarket |
Returns AtMarket |
String |
Y/N |
Product |
Returns Product Type |
String |
C/D |
WithSL |
Returns WithSL flag |
String |
Y/N |
SLTriggerRate |
Returns SL trigger rate |
String |
0 |
DisclosedQty |
Returns DisclosedQty |
String |
0 |
PendingQty |
Returns PendingQty |
String |
1 |
TradedQty |
Returns TradedQty |
String |
0 |
RemoteOrderId |
Returns RemoteOrderId |
String |
202205270455305 |
Subscribing/Unsubscribing to scrips to get live feeds
Refer to below table to map requests:-
Request | Method Name |
---|---|
Get Live Quotes | MarketFeedV3 |
Get Market Depth | MarketDepthService |
Get Open Interest | GetScripInfoForFuture |
Indices | Indices |
In Request please enter(payload):-
{"Method"
:"MarketFeedV3","Operation":"Subscribe", "ClientCode"
:"<<Pass ClientCode>>","MarketFeedData":[ {"Exch"
:"N","ExchType":"C","ScripCode":15083} ]}
Sample Request:- {"Method"
:"MarketFeedV3","Operation":"Subscribe", "ClientCode"
:"ABC123","MarketFeedData":[ {"Exch"
:"N","ExchType":"C","ScripCode":15083} ]}
Similarly if want to Subscribe multiple scrips we need to put in following Request:-
{"Method"
:"MarketFeedV3","Operation":"Subscribe", "ClientCode"
:"<<Pass ClientCode>>","MarketFeedData":[ {"Exch"
:"N","ExchType":"C","ScripCode":15083}, "Exch"
:"B","ExchType":"C","ScripCode":999901}, "Exch"
:"N","ExchType":"C","ScripCode":22} ]}
Sample Request (Multiple Request):- {"Method"
:"MarketFeedV3","Operation":"Subscribe", "ClientCode"
:"ABC123","MarketFeedData":[ {"Exch"
:"N","ExchType":"C","ScripCode":15083}, "Exch"
:"B","ExchType":"C","ScripCode":999901}, "Exch"
:"N","ExchType":"C","ScripCode":22} ]}
If user wants to receive feeds again, user has to sign in again and Subscribe to Scrips again that is we need to follow process all over again.
Unsubscribing Scrips (To stop getting feeds for particular scrips)
If want to Unsubscribe a particular scrip we need to pass following in Request:- {"Method"
:"MarketFeedV3","Operation":"Unsubscribe", "ClientCode"
:"<<Pass ClientCode>>","MarketFeedData":[ {"Exch"
:"N","ExchType":"C","ScripCode":15083} ]}
In this case we will continue receiving feeds of N,C,999901 and N,C,22 and we will stop receiving live feeds of N,C,15083 as we have unsubscribed this scrip.
Response for Market Feed:- [{"Exch":"N","ExchType":"C","Token":1660,"LastRate":205,"LastQty":13,"TotalQty":6508704, "High":206.5,"Low":203.85,"OpenRate":203.9,"PClose":205.55,"AvgRate":205.39,"Time":23608, "BidQty":21411,"BidRate":205,"OffQty":7401,"OffRate":205.05,"TBidQ":2195269, "TOffQ":2419127,"TickDt":"\/Date(1620716608000)\/"}]
REQUEST:
{"Method"
:"MarketFeedV3","Operation":"Subscribe", "ClientCode"
:"<<Pass ClientCode>>","MarketFeedData":[ {"Exch"
:"N","ExchType":"C","ScripCode":15083} ]}
Sample Request:- {"Method"
:"MarketFeedV3","Operation":"Subscribe", "ClientCode"
:"ABC123","MarketFeedData":[ {"Exch"
:"N","ExchType":"C","ScripCode":15083} ]}
REQUEST:
req_list=[
{ "Exch":"N","ExchType":"C","ScripCode":1660},
]
req_data=client.Request_Feed('mf','s',req_list)
def on_message(ws, message):
print(message)
client.connect(req_data)
client.receive_data(on_message)
REQUEST:
Order Request (Place Order)
Name | Desc | Compulsory* | DataType | |
---|---|---|---|---|
Exchange | Pass the Exchange. N - Nse B - Bse M - Mcx |
Y | Char | |
ExchangeType | Pass the Exchange Type. C - Cash D - Derivative U - Currency |
Y | Char | |
|
|
Y | String | |
Price | Pass the Price. (Price 0 - At Market Order) |
Y | Double | |
Qty | Pass the Qty. | Y | Long | |
OrderType | Pass the Order Type. Buy Or Sell |
Y | String | |
DisQty | Pass the DisQty. | N | Long | |
StopLossPrice | Pass the Stop Loss Price. (Stop Loss Price 0 - Stop Loss Order) |
N | Double | |
IsIntraday | Pass the IsIntraday. (True or False) |
Y | Boolean | |
iOrderValidity | Pass the iOrderValidity. | N | Enum | |
AppSource | Pass the App Source of Vendor. | Y | Long | |
RemoteOrderID | Pass the Remote Order ID for tracking. | N | String |
Field Name | Description | Data Type |
---|---|---|
BrokerOrderID | BrokerOrderID of order placed . | string |
ClientCode | ClientCode passed in request . | String |
Exch | Exchange passed in request | String |
ExchOrderID | it comes as zero RMS doesnt send Exchange order ID | String |
ExchType | Exchange Type passed in request | String |
LocalOrderID | OrderID passed in request | String |
Message | Error Message | String |
RMSResponseCode | RMSResponseCode | Double |
ScripInfo | Scripdata or scripcode passed in request | string |
status | status of order request | Integer |
time | order placed time | string |
REQUEST:
REQUEST:
curl --location --request POST 'https://openapi.5paisa.com/VendorsAPI/Service1.svc/V1/PlaceOrderRequest' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {Your Access Token}' \
--header 'Cookie: 5paisacookie=j2usr4wuddgegs14hcjrh3d4; NSC_JOh0em50e1pajl5b5jvyafempnkehc3=ffffffffaf103e0f45525d5f4f58455e445a4a423660' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ClientCode":"{Your Client Code}",
"Exchange":"N",
"ExchangeType" : "C",
"Qty": "50",
"Price": "1800.50",
"OrderType":"Buy",
"ScripData" : "1660",
"IsIntraday" : false,
"DisQty": 1,
"StopLossPrice":0,
"IsAHOrder": "N",
"ValidTillDate":"/Date(1630391628000)/",
"RemoteOrderID":"{Your custom order tag}",
"AppSource" : "{your app source}"
}
}'
REQUEST:
REQUEST:
# Note: This is an indicative order.
from py5paisa.order import Order, OrderType, Exchange
#You can pass scripdata either you can pass scripcode also.
# please use price = 0 for market Order
#use IsIntraday= true for intraday orders
#Using Scrip Code :-
client.place_order(OrderType='B',Exchange='N',ExchangeType='C', ScripCode = 1660, Qty=1, Price=260)
#Sample For SL order
client.place_order(OrderType='B',Exchange='N',ExchangeType='C', ScripCode = 1660, Qty=1, Price=350, IsIntraday=False, StopLossPrice=345)
#Derivative Order
client.place_order(OrderType='B',Exchange='N',ExchangeType='D', ScripCode = 57633, Qty=50, Price=1.5)
REQUEST:
REQUEST:
var options = {
exchangeSegment: "C",
atMarket: false,
isStopLossOrder: false,
stopLossPrice: 0,
isVTD: false,
isIOCOrder: false,
isIntraday: false,
ahPlaced: "N",
IOCOrder: false,
price: 208
};
try {
client.placeOrder("BUY", "1660", "1", "N", options).then((response) => {
console.log(response)
})
} catch (err) {
console.log(err)
}
Order Modify
Field Name | Description | Compulsory* | Data Type |
---|---|---|---|
Price | Pass Price to modify | N | Double |
Qty | Pass quantity | N | integer |
ExchOrderID | Pass Exchange Order ID of an order which you want to modify. | Y | string |
DisQty | pass Disclosed qty | N | long |
StopLossPrice | pass stoploss price | N | double |
AppSource | pass Appsource given to vendor. | N | string |
RemoteOrderID | Pass ID in order to tag placed orders | N | string |
Field Name | Description | Data Type |
---|---|---|
BrokerOrderID | BrokerOrderID of order placed. | string |
ClientCode | ClientCode passed in request. | String |
Exch | Exchange passed in request | String |
ExchOrderID | it comes as zero RMS doesnt send Exchange order ID | String |
ExchType | Exchange Type passed in request | String |
LocalOrderID | OrderID passed in request | String |
Message | Error Message | String |
RMSResponseCode | RMSResponseCode | Double |
ScripInfo | Scripdata or scripcode passed in request | string |
status | status of order request | Integer |
time | order modified time | string |
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V1/ModifyOrderRequest' \
--header 'Authorization: Bearer null' \
--header 'Content-Type: application/json' \
--header 'Cookie: ASP.NET_SessionId=bqr45sqdj5vtexqouwvfmjb2; NSC_JOh0em50e1pajl5b5jvyafempnkehc3=ffffffffaf103e0f45525d5f4f58455e445a4a423660' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"Qty":"30",
"ExchOrderID": "{Exchange Order ID }"
}
}'
REQUEST:
REQUEST:
client.modify_order(ExchOrderID="1100000017861430", Qty=2,Price=261)
REQUEST:
REQUEST:
client.modifyOrder("1100000007628729", "1", "210", "1660", false, "N", "C", true).then((response)=> {
console.log(response)
})
} ).catch((err) => {
console.log(err)
});
Order Cancel
Field Name | Description | Data Type |
---|---|---|
ExchOrderID | Pass Exchange Order ID of an order which you want to modify. | String |
Field Name | Description | Data Type |
---|---|---|
BrokerOrderID | BrokerOrderID of order placed . | string |
ClientCode | ClientCode passed in request . | String |
Exch | Exchange passed in request | String |
ExchOrderID | it comes as zero RMS doesnt send Exchange order ID | String |
ExchType | Exchange Type passed in request | String |
LocalOrderID | OrderID passed in request | String |
Message | Error Message | String |
RMSResponseCode | RMSResponseCode | Double |
ScripInfo | Scripdata or scripcode passed in request | string |
status | status of order request | Integer |
time | order modified time | string |
REQUEST:
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V1/CancelOrderRequest' \
--header 'Authorization: Bearer null' \
--header 'Content-Type: application/json' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ExchOrderID":"{Exchange Order ID}"
}
}'
REQUEST:
REQUEST:
client.cancel_order(exchange='N',exchange_segment='C',exch_order_id='12345678')
REQUEST:
REQUEST:
client.cancelOrder("1100000007973827", "1", "205", "1660", false, "N", "C", false).then((response) => {
console.log(response)
})
} ).catch((err) => {
console.log(err)
});
Cancel Bulk Orders
This API is used to cancel multiple orders at a time.
Request Body
Name | Desc | Required* | DataType |
---|---|---|---|
ExchOrderIDs | List of Exchange Order ID. | Y | List |
ExchOrderIDs (List)
Name | Desc | Required* | DataType |
---|---|---|---|
ExchOrderID | Pass the Exchange Order ID. | Y | String |
Body Attributes
Name | Desc |
---|---|
ClientCode | Returns the ClientCode. |
LocalOrderID | Returns the Local Order ID. |
BrokerOrderID | Returns the Broker Order ID. |
ExchOrderID | Returns the Exchange Order ID. |
ExchType | Returns the Exchange Type. |
Exch | Returns the Exchange. |
RMSResponseCode | Returns the RMS Response Code. |
Status | 0 for success In case of non zero code, refer following field for error description |
Message | Error description incase of non zero status or "Success". |
Time | Returns the TimeStamp. |
ScripCode | Returns the Scrip Code. |
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/CancelOrderBulk' \
--header 'Authorization: Bearer null' \
--header 'Content-Type: application/json' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ExchOrderIDs": [
{
"ExchOrderID": "{{Exchange Order ID1}}"
},
{
"ExchOrderID": "{{Exchange Order ID2}}"
}
]
}
}'
REQUEST:
cancel_bulk=[
{
"ExchOrderID": "<Exchange Order ID 1>"
},
{
"ExchOrderID": "<Exchange Order ID 2>"
},
client.cancel_bulk_order(cancel_bulk)
REQUEST:
a=[
{
"ExchOrderID": "{{Exchange Order ID1}}"
},
{
"ExchOrderID": "{{Exchange Order ID2}}"
}
]
client.canceBulkOrder(a).then((positions) => {
console.log(positions)
}).catch((err) => {
console.log(err)
});
SquareOff All Orders
This API is used to squareoff all the open positions for a specific client.
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/SquareOffAll' \
--header 'Authorization: bearer {{Access_Token}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ClientCode": "{{Client_Code}}"
}
}'
REQUEST:
client.squareoff_all()
REQUEST:
client.squareoff_all()
Order Book
Field Name | Description | Data Type (max length) | Sample Value |
---|---|---|---|
ClientCode | Pass the registered client code of the user. | String(10) | 12345678 |
Field Name | Description | Data Type (max length) | List Values | Sample Value |
---|---|---|---|---|
Status | Returns the status of the response. | Integer | A. | -1 0 1 2 |
Message | Returns the message of the reponse. | String | - | “Success” “No record found.” “Invalid input parameters.” “Invalid head parameters.” “Error while processing your request.” “Invalid Session” "No Order found for this Client." |
OrderBookDetail | Order Details of that particular client for the day. | Array Of Orders | Array Of Orders | - |
Field Name | Type | Description |
---|---|---|
RequestType | Char | Order request type P- Placed, M- Modified, C- Cancelled, S- Bracket/Cover Order |
BrokerOrderId | Int32 | Order ID set by 5paisa for a particular Order |
BrokerOrderTime | DateTime | Time at which order received by 5paisa |
Exch | Char | Exchange in which order has been Placed. N- NSE, B-BSE, M- MCX |
ExchType | Char | Exchange segment C-Cash, D-Derivatives, U-Currency |
ScripCode | Int32 | Scrip Code of the particular stock |
ScripName | String | Scrip Name of the scrip. |
BuySell | Char | B- Buy S- Sell |
Qty | Int32 | Order Quantity |
Rate | Double | Rate at which order has been placed |
AveragePrice | Double | Price at which Quantity is filled, for multiple trades it will be average price and |
AtMarket | Char | Order Placed is limit order or Market Order. Y-At Market, N- Limit Order |
WithSL | Char | Is stop loss order. |
SLTriggerRate | Double | Stop lass rate |
SLTriggered | Char | Is stop loss triggered |
ExchOrderID | String | Order ID given by Exchange to an order. |
ExchOrderTime | DateTime | Time at which order has received by Exchange |
OrderStatus | String | Status of an Order. |
AfterHours | Char | Is Order Placed After Market order. |
AHProcess | Char | Is AH Order is Processed by 5paisa or not |
OldorderQty | Int32 | Order quantity before modified quantity |
TradedQty | Int32 | Number of Quantity which are traded. |
PendingQty | Int32 | Remaining quantity after trade happened |
OrderRequesterCode | String | Id of the user who had placed the order. |
DisClosedQty | Int32 | Quantity which is exposed in Exchange by Client. |
TerminalId | Int32 | Terminal number on which order has been sent. |
DelvIntra | Char | I-Intraday, D-Delivery |
OrderValidity | Int32 | Validity of an order. Day = 0 GTD = 1 GTC = 2 IOC = 3 EOS = 4 VTD = 5 FOK = 6 |
OrderValidUpto | String | Order Validity Date |
Reason | String | Order rejection reason. |
SMOSLLimitRate | Double | SMO Stop Loss Limit Rate |
SMOSLTriggerRate | Double | SMO Stop Loss Trigger Rate |
SMOProfitRate | Double | SMO Profit Rate |
SMOTrailingSL | Double | SMO Trailing Stop Loss |
MarketLot | Double | Shows MarketLot |
REQUEST:
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V3/OrderBook' \
--header 'Authorization: bearer {Your Access Token}' \
--header 'Content-Type: application/json' \
--header 'Cookie: NSC_JOh0em50e1pajl5b5jvyafempnkehc3=ffffffffaf103e0f45525d5f4f58455e445a4a423660' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ClientCode": "{Your Client Code}"
}
}'
REQUEST:
REQUEST:
client.order_book()
REQUEST:
REQUEST:
client.getOrderBook().then((orders) => {
console.log(orders)
}).catch((err) => {
console.log(err)
});
Trade Book
Field | Description | DataType | Sample Value |
---|---|---|---|
ClientCode | Pass the ClientCode. | String | 50000091 |
Field | Description | DataType |
---|---|---|
TradeBookDetail | List of TradeBookDetailV1 | List |
Status | Pass the Status. | Integer |
Message | Pass the Message. | String |
Field | Description | DataType |
---|---|---|
Exch | Pass the Exch. | Char |
ExchType | Pass the ExchType. | Char |
ScripCode | Pass the ScripCode. | Int |
ScripName | Pass Name of Scrip. | String |
BuySell | Pass Buy/Sell. | Char |
Qty | Pass the Qty. | Int |
PendingQty | Pass the PendingQty. | Int |
OrgQty | Pass the OrgQty. | Int |
Rate | Pass the Rate. | Double |
ExchOrderID | Pass the ExchOrderID. | String |
ExchangeTradeID | Pass the ExchangeTradeID. | String |
ExchangeTradeTime | Pass the ExchangeTradeTime. | DateTime |
TradeType | Pass the TradeType. | String |
DelvIntra | Pass the Delv / Intra. | Char |
Multiplier | Pass the Multiplier. | Double |
REQUEST:
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V1/TradeBook' \
--header 'Authorization: bearer {Your Access Token}' \
--header 'Content-Type: application/json' \
--header 'Cookie: NSC_JOh0em50e1pajl5b5jvyafempnkehc3=ffffffffaf103e0f45525d5f4f58455e445a4a423660' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ClientCode": "{Your Client Code}"
}
}'
REQUEST:
REQUEST:
client.get_tradebook()
REQUEST:
REQUEST:
client.getTradeBook().then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
});
Trade History
Request Body
Name | Desc | Required* | DataType |
---|---|---|---|
ClientCode | Pass the ClientCode. | Y | String |
ExchOrderID | Pass Order ExchOrderID. | Y | String |
Response Body
Name | Desc |
---|---|
TradeHistoryData | List of TradeHistoryData. |
Status | 0 for success In case of non zero code, refer following field for error description |
Message | Error description incase of non zero status or "Success". |
Trade History List Attributes:-
Name | Desc |
---|---|
Exchange | Returns the Exchange. |
ExchangeType | Returns the Exchange Type. |
ScripCode | Returns the Scrip Code. |
Symbol | Returns the Symbol. |
Product | Returns the Product. |
TransactionType | Returns the Transaction Type. |
TradedQty | Returns the Traded Qty. |
ExchOrderID | Returns the Exchange Order ID. |
RemoteOrderID | Returns the Remote Order ID. |
ExchangeTime | Returns the Exchange Time. |
TradePrice | Returns the Trade Price. |
TradeID | Returns the Trade ID. |
OrderType | Returns the Order Type. |
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/TradeHistory' \
--header 'Authorization: Bearer null' \
--header 'Content-Type: application/json' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ClientCode": "null",
"ExchOrderID":"{Exchange Order ID}"
}
}'
REQUEST:
client.get_trade_history("PASS EXCHANGE ORDER ID")
REQUEST:
Order Status
Field Name | Description | Sample Value |
---|---|---|
ClientCode | Pass your ClientCode | 12345678 |
OrdStatusReqList | List Of OrderStatusReqList | - |
Field Name | Description | Data Type |
---|---|---|
Exch | Exchange in which order has been placed. (N- NSE, B- BSE , M-MCX) | char |
RemoteOrderID | This will be unique ID for each order. | String |
Field Name | Description | Data Type | List of values |
---|---|---|---|
Status | Returns the status of the response. | Integer | A. -1 B. 0 C. 1 D. 2 |
Message | Returns the message of the response. | String | A. “Success” B. “No record found.” C. “Invalid input parameters.” D. “Invalid head parameters.” E. “Error while processing your request.” F. “Invalid Session” G. "No Order found for this Client. |
OrdStatusResLst Array Of OrdStatusResLst | Trade Details of that particular client | Array Of OrdStatusResLst | - |
FieldName | Type | Description |
---|---|---|
Exch | Char | Exchange in which order has been Placed. N- NSE, B-BSE, M-MCX |
ExchType | Char | Exchange segment C-Cash, D-Derivatives, U-Currency |
ScripCode | Int32 | Scrip Code of the particular stock |
Symbol | String | Symbol of the scrip. |
OrderQty | Int32 | Returns order quantity |
OrderRate | Double | Returns order rate |
ExchOrderID | Int32 | Order ID given by Exchange to an order. |
ExchOrderTime | DateTime | Time at which order has received by Exchange |
Status | String | Returns the status of the response. |
TradedQty | Int32 | Returns Traded Qty of an order. |
PendingQty | Int32 | Returns Pending Qty of an order. |
REQUEST:
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V2/OrderStatus' \
--header 'Authorization: bearer {Your Token}' \
--header 'Content-Type: application/json' \
--data-raw '{
"head": {
"key": "{You Key}"
},
"body": {
"ClientCode": "{Your Client Code}",
"OrdStatusReqList": [
{
"Exch": "{Exchange of your placed order}",
"RemoteOrderID": "{Tag used at the time of placing order}"
}
]
}
}'
REQUEST:
REQUEST:
req_list_= [
{
"Exch": "N",
"RemoteOrderID": "90980441"
}]
# Fetches the order status
client.fetch_order_status(req_list_)
REQUEST:
REQUEST
var a=[{ "Exch":"N", "RemoteOrderID":"1" }] client.getOrderStatus(a).then((Response) => { console.log(Response) }).catch((err) => { console.log(err) });
Trade Information
Field Name | Description | Data Type (max length) | List of values | Sample Value |
---|---|---|---|---|
ClientCode | Pass the registered client code of the user. | String(10) | - | 12345678 |
TradeInformationList | List Of TradeInformationList | List Of TradeInformationList | - | - |
Field Name | Description | Data Type (max length) | List of values |
---|---|---|---|
Exch | Exchange in which order has been placed. N- NSE, B- BSE ,M-MCX | Char | N B M |
ExchType | Exchange segment. C-Cash, D-Derivative, U – Currency | Char | C D U |
ScripCode | Scrip Code of the requested order. | Long | - |
RemoteOrderID | This will be unique ID for each order which was sent at the time of placing the order. | String | 112313 |
REQUEST:
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/TradeInformation' \
--header 'Authorization: bearer {Your Access Token}' \
--header 'Content-Type: application/json' \
--header 'Cookie: 5paisacookie=ym05vvsxopu5pxusz45y1ys3; NSC_JOh0em50e1pajl5b5jvyafempnkehc3=ffffffffaf103e0f45525d5f4f58455e445a4a423660' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ClientCode": "{Your Client Code}",
"TradeInformationList": [
{
"Exch": "N",
"ExchType": "C",
"ScripCode": {Order ScripCode},
"ExchOrderID": {ExchangeOrderID}
}
]
}
}'
REQUEST:
REQUEST:
req_list= [
{
"Exch": "N",
"ExchType": "C",
"ScripCode": 20374,
"ExchOrderID": "1000000015310807"
}]
# Fetches the trade details
client.fetch_trade_info(req_list)
REQUEST:
REQUEST:
a=[
{
"Exch":"N",
"ExchType":"C",
"ScripCode":11111,
"RemoteOrderID":"5712977609111312242"
}
]
client.getTradeInfo(a).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
});
Historical Data
- 1m - 1 minute
- 5m - 5 minute
- 10m - 10 minute
- 15m - 15 minute
- 30m - 30 minute
- 60m - 60 minute
- 1d - 1 day
Field Name | Description | Sample Value |
---|---|---|
Exch | Exchange of the scrip N – NSE B – BSE M – MCX (ExchType will be D) n – NCDEX (only if ExchType is X) |
N B M |
ExchType | Exchange segment of the scrip c – Cash d – Derivative (Commodity if exchange is M) u – Currency Derivative x – NCDEX commodity y – Commodity |
c d u x y |
ScripCode | Unique number for particular scrip | 1660 |
Interval | Interval for candle data. 1m - 1 minute 5m - 5 minute 10m - 10 minute 15m - 15 minute 30m - 30 minute 60m - 60 minute 1d - 1 day |
1m 5m 10m 15m 30m 60m 1d |
FromDate | Date from which candle data needs to be fetched (Format: YYYY-MM-DD) | 2021-01-01 |
EndDate | Date to which candle data needs to be fetched (Format: YYYY-MM-DD) | 2021-05-30 |
Field Name | Description | Data Type | Sample Value |
---|---|---|---|
status | Status of the response | String | Cannot be empty |
data | Contains the data of requested candles | - | |
candles | An array of the OHLC and volume data along with timestamp | Array | [[ Datetime,Open,High,Low,Close,Volume],[Datetime,Open,High,Low,Close,Volume]] |
Field Name | Description | Data Type | Sample Value |
---|---|---|---|
Timestamp | This is the timestamp of the data in the format of YYYY-MM-DDTHH:MM:SS | String | 2021-04-01T09:15:00 |
Open | This is the open rate at given time stamp | Double | 1480.2 |
High | This is the high rate at given time stamp | Double | 1501.35 |
Low | This is the low rate at given time stamp | Double | 1420 |
Close | This is the close rate at given time stamp | Double | 1492.95 |
Volume | This is the volume at given time stamp | Integer | 39003540 |
REQUEST:
REQUEST:
curl --location --request GET 'https://openapi.5paisa.com/historical/n/c/1594/5m?from=2021-05-24&end=2021-05-27' \
--header 'Ocp-Apim-Subscription-Key: c89dgt8d888a426d9e00db888b433027' \
--header 'x-clientcode: {Your client code}' \
--header 'x-auth-token: {Your Access Token}' \
/code>
REQUEST:
REQUEST:
#historical_data(exchange,exchange type,scrip code,time frame,from data,to date)
df=client.historical_data('N','C',1660,'15m','2021-05-25','2021-06-16')
print(df)
# Note : TimeFrame Should be from this list ['1m','5m','10m','15m','30m','60m','1d']
REQUEST:
REQUEST:
// historicalData(exchange,exchange type,scrip code,time frame,from data,to date)
a=client.historicalData('n', 'c', '1660', '1m','2021-05-31', '2021-06-01')
//Note: Timeframe should be from this list ['1m','5m','10m','15m','30m','60m','1d']
Market Depth
This API is used to fetch market depth (bid/ask prices) up-to Level 5.
Request
Field Name | Description | Data Type | Examples |
---|---|---|---|
Exchange | Exchange Code | String | N-NSE, B-BSE |
ExchangeType | ExchangeType | String | C-Cash, D-Derivatives |
ScripCode |
ScripCode | String | ITC-1660 |
ScripData | ScripData | String | ITC_EQ |
ClientCode | 5p Client Code | String |
*Note:- Either ScripCode or ScripData is required. If both are present in request then ScripCode will be considered.
Response
Field Name | Description | Example |
---|---|---|
Exchange | Exchange Code | N-NSE, B-BSE(String) |
ExchangeType | ExchangeType | C-Cash, D-Derivatives(String) |
CacheTime | Returns the CacheTime of the response. | 5(int) |
BbBuySellFlag |
Bid/Ask Flag |
66- Bid, 83-Ask(Int) |
NumberOfOrders | Orders | 6(int) |
Price | Price | 2500(int) |
Quantity | Quantity | 86(int) |
REQUEST:
curl --location 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V2/MarketDepth' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {Your Access Token}
' \
--data '{
"head": {
"key": "{Your Vendor/User Key}
"
},
"body": {
"ClientCode": "{client_code}",
"Exchange":"N",
"ExchangeType":"C",
"ScripCode":2885,
"ScripData":"RELIANCE_EQ"
}
}'
REQUEST:
REQUEST:
Compact Market Snapshot
(HEAD PARAMETERS NOT INCLUDED)
Field Name | Description | Data Type | Examples |
---|---|---|---|
Count | Pass the ClientCode. | long | 1 |
MarketFeedData | Array of MarketFeedDataListReq | List | - |
ClientLoginType | Pass the ClientLoginType. | Integer | 0 |
LastRequestTime | Pass the LastRequestTime. | DateTime | /Date(0)/ |
RefreshRate | Pass the RefreshRate. | String | H |
Field Name | Description | Data Type | Examples |
---|---|---|---|
1 | Exch | Pass the Exch. | String |
ExchType | Pass the ExchType. | String | C |
Symbol | Pass the Symbol. | String | BHEL |
Expiry | Pass the Expiry. | String | |
StrikePrice | Pass the StrikePrice. | Double | 0 |
OptionType | Pass the OptionType. | String |
(HEAD PARAMETERS NOT INCLUDED)
Field Name | Description | Data Type |
---|---|---|
1 | Status | Returns the status of the response. |
Message | Returns the message of the response. | String |
CacheTime | Returns the CacheTime of the response. | Integer |
TimeStamp | Returns the TimeStamp of the response. | DateTime |
Data | Trade Details of that particular client | Array Of MarketFeedDataListRes |
Field Name | Description | Data Type |
---|---|---|
1 | Exch | Returns the Exch. |
ExchType | Returns the ExchType. | Char |
Token | Returns the Scrip Code. | Integer |
LastRate | Returns the LastRate. | Double |
TotalQty | Returns the TotalQty. | Integer |
High | Returns the High. | Double |
Low | Returns the Low. | Double |
PClose | Returns the PClose. | Double |
AvgRate | Returns the AvgRate. | Double |
Time | Returns the Time. | Integer |
TickDt | Returns the TickDt. | Date |
REQUEST:
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/MarketFeed' \
--header 'Authorization: bearer {Your Access Token}' \
--header 'Content-Type: application/json' \
--header 'Cookie: NSC_JOh0em50e1pajl5b5jvyafempnkehc3=ffffffffaf103e0f45525d5f4f58455e445a4a423660' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"Count": 1,
"MarketFeedData": [
{
"Exch": "N",
"ExchType": "C",
"Symbol": "BHEL",
"Expiry": "",
"StrikePrice": "0",
"OptionType": ""
}
],
"ClientLoginType": 0,
"LastRequestTime": "/Date(0)/",
"RefreshRate": "H"
}
}'
/code>
REQUEST:
REQUEST:
#NOTE : Symbol has to be in the same format as specified in the example below.
req_list_=[{"Exch":"N","ExchType":"D","Symbol":"NIFTY 22 APR 2021 CE 15200.00","Expiry":"20210422","StrikePrice":"15200","OptionType":"CE"},
{"Exch":"N","ExchType":"D","Symbol":"NIFTY 22 APR 2021 PE 15200.00","Expiry":"20210422","StrikePrice":"15200","OptionType":"PE"}]
client.fetch_market_feed(req_list_)
REQUEST:
REQUEST:
a=[
{
"Exch":"N",
"ExchType":"D",
"Symbol":"NIFTY 27 MAY 2021 CE 14500.00",
"Expiry":"20210527",
"StrikePrice":"14500",
"OptionType":"CE"
}]
client.getMarketFeed(a).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
});
Full Market Snapshot
(HEAD PARAMETERS NOT INCLUDED)
Field Name | Description | Data Type |
---|---|---|
ClientCode | Pass the ClientCode. | String |
Count | Pass the Count. | Long |
Data | List of MarketDepthReqData | List |
Field Name | Description | Data Type |
---|---|---|
Exch | Pass the Exch. | String |
ExchType | Pass the ExchType. | String |
ScripCode | Pass the ScripCode. | Integer |
(HEAD PARAMETERS NOT INCLUDED)
Field Name | Description | Data Type |
---|---|---|
LastTradeTime | Pass the LastTradeTime. | DateTime |
NetChange | Pass the NetChange. | String |
Open | Pass the Open. | String |
High | Pass the High. | String |
Low | Pass the Low. | String |
Close | Pass the Close. | String |
Volume | Pass the Volume. | String |
AverageTradePrice | Pass the AverageTradePrice. | Double |
LastTradedPrice | Pass the LastTradedPrice. | Double |
LastQuantity | Pass the LastQuantity. | Integer |
BuyQuantity | Pass the BuyQuantity. | Integer |
SellQuantity | Pass the SellQuantity. | Integer |
TotalBuyQuantity | Pass the TotalBuyQuantity. | Integer |
TotalSellQuantity | Pass the TotalSellQuantity. | Integer |
OpenInterest | Pass the OpenInterest. | Integer |
Exchange | Pass the Exchange. | String |
ExchangeType | Pass the ExchangeType. | String |
ScripCode | Pass the ScripCode. | Integer |
REQUEST:
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/MarketDepth' \
--header 'Authorization: bearer {Your Access Token}' \
--header 'Content-Type: application/json' \
--header 'Cookie: 5paisacookie=qwmwpam1su3s4lvwlwyevrl5; NSC_JOh0em50e1pajl5b5jvyafempnkehc3=ffffffffaf103e0f45525d5f4f58455e445a4a423660' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ClientCode": "{Your Client Code}",
"Count": "1",
"Data": [
{
"Exchange": "N",
"ExchangeType": "C",
"ScripCode": "2885"
},
{
"Exchange": "N",
"ExchangeType": "C",
"ScripCode": "2885"
},
{
"Exchange": "N",
"ExchangeType": "D",
"ScripCode": "542003"
}
]
}
}'
REQUEST:
REQUEST:
a=[{"Exchange":"N","ExchangeType":"C","ScripCode":"2885"},
{"Exchange":"N","ExchangeType":"C","ScripCode":"1660"},
]
print(client.fetch_market_depth(a))
REQUEST:
REQUEST:
a=[{"Exchange":"N","ExchangeType":"D","ScripCode":"51440"},{"Exchange":"N","ExchangeType":"C","ScripCode":"1660"}]
client.getmarketdepth(a).then((response) => {
console.log(response)
}).catch((err) => {
console.log(err)
});
Full Market Snapshot (By Symbol)
Request Body
Name | Desc | Required* | DataType |
---|---|---|---|
ClientCode | Pass the ClientCode. | Y | String |
Count | Pass the Number of ScripList. | Y | Long |
Data | List of MarketDepth | Y | List |
Data Structure:-
Name | Desc | Required* | DataType |
---|---|---|---|
Exchange | Pass the Exchange. N - Nse B - Bse M - Mcx |
Y | String |
ExchangeType | Pass the ExchangeType. C - Cash D - Derivatives U - Currency |
Y | String |
Symbol |
Pass the ScripName. For Example:- NSE,Cash, RELIANCE NSE,Derivatives, BANKNIFTY 10 Mar 2022 CE 41600.00 *Full Name from the scripmaster file |
Y | String |
Response Attributes
Name | Desc |
---|---|
LastTradeTime | Returns the LastTradeTime. |
NetChange | Returns the NetChange. |
Open | Returns the Open. |
High | Returns the High. |
Low | Returns the Low. |
Close | Returns the Close. |
Volume | Returns the Volume. |
AverageTradePrice | Returns the Average Trade Price. |
LastTradedPrice | Returns the Last Traded Price. |
LastQuantity | Returns the Last Quantity. |
BuyQuantity | Returns the Buy Quantity. |
SellQuantity | Returns the Sell Quantity. |
TotalBuyQuantity | Returns the Total Buy Quantity. |
TotalSellQuantity | Returns the Total Sell Quantity. |
OpenInterest | Returns the Open Interest. |
Exchange | Returns the Exchange. |
ExchangeType | Returns the Exchange Type. |
ScripCode | Returns the ScripCode. |
UpperCircuitLimit | Returns the Upper Circuit Limit. |
LowerCircuitLimit | Returns the Lower Circuit Limit. |
MktLot | Returns the MktLot. |
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V1/MarketDepth' \
--header 'Authorization: Bearer null' \
--header 'Content-Type: application/json' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ClientCode": "null",
"Count": "1",
"Data": [
{
"Exchange": "N",
"ExchangeType": "C",
"Symbol": "RELIANCE"
},
{
"Exchange": "N",
"ExchangeType": "D",
"Symbol": "BANKNIFTY 31 Mar 2022 CE 35600.00"
}
]
}
}'
REQUEST:
a=[{"Exchange":"N","ExchangeType":"C","Symbol":"RELIANCE"},
{"Exchange":"N","ExchangeType":"D","Symbol":"BANKNIFTY 31 Mar 2022 CE 35600.00"},
]
print(client.fetch_market_depth_by_symbol(a))
REQUEST:
Market Status
Head
Name | Desc |
---|---|
Status | 0 for success In case of non zero code, refer following field for error description |
StatusDescription | Error description incase of non zero status or "Success". |
MarketStatusList
Name | Desc |
---|---|
Exch | Returns the Exchange. |
ExchType | Returns the ExchangeType. |
ExchDescription | Returns the information of Segment. |
MarketStatus | Returns the Market Status (Open or Close) |
REQUEST:
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/MarketStatus' \
--header 'Authorization: bearer access_token' \
--header 'Content-Type: application/json' \
--data-raw '{
"head": {
"key": "<Your Key>"
},
"body": {
"ClientCode": "<Your Client Code>"
}
}'
REQUEST:
client.get_market_status()
REQUEST:
client.getMarketStatus().then((Response)=>{
console.log(Response)
}).catch((err)=>{
console.log(err)
})
Trading IDEAs
Field Name | Description | Data Type | Validation | Sample Value |
---|---|---|---|---|
ClientCode
|
This the client code of particular client
|
String
|
Cannot be empty
|
Dummy
|
REQUEST:
REQUEST:
curl --location --request POST 'https://Openapi.5paisa.com/VendorsAPI/Service1.svc/TraderIDEAs' \
--header 'Authorization: bearer abc' \
--header 'Content-Type: application/json' \
--header 'Cookie: 5paisacookie=taa4m4za1azcwryekinvf2us; NSC_JOh0em50e1pajl5b5jvyafempnkehc3=ffffffffaf103e0c45525d5f4f58455e445a4a423660' \
--data-raw '{
"head": {
"key": "{Your Vendor/User Key}"
},
"body": {
"ClientCode": "{Your Client Code}"
}
}'
REQUEST:
REQUEST:
#To get actionable buy trades use:-
print(Client.get_buy())
#To get list of current trades use:-
print(Client.get_trade())
REQUEST:
REQUEST:
client.ideas_trade().then((positions) => {
console.log(positions)
}).catch((err) => {
console.log(err)
});
Encryption
EDIS
To sell a stock in your DMAT account you need to complete EDIS process. We are offering this through API, please refer the form on right hand side.
Process for EDIS-
1. Create .html file with form data which is mentioned on right hand side.
2. Open the HTML file in browser and complete Sell authorization process.
REQUEST:
<form name= "VEdisForm" method = "post"
action="https://dev-openapi.5paisa.com/WebVendorLogin/EDISAuthorization/Authorization" >
<input type= "hidden" name= "AccessToken" value= "{Access Token}"/>
<input type= "hidden" name= "ClientCode" value="{client_code}" />
<input type= "hidden" name= "VendorKey" value="{Your Vendor/User Key}
" />
<input type= "hidden" name= "ResponseURL" value="{Your Redirect URL e.g.https://google.com}" />
<div>
<button>Authorize</button>
</div>
</form>
REQUEST:
REQUEST:
Publisher JS Library
Publisher JS allows you to Embed Trade button on your Web or App with very less development efforts. All you have to do is copy paste few lines of code and you are good to go.
Advantages –
- Inbuild User Login Flow.
- In App Experience for Order Placement
- Quick Integration with less coding efforts.
- No Exchange Approval for Order Placement Screens.
- Free of cost
Please follow below Steps for Publisher JS Integration.
Library Install
You need to add below line of code in your Website or App.
You need to copy this filed just before closing the body tag and only including it once should suffice.
<script src="https://tradechart.5paisa.com/plugin/plugin.js"></script>
Add Branded Button
To render Branded 5paisa Button on your app use <FIVEP-BUTTON> HTML tag and copy paste below data points.
<FIVEP-BUTTON
data-fivepvendorkey="
data-scripdata="RELIANCE_EQ"
data-exchange="NSE"
data-transaction_type="BUY"
data-exchange_type= "C"
data-price="2535.65"
data-qty="5"
></FIVEP-BUTTON>
Custom Button
<button
data-fivepvendorkey="
data-scripdata="RELIANCE_EQ"
data-transaction_type="BUY"
data-exchange_type= "C"
data-price="2535.65"
data-qty="5"
>
Buy RELIANCE
</button>
Dynamic Button with Single Stock
<button id="custom-button">Buy SBI Dynamic</button>
<script>
fivePaisaConnect.ready(function () {
var fivePaisa = new fivePaisaConnect(
"YnJ4JYpdZweCOhX2zCXeWiOg7EZwkV
);
fivePaisa.add({
scripdata: "SBIN_EQ",
exchange: BSE,
transaction_type: "BUY",
script_code: "500112",
price: 590.00,
qty: 10,
exchange_type: "C",
intraday: false,
});
fivePaisa.fivepButton("#custom-button");
});
Dynamic Button with Baset
<script>
fivePaisaConnect.ready(function () {
var fivePaisa = new fivePaisaConnect(
"YnJ4JYpdZweCOhX2zCXeWiOg7EZwkV
);
fivePaisa.Multipleadd([
{
scripdata: "RELIANCE",
exchange: BSE,
transaction_type: "SELL",
script_code: "500325",
order_type: "LIMIT",
product: "MIS",
price: 2485.0,
qty: 15,
variety: "co",
readonly: true,
exchange_type: "C",
is_intraday: false,
},
{
scripdata: "AXISBANK",
exchange: NSE,
transaction_type: "SELL",
script_code: "3456",
order_type: "LIMIT",
product: "MIS",
price: 384.4,
qty: 5,
variety: "co",
readonly: true,
exchange_type: "C",
is_intraday: false,
},
]);
fivePaisa.link("#custom-btn");
});
</script>
Input Variables
API Key - This key is your api key and is being provided by 5paisa.
data-fivepvendorkey = YnJ4JYpdZweCOhX2zCXeWiOg7EZwkV
Order Type –
Market - data-price =0
Limit Order - data-price = 200
IntradayOrder - data-IsIntraday=”true/false”
StopLoss order - data-IsStopLossOrder="true/false"
data-StopLossPrice="20"
ScritpData / ScriptCode - ScritpData or ScriptCode one of the field is required.
ScriptCode you can obtain from
Format for ScriptData
EQUITY
Format: SYMBOL_EQ
Ex. ScriptData :RELIANCE_EQ
FUTURE
Format - SYMBOL_yyyymmdd
Ex.NIFTY 30 Sep 2021_20210930
OPTION
Symbol : BANKNIFTY 24 Nov 2022 CE 41600.00
Format : SYMBOL_YYYYMMDD_CE/PE_STRIKE
Ex. BANKNIFTY 24 Nov 2022 CE 41600.00_20221124_CE_41600
BANKNIFTY 29 Mar 2023 CE 41600.00_20230329_CE_41600
REQUEST:
REQUEST:
REQUEST: