keyError - 'data' (It was working since over a year till May 18th 2024.)

ashbash edited May 21 in Python client
It has been working seamlessly for last 1 year but things changed after May 20st.

All I am doing is seeking current positions from kite object, using HTTP API as given below.

Traceback (most recent call last):
File "", line 92, in
curpos = kite.positions()
File "/home/ag/xts-pythonclient-api-sdk-main/", line 129, in positions
positions = self.session.get(f"{self.root_url}/portfolio/positions", headers=self.headers).json()["data"]
KeyError: 'data'
  • sujith
    Can you private message the api_key? We will check and get back to you.
  • sujith
    You may also include the complete stack trace in the private message with request and response json from the Kite Connect.
  • ashbash
    Hi Sujith,

    Here is the debugging stack trace. I hv executed each line one by one and eventually, after obtaining kite object successfully, when I try to run any command on kite object such kite.ltp, kite.quote, kite.historical etc, I get HTTP 400

    Here is the stacktrace:

    > /home/ag/xts-pythonclient-api-sdk-main/
    -> kite = KiteApp(enctoken=enctoken)
    (Pdb) n
    > /home/ag/xts-pythonclient-api-sdk-main/
    -> if kite.root_url is None:
    (Pdb) kite

    (Pdb) kite.root_url
    (Pdb) n
    > /home/ag/xts-pythonclient-api-sdk-main/
    -> curpos = kite.positions()
    (Pdb) s
    > /home/ag/xts-pythonclient-api-sdk-main/
    -> def positions(self):
    (Pdb) n
    > /home/ag/xts-pythonclient-api-sdk-main/
    -> positions = self.session.get(f"{self.root_url}/portfolio/positions", headers=self.headers).json()["data"]
    (Pdb) self.session.get(f"{self.root_url}/portfolio/positions", headers=self.headers)

  • sujith
    This was always the intended behavior. Emulating curl requests of the browser wasn't a service we ever offered.
Sign In or Register to comment.