openapi-5p / 5paisa-js Goto Github PK
View Code? Open in Web Editor NEWOfficial NodeJS SDK for 5paisa APIs natively written in .NET
Official NodeJS SDK for 5paisa APIs natively written in .NET
Hi Team,
I used the following example
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.login("[email protected]", "password", "YYYYMMDD").then((response) => {
* client.init(response).then(() => {
* // Fetch holdings, positions or place orders here.
* // See following examples.
* })
* }).catch((err) =>{
* // Oh no :/
* console.log(err)
* })
I have passed all the values properly.
and getting following response
Invalid Input Parameters.
Hey,
How do I get the LTP of a stock using this 5paisa JS API?
Please help.
Regards,
I am trying to login using 5paisa api but getting the message as invalid input parameters.Have check the configurations several times there seem to be no problem with configuration.The API code snippet is here:
const conf = {
"appSource": "****",
"appName": "",
"userId": "-",
"password": "",
"userKey": "",
"encryptionKey": ""
}
const { FivePaisaClient } = require("5paisajs")
var client = new FivePaisaClient(conf)
client.login("[email protected]", "abcd#12345", "yyyymmdd").then(
(response) => {
console.log(response)
}).catch((err) => {
console.log(err)
return res.json({
eror: err
})
})
The getPositions()
API gives BookedPL
& LTP
for each position, but BuyAvgRate
and SellAvgRate
are zero:
{
BodQty: 200,
BookedPL: 0,
BuyAvgRate: 0,
BuyQty: 0,
BuyValue: 0,
Exch: 'N',
ExchType: 'D',
LTP: 58.55,
MTOM: 610,
Multiplier: 1,
NetQty: 200,
OrderFor: 'D',
PreviousClose: 55.5,
ScripCode: 50035,
ScripName: 'NIFTY 11 Nov 2021 PE 17600.00',
SellAvgRate: 0,
SellQty: 0,
SellValue: 0
}
It would help if BuyAvgRate
and SellAvgRate
can be obtained, or if UnbookedPL
could be added.
I am getting error by fetching the live feed,
here is my code
client.login("usernameentered", "passwordentered", "code").then((response) => {
client.init(response).then(() => {
console.log(response.data.body.JWTToken)
const options = {
method: 'POST',
url: "https://openfeed.5paisa.com/Feeds/api/UserActivity/LoginCheck",
headers: {
//"requestCode": "5PLoginV4",
"requestCode": "5PLoginCheck",
"key": "keyentered",
"appVer": "1.0",
"appName": "inserted",
"osName": "web",
"LoginId": "inserted",
},
form: {
"RegistrationID": response.data.body.JWTToken
},
json: true
};
request(options, (error, resp, body) => {
if (error) {
console.log(resp, body, error)
process.exit();
}
console.log(body);
//HERE I AM GETTING ERROR WHICH IS ATTACHED
});
})
The 5paisajs
package on https://www.npmjs.com/package/5paisajs doesn't seems to be updated with this repository and is broken as a result. The const.js
and utils.js
files are missing from the package repository and as a result the node application is crashing and is unable to start. Hope this issue will be Resolved.
In const.js file LastRequestTime:/Date(${today})/
should be changed to In const.js file LastRequestTime:/Date(${0})/
for normal functioning of latest market watch api. please check and consider.
I am using the below code to login using the credentials, but getting 400 Bad Request.
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.login("[email protected]", "password", "YYYYMMDD").then((response) => {
* console.log(response);
* }).catch((err) =>{
* // Oh no :/
* console.log(err)
* })
Please help me resolve the issue.
Hi,
Do you plan to provide type definition files anytime soon?
Thanks
Nice to see 5paisa has a sdk. But it is missing the most important functionality of market feed also websocket support. Also the api docs is not very clear and hardly updated. No clue on the formats of each symbol (like nifty 04 March 2021 ce) and also what each exchange type and exchange mean. Would be nice if the the sdk had market feeds and the docs were regularly updated
Is there any way I can subscribe to live feed for Unbooked P/L?
How does 5paisa web/app do that?
This will be very handy for triggering stop-loss.
Followed the steps as per doc, and using postman interceptor too.
https://invest.5paisa.com/DeveloperAPI/LiveQuotes
Using Postman WebSocket
URL: wss://openfeed.5paisa.com/Feeds/api/chat?Value1=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjU3MjA5NTc0Iiwicm9sZSI6IkNsaWVudCIsIm5iZiI6MTYyMzQ4OTIxOSwiZXhwIjoxNjMxMjY1MjE5LCJpYXQiOjE2MjM0ODkyMTl9.Blf6z4bp9KNe_MVWWtap_-Yo38SeeTxL7utQoqHvlrg
Error:
Error: Unexpected server response: 401
Handshake Details
Request URL: https://openfeed.5paisa.com/Feeds/api/chat?Value1=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1bmlxdWVfbmFtZSI6IjU3MjA5NTc0Iiwicm9sZSI6IkNsaWVudCIsIm5iZiI6MTYyMzQ4OTIxOSwiZXhwIjoxNjMxMjY1MjE5LCJpYXQiOjE2MjM0ODkyMTl9.Blf6z4bp9KNe_MVWWtap_-Yo38SeeTxL7utQoqHvlrg
Request Method: GET
Status Code: 401 Unauthorized
Request Headers
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: 3HxzDQYRvpJAUtz0yPxrCw==
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Host: openfeed.5paisa.com
Response Headers
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Server: Microsoft-IIS/8.5,VIKDCPUONFP165
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Sat, 12 Jun 2021 09:15:51 GMT
try{ const client = await fetchClient(user); const holdings = await client.getHoldings(); console.log("Holdings are: ") console.log(holdings) }catch(err){ console.log(err) }
When I ran this code, empty holdings took it to the error block instead of simply returning an empty array
I need to calculate margin required for basket order.
Is there any API that I can call before placing actual orders?
Someone please help me...
Currently the getHoldings()
and getPositions()
functions are fetching the data and printing it out on console, which makes them unusable for further purposes.
login()
function for future use so we don't have to send the Email ID and password for every subsequent request of fetching the user portfolio.Thanks!
Hi,
I am trying to login with the keys from https://www.5paisa.com/developerapi/apikeys and my email, password, and date of birth but I am getting the following error
{
body: null,
head: {
responseCode: '5PLoginV2',
status: '2',
statusDescription: 'Invalid head parameters.'
}
}
TypeError: Cannot read property 'ClientCode' of null
I recently joined 5paisa and want to use the API can you help resolve this issue.
Hi! I just downloaded the package 5paisajs from npm. Node threw an error for the line of code
const { FivePaisaClient } = require('5paisajs');
Error At: node_modules/node-pandas/src/utils/utils.js:1:18
Due to the file located at node_pandas/src/utils/datatype.js
when I renamed it as dataType.js the error was gone!
was that really I typo?
Hi,
I am getting following error on login attempt in my JS app.
Access to XMLHttpRequest at 'https://openapi.5paisa.com/VendorsAPI/Service1.svc/V4/LoginRequestMobileNewbyEmail' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource..
What do I need to do?
Thanks
axios <=0.21.1
Severity: high
Incorrect Comparison in axios - GHSA-cph5-m8f7-6c5x
Server-Side Request Forgery in Axios - GHSA-4w2v-q235-vp99
No fix available
node_modules/5paisajs/node_modules/axios
5paisajs *
Depends on vulnerable versions of axios
node_modules/5paisajs
2 high severity vulnerabilities
The npm package table
is required by index.js
but is not mentioned in package.json
and hence is not installed.
Below is my configuration
used keys from https://invest.5paisa.com/DeveloperAPI/APIKeys
const conf = {
"appSource": "WEB",
"appName": "ABC",
"userId": "userid",
"password": "password",
"userKey": "email encrypted key",
"encryptionKey": "encyption key"
}
const { FivePaisaClient } = require("5paisajs")
var client = new FivePaisaClient(conf)
client.login("email", "password", "dob").then((response) => {
client.init(response).then(() => {
console.log('success')
})
}).catch((err) =>{
console.log(err)
})
Getting below error
TypeError: Cannot read property 'Message' of null
at /home/rocket/fireworks/5paisaApi/node_modules/5paisajs/index.js:107:30
at new Promise (<anonymous>)
at FivePaisaClient.init (/home/rocket/fireworks/5paisaApi/node_modules/5paisajs/index.js:104:19)
at execute (/home/rocket/fireworks/5paisaApi/app.js:20:32)
at process._tickCallback (internal/process/next_tick.js:68:7)
on debugging below 5paisajs library code
this.init = function (response) {
var promise = new Promise(function (resolve, reject) {
if (response.data.body.Message == "") {
console.log(GREEN, `Logged in`);
CLIENT_CODE = response.data.body.ClientCode;
resolve();
} else {
console.log(RED, response.data.body.Message);
reject(response.data.body.Message);
}
});
return promise;
};
i found below actual error
i dont know what parameters are invalid
Thanks for help in advance
Please share an example of live feed for open interest.
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.