Giter VIP home page Giter VIP logo

5paisa-js's People

Contributors

5paisa avatar ba11b0y avatar gd5paisa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

5paisa-js's Issues

Unable to login 5Paisa using Node.js API - Error: Invalid Input Parameters.

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.

Login api not working

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
        })
    })

Calculating Unbooked P&L

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.

NodeJs Error getting live feed

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

issue-ss1

    });

})

Getting 400 Bad Request on login

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.

Market feeds api

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

Unable to connect to websocket getting error - expected server response: 401

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

Result of no records in holdings goes into error block

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

Margin calculator for basket orders

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...

Feature Request: Getting portfolio data in a JSON format for further operations on it

Currently the getHoldings() and getPositions() functions are fetching the data and printing it out on console, which makes them unusable for further purposes.

  1. Can these methods be changed to get this data back in a JSON format so it can be further processed.
  2. Can a token based login system be implemented, which gives back a token via the 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!

Invalid head parameters.

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.

Error: Cannot find module './dataType' (node_pandas module typo bug)

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?

Access to XMLHttpRequest from origin 'http://localhost:3000' has been blocked by CORS policy

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

Kindly update security patches

Here is the audit report

npm audit report

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

table is not installed

The npm package table is required by index.js but is not mentioned in package.json and hence is not installed.

Cannot read property 'Message' of null error from init

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

Screenshot from 2021-05-12 22-17-03

i dont know what parameters are invalid

Thanks for help in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.