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

ashbash
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 "c1-ash.py", line 92, in
curpos = kite.positions()
File "/home/ag/xts-pythonclient-api-sdk-main/kite_trade.py", 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/c1-ash.py(85)()
    -> kite = KiteApp(enctoken=enctoken)
    (Pdb) n
    > /home/ag/xts-pythonclient-api-sdk-main/c1-ash.py(88)()
    -> if kite.root_url is None:
    (Pdb) kite

    (Pdb) kite.root_url
    'https://api.kite.trade'
    (Pdb) n
    > /home/ag/xts-pythonclient-api-sdk-main/c1-ash.py(92)()
    -> curpos = kite.positions()
    (Pdb) s
    --Call--
    > /home/ag/xts-pythonclient-api-sdk-main/kite_trade.py(128)positions()
    -> def positions(self):
    (Pdb) n
    > /home/ag/xts-pythonclient-api-sdk-main/kite_trade.py(129)positions()
    -> 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.