Getting TokenException on market quote APIs

KiteConnect kiteSdk = new KiteConnect("*****");

//String token = Authenticator.login();
//kiteSdk.generateSession(token, "***_secretkey");

String token = "***_previously_obtained_access_token";

List instruments = kiteSdk.getInstruments("NSE"); //Working fine

String[] instruments = {"256265"};
//String[] instruments = {"256265","NSE:INFY",};
Map resultMap = kiteSdk.getLTP(instruments); //Failing with following exception

at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.dealWithException(
at com.zerodhatech.kiteconnect.kitehttp.KiteResponseHandler.handle(
at com.zerodhatech.kiteconnect.kitehttp.KiteRequestHandler.getRequest(
at com.zerodhatech.kiteconnect.KiteConnect.getQuote(
at com.kite.KiteBot.main(

I haven't subscribed to history API and I am trying to run this after market hours, getting exception on getLTP() API.
Can you pls help me understand what am I missing here? or I cannot access market quote APIs after market hours, if I haven't subscribed to history apis?
I have 2FA and I am doing a manual login.
  • sujith
    The getInstruments API isn't authenticated. The getLTP API call is authenticated by the Kite Trade. Once you obtain an access token store it and reuse it in subsequent runs for the day. Don't call generate session again.
  • pratikmachve
    Thanks Sujith, my bad, I was missing following :(

This discussion has been closed.