How to get quote for an instrument

pannet1
I am trying to get quote for an instrument, INFY for example. How can I get it through

AA) Kite Object

$infy = $Kite->instruments("'exchange'=>'NSE','tradingsymbol'=>'INFY'");
echo $infy->last_price;

OR BB) file_get_contents

$response = file_get_contents("https://api.kite.trade/instruments?api_key=mykey&exchange=NSE&tradingsymbol=INFY";

print_r($reponse);

Kindly advise.
Tagged:
  • sujith
    Hi @pannet1,
    All API calls are authenticated using access token, you can check out documentation here.
  • pannet1
    hi sujith,

    i already got the access token. can you correct the code above (any or both the codes).

    NB:
    i already got the list of Orders and Positions from the API through another part of my code. This is just FYI.
  • Vivek
    Vivek edited August 2017
    You can use quote method to fetch quotes. You can do something like
    $infy = $Kite->quote("'exchange'=>'NSE','tradingsymbol'=>'INFY'");
    Refer this - https://kite.trade/docs/phpkiteconnect/class-KiteConnect.html#_quote
  • pannet1
    @vivek,

    Thanks.

    I had a missing argument 2 error. However, your reply pointed me into the right direction. Here is the working code

    $infy = $Kite->quote("NSE","INFY");

    Thanks once again.
This discussion has been closed.