Developer APIs

Market Depth

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

Request:-
{
"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",
    }
}
Request (Sample Request):-
{
"head": {
    "requestCode": "5PLoginCheck",
    "key": "V5ts2aUAlJUZgHq3xACmhusIi0dI45I0",
    "appVer": "1.0",
    "appName": "5P51882016",
    "osName":"Web",
    "LoginId":"51882016",
},
"body": {
    "RegistrationID" : "eyKuw3MiOiJ0b3B0YWwuY29tIiwiZXhwIjoxNDI2NDIwODAwLCJodHRwOi8vdG9wdGFsLmNvbS9qd3RfY2xhaW1zL2lzX2FkbWluIjp0cThDsoJjb21wYW55IjoiVG9wdGFsIiwiYXdlc29tZSI6dHJ1ZX0",
    }
}
Success Response:-
{
    "body": {
    "Message": "Success",
    "Status": 0
 },
    "head": {
    "responseCode": "5PLoginCheck",
    "status": 0,
    "statusDescription": "Success"
 }
}
                                        
Sample Response:-
{
    "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)

Failure Response:-
{
    "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.

Failure Response:-
{
    "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=eyKuw3MiOiJ0b3B0YWwuY29tIiwiZXhwIjoxNDI2NDIwODAwLCJodHRwOi8vdG9wdGFsLmNvbS9qd3RfY2xhaW1zL2lzX2FkbWluIjp0cThDsoJjb21wYW55IjoiVG9wdGFsIiwiYXdlc29tZSI6dHJ1ZX0|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

Step 3 Refer to below table to map requests:-
Request Method Name
Get Live Quotes MarketFeedV3
Get Market Depth MarketDepthService
Get Open Interest GetScripInfoForFuture
Market Depth

Note:- 1st and 2nd Step will be the same. For 3rd Step refer to the things mentioned below.

In Request please enter:-
{"Method":"MarketDepthService","Operation":"Subscribe",
"ClientCode":"<<Pass ClientCode>>","MarketFeedData":[
{"Exch":"N","ExchType":"D","ScripCode":50210}
]}
                                    

And click on Send Button. We are basically Subscribing N,D,50210 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":"MarketDepthService","Operation":"Subscribe",
"ClientCode":"<<Pass ClientCode>>","MarketFeedData":[
{"Exch":"N","ExchType":"D","ScripCode":50210},
{"Exch":"N","ExchType":"D","ScripCode":52699},
{"Exch":"N","ExchType":"D","ScripCode":98562},
{"Exch":"N","ExchType":"D","ScripCode":98563},
{"Exch":"N","ExchType":"D","ScripCode":98564},
]}
                                    

If we click on Close then we will stop receiving live feeds which means that user has Signed out.
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.

If user wishes to Unsubscribe a particular scrip we need to pass following in
Request:-
{"Method":"MarketDepthService","Operation":"Unsubscribe",
"ClientCode":"<<Pass ClientCode>>","MarketFeedData":[
{"Exch":"N","ExchType":"D","ScripCode":50210}
]}
                                    

In this case we will continue receiving feeds of N,D,52699 | N,D,98562 | N,D,98563 | N,D,98564 and we will stop receiving live feeds of N,D,50210 as we have unsubscribed this scrip.

Response for Market Depth Data:-
{"Exch":"N","ExchType":"C","Token":1660,"TBidQ":2183351,"TOffQ":2444311,"Details":[
{"Quantity":1760,"Price":204.85,"NumberOfOrders":17,"BbBuySellFlag":66},
{"Quantity":13288,"Price":204.8,"NumberOfOrders":74,"BbBuySellFlag":66},
{"Quantity":39836,"Price":204.75,"NumberOfOrders":54,"BbBuySellFlag":66},
{"Quantity":24559,"Price":204.7,"NumberOfOrders":65,"BbBuySellFlag":66},
{"Quantity":36290,"Price":204.65,"NumberOfOrders":46,"BbBuySellFlag":66},
{"Quantity":7,"Price":204.9,"NumberOfOrders":2,"BbBuySellFlag":83},
{"Quantity":7593,"Price":204.95,"NumberOfOrders":14,"BbBuySellFlag":83},
{"Quantity":8440,"Price":205,"NumberOfOrders":21,"BbBuySellFlag":83},
{"Quantity":18204,"Price":205.05,"NumberOfOrders":23,"BbBuySellFlag":83},
{"Quantity":36755,"Price":205.1,"NumberOfOrders":27,"BbBuySellFlag":83}],"TimeStamp":0,"Time":"\/Date(1620716798461)\/"}