Rest API with access keys in body ?

moksh
Hi,

I built one strategy in tradingview pine scrip and wanted to generate buy and sell signal from tradingview platform to zerodha account using REST API.
It looks all good but I just wanted to confirm about access token, how do we pass access token in REST API? Is it in header or in body ?
  • sujith
    sujith edited January 2021
    You can check out the documentation to know more.
  • moksh
    moksh edited January 2021
    @sujith There's not specific information I could find on this APIs. In example they've just mentioned -h and -d, and there's no specification on how this should be.
  • sujith
    sujith edited January 2021
    -h means header and -d means body param in curl.
  • moksh
    moksh edited January 2021
    @sujith Thanks for your response, I have built one strategy on tradingview platform, and they're providing webhooks to make trade according to signal generated from strategy, but the problem is its only possible to provide data in body, and not in header, is there anyway we can achieve this ?
  • sujith
    You can post it to your endpoint and then make an API call from there.
  • moksh
    moksh edited January 2021
    @sujith You mean to say an API bridge, between zerodha and tradingview ?
  • moksh
    moksh edited January 2021
    @sujith also, wanted to confirm about derivatives market, can we trade in derivatives market with API ? because there's no specification about derivatives trading in REST API document.
  • rakeshr
    @moksh
    wanted to confirm about derivatives market, can we trade in derivatives market with API ?
    Yes, if you have respective derivates exchange enabled in your Zerodha account. You can know more about the enabled exchange here.
  • moksh
    @rakeshr Yes, its already enabled in my account, but when I was trying with free publisher app (with just html button) it was not working with derivatives.
  • sujith
    Can you give us the error? Even on Kite Publisher, you should be able to place orders if your account has derivatives enabled.
  • moksh
    I get this error whenever I put derivative symbol in button control.
    For equity, it works fine.
    {"status":"error","message":"No valid orders found in payload.","data":null,"error_type":"InputException"}
  • rakeshr
    Can you paste here the complete param you are sending? You would be sending the wrong trading symbol/any other order field.
  • moksh
    moksh edited January 2021
    I wanted to try with Nifty Jan Future, "NIFTY21JANFUT" this is the symbol I used...
    < button data-kite="API KEY"
    data-exchange="NSE"
    data-tradingsymbol="NIFTY21JANFUT"
    data-transaction_type="BUY"
    data-quantity="1"
    data-order_type="LIMIT"
    >Buy NIFTY
  • sujith
    The exchange value is NFO for NSE F&O instruments and quantity has to be in the multiple of 75.
  • sujith
    You need to send the price if you are placing a LIMIT order.
  • moksh
    moksh edited January 2021
    @sujith Thanks a lot, after changin exchange value it did work
  • moksh
    Just one more questio, For REST API, Following header is required as per document:
    -H "Authorization: token api_key:access_token"
    1. So, Authorization and api_key are these 2 different header or just one?
    2. Also, how do we get this tokens ?
  • sujith
    The correct syntax is -H "Authorization: token <api_key>:<access_token>"
  • sujith
    You can get api_key from the developers console after creating a Kite Connect app and you can get an access token after login flow. You can know more here.
  • moksh
    moksh edited January 2021
    @sujith Thanks a lot, got my query resolved!
This discussion has been closed.