How to login to kite connect using python client?

tyamini
Hello,
I am using kiteconnect python APIs for the first time. Can you provide me the sample code for login to kite and just check the open orders?
  • tyamini
    I have tried to get the access_token by redirecting to https://127.0.0.1 and then tried to login .
    Below are the errors I am getting


    Warning (from warnings module):
    File "C:\Users\tannirus\AppData\Local\Programs\Python\Python35\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 821
    InsecureRequestWarning)
    InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
    RY0275 has logged in

    Warning (from warnings module):
    File "C:\Users\tannirus\AppData\Local\Programs\Python\Python35\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 821
    InsecureRequestWarning)
    InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
    Traceback (most recent call last):
    File "C:\personal\kiteAPI\kitelogin.py", line 21, in
    print(kite.positions())
    File "C:\Users\tannirus\AppData\Local\Programs\Python\Python35\lib\site-packages\kiteconnect\__init__.py", line 341, in positions
    return self._get("portfolio.positions")
    File "C:\Users\tannirus\AppData\Local\Programs\Python\Python35\lib\site-packages\kiteconnect\__init__.py", line 439, in _get
    return self._request(route, "GET", params)
    File "C:\Users\tannirus\AppData\Local\Programs\Python\Python35\lib\site-packages\kiteconnect\__init__.py", line 525, in _request
    raise(exp(data["message"], code=r.status_code))
    kiteconnect.exceptions.GeneralException: An internal server error occurred
  • Kailash
    The example here prints orders -- https://github.com/rainmattertech/pykiteconnect

    Please share the code snippet you're testing with.
  • tyamini
    Hi Kailash...
    Now I am able to login kite by using sample code given at https://github.com/rainmattertech/pykiteconnect.

    kite = KiteConnect(api_key="xxxxxx")
    user = kite.request_access_token(request_token="zzzzzz",
    secret="yyyyyyyy")
    I have also tried placing an order same as the sample code given in the link..

    # Place an order.
    order_id = kite.order_place(
    tradingsymbol="INFY",
    exchange="NSE",
    quantity=1,
    transaction_type="BUY",
    order_type="MARKET"
    )

    Now i want try out using other APIs for cancelling an open order, open positions, m2m on open positions..etc.. May I know the KiteConnect APIs for the same?

    And also I have seen webpage giving the APIs https://kite.trade/docs/connect/v1/. Are these are the APIs for Python? I have seen APIs like GET, PUT, POST..Which I never came accross? May I know what are these

    Example:
    Orders

    The order APIs let you place orders of different varities on the user’s account, modify and cancel pending orders, retrieve the daily order log etc. Some call URIs are formed with the :variety of the order, and many request parameters take constant, preset values. You can get possible values for the parameters here.

    type endpoint
    GET /orders Retrieve the list of all orders (open and executed) for the day
    GET /orders/:order_id Retrieve an individual order’s details
    GET /orders/:order_id/trades Retrieve trades generated by an order
    POST /orders/:variety Place an order of a particular variety
    PUT /orders/:variety/:order_id Modify an open or pending order
    DELETE /orders/:variety/:order_id Cancel an open or pending order


    Are these APIs for placing orders from python client? If yes How to use this APIs?

    Thanks


  • Kailash
    https://kite.trade/docs/connect/v1/ describes the actual API.

    Here's the Python Client documentation -- https://kite.trade/docs/pykiteconnect/
Sign In or Register to comment.