Kiteconnectjs

eeesathiaeee

I have developed a standalone serverless android and local html app using html/js for spread trading strategies and will buy the api keys shortly. Will you be able to share any sample working html/js codes for testing purpose may be with limited access api key mainly for the initial login. I went through all the documentations but stuck with linking files. Any help is much appreciated. Also advise if it is really possible to config api for a standalone serverless desktop/mobile app only with internet access.

Stuck with the very first line below which is not working in both the mobile and desktop versions.
Var kiteconnect = require("kiteconnect").kiteconnect;
  • eeesathiaeee
    Also please note that kite publisher api is working fine in both the standalone serverless mobile and desktop versions with internet access.
  • Vivek
    Kiteconnectjs is a node client and can't be used in browser. Its possible to modify it and use it in webpage but you still need a backend server which will handle things like access token exchange.
  • eeesathiaeee
    eeesathiaeee edited March 2018
    Thanks, trying with the localhost and getting route not found errors while posting the below code, please advise. Note that jsonp datatype is used to prevent cross domain access issues. The url is also not working when directly accessed. And for content type, json was also tried but no luck.
    	parseurl = "https://api.kite.trade/session/token?api_key=" + api_key + "&request_token=" + request_token + "&checksum=" + checksum;
    $.ajax({
    url: parseurl,
    dataType: 'jsonp',
    type: 'POST',
    contentType: "application/x-www-form-urlencoded",
    crossDomain: true,
    async: true,
    beforeSend: function(xhr) {
    xhr.setRequestHeader("X-Kite-Version",3)
    }, success: function(data){
    alert(data);
    }
    });
  • Vivek
    @eeesathiaeee As said before you shouldn't be calling get access token call from frontend. Its should be implemented in backend and your frontend should talk to your backend to get data. Otherwise you will compromise your api secret and also access token to end user.
  • eeesathiaeee
    Tried the backend call with https redirect url as well. Not working. Please advise how to test if the parseurl is correct or not.
  • eeesathiaeee
    @vivek I understand we cannot access the url this way. But are those keys correct? If so I will try post method with other parameters in setheader. Please share an Ajax syntax for post method if possible. Thanks for your help.
  • eeesathiaeee
    @vivek Below is the latest code used which is going into the error flow. Please advise.

    $.ajax({
    url: 'https://api.kite.trade/session/token',
    dataType: 'json',
    type: 'POST',
    contentType: 'application/json',
    data: {api_key, request_token, checksum},
    beforeSend: function(xhr) {
    xhr.setRequestHeader('X-Kite-Version: 3')
    }, success: function(data){
    alert(data);
    }, error: function(){
    alert("Unsuccessful login!");
    }
    });
  • eeesathiaeee
    Please advise.
  • sujith
    Come on how can you expect people to spend time on your query if you give broken information?
    Mention the exact error message what you are getting for the above request.
  • eeesathiaeee
    I messaged Vivek.. let me message you too. Thanks.
  • eeesathiaeee
    Thanks @vivek @sujith . I am able to retrieve access token now. Understanding is that it will never be retrieved from client side js even with jsonp. So tried using server side php call from js and it worked fine.
  • eeesathiaeee
    @vivek @sujith It is understood that multiple users could be added to access the API key and secret if setup(please explain this process as well). If that is the case, will it be still 3 requests per second for API calls or is it per user/access token? Please advise.
  • sujith
    Kite Connect is by default a personal app only. It is can't be used for multiple users. You need to create multiple apps to use APIs for multiple clients.
    If you are developing a platform then you can write to talk(at)rainmatter.com to get multi-user access.
This discussion has been closed.