Step 1
We need to run Web API service using Postman and enable Postman Interceptor (to get cookies).
Use our new Login API V4 in order to get JWT token in body of response (this would be passed in Login Check Api)
URL https://openfeed.5paisa.com/Feeds/api/UserActivity/LoginCheck
{
"head": {
"requestCode": "Pass requestCode",
"key": "Pass Key",
"appVer": "Pass App Version",
"appName": "Pass App Name",
"osName":"Pass Operating System Name",
"LoginId":"Pass LoginId",
},
"body": {
"RegistrationID" : "Pass JWT Token",
}
}
{
"head": {
"requestCode": "5PLoginCheck",
"key": "V5ts2aUAlJUZgHq3xACmhusIi0dI45I0",
"appVer": "1.0",
"appName": "5P51882016",
"osName":"Web",
"LoginId":"51882016",
},
"body": {
"RegistrationID" : "eyKuw3MiOiJ0b3B0YWwuY29tIiwiZXhwIjoxNDI2NDIwODAwLCJodHRwOi8vdG9wdGFsLmNvbS9qd3RfY2xhaW1zL2lzX2FkbWluIjp0cThDso
Jjb21wYW55IjoiVG9wdGFsIiwiYXdlc29tZSI6dHJ1ZX0",
}
}
{
"body": {
"Message": "Success",
"Status": 0
},
"head": {
"responseCode": "5PLoginCheck",
"status": 0,
"statusDescription": "Success"
}
}
{
"body": {
"Message": "Success",
"Status": 0
},
"head": {
"responseCode": "5PLoginCheck",
"status": 0,
"statusDescription": "Success"
}
}
Note:-
In Response if we get Status 0 and Message "Success", then Form Authentication Token will be generated and we will get Token in“.ASPXAUTH”in Cookies section in Response body but to get this Postman Interceptor should be enabled and for that please install Postman Interceptor.
*In cookies response of Login Check API we need .ASPXAUTH of domain:- 5paisa.com (.ASPXAUTH would be passed as a cookie to establish websocket connection)
{
"body": {
"Message": "Incorect Credentials",
"Status": 1
},
"head": {
"responseCode": "5PLoginCheck",
"status": 0,
"statusDescription": "Success"
}
}
Note:- In Response if we get Status 1 and Message "Incorrect Credentials", then Form Authentication Token will not be generated and we will not get Token in“.ASPXAUTH”in Cookies section in Response body.
{
"body": {
"Message": "Invalid body parameters.",
"Status": 2
},
"head": {
"responseCode": "5PLoginCheck",
"status": 0,
"statusDescription": "Success"
}
}
In Response if we get Status 2 and Message "IInvalid body parameters.", then Form Authentication Token will not be generated and we will not get Token in“.ASPXAUTH”in Cookies section in Response body.
Step 2 (This must be tried using a websocket client which supports passing of cookie for handshaking)
In URL please enter:-
wss://openfeed.5paisa.com/Feeds/api/chat?Value1=<
Sample URL:-
“wss://openfeed.5paisa.com/Feeds/api/chat?Value1=eyKuw3MiOiJ0b3B0YWwuY29tIiwiZXhwIjoxNDI2NDIwODAwLCJodHRwOi8vdG9wdGFsLmNvbS9qd3RfY2xhaW1zL2lzX2FkbWluIjp0cTh
DsoJjb21wYW55IjoiVG9wdGFsIiwiYXdlc29tZSI6dHJ1ZX0|51882016”
Value1 is basically contains JWT Token which we get at the time of Login API(in response body).
Once you open your application form then, put the JWT which you’ll get from Login and ClientCode as shown by the placeholder in above link.
In order to establish websocket connection successfully you have to pass .ASPXAUTH cookie (received from Login Check API) as a cookie for websocket api.
After Connecting to Websocket It will start giving you feeds scrip or request which you entered in request code(payload).
Subscribing/Unsubscribing to scrips to get live feeds
| Request | Method Name |
|---|---|
| Get Live Quotes | MarketFeedV3 |
| Get Market Depth | MarketDepthService |
| Get Open Interest | GetScripInfoForFuture |
{"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}
]}
And click on Send Button. We are basically Subscribing N,C,15083 for a particular Client Code.
We will now get live feeds.
Similarly if we 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.
At one time you can get feeds using LoginId and JWT. If you use same LoginId and RegistrationID again to get feeds, it will allow you to login and get feeds but earlier session for that LoginId and JWT will be disconnected.
Unsubscribing Scrips (To stop getting feeds for particular scrips)
If user wishes 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)\/"}]