I want fetch specific holding


  • I have more 3 stock in my demat account . I want get data only BHEL-EQ holding data . Anyone tell me how to fetch only one data
    I use this code :
    <?php
    $urlholding ='https://apiconnect.angelbroking.com/rest/secure/angelbroking/portfolio/v1/getHolding?tradingSymbol=BHEL-EQ';
    $curltrade = curl_init();
    curl_setopt($curltrade, CURLOPT_URL, $urlholding);

    curl_setopt($curltrade, CURLOPT_HEADEROPT, CURLHEADER_UNIFIED);
    curl_setopt($curltrade, CURLOPT_HTTPHEADER, $tradeheaders);

    curl_setopt($curltrade, CURLOPT_RETURNTRANSFER, 1);

    $resulttrade = curl_exec($curltrade);
    $http_statustrade = curl_getinfo($curltrade, CURLINFO_HTTP_CODE);

    echo '<br/>Response Status trade : ' . $http_statustrade;
    //echo '<br/>Response String trade : ' . $resulttrade;

    //To Convert json response to array
    $resJsontrade = json_decode($resulttrade, true);

    //holding
    $ts = $resJsontrade['data']['0']['tradingsymbol'];
    $exg = $resJsontrade['data']['0']['exchange'];
    $quh = $resJsontrade['data']['0']['quantity'];
    $proh = $resJsontrade['data']['0']['product'];
    $avh = $resJsontrade['data']['0']['averageprice'];
    $ltp0 = $resJsontrade['data']['0']['ltp'];
    $sth = $resJsontrade['data']['0']['symboltoken'];
    $close0 = $resJsontrade['data']['0']['close'];
    $realisedquantity0 = $resJsontrade['data']['0']['realisedquantity'];
    $profitandloss0 = $resJsontrade['data']['0']['profitandloss'];
    echo " ts " . $ts . " quantity " . $quh;
    ?>


  • @aksharmty I am giving you a common algo. Get all stocks in a loop. Check the symbol in loop. When you get BHEL , then break the loop.

    Call server for LTP


  • @webseos i have 3 stock ( BHEL-EQ, SBIN-EQ,NHPC-EQ) in holding. now I want to fetch only BHEL-EQ stock quantity and average price from the exchange using api.


  • @aksharmty You did a lot ? Whats left to do? whats your point of problem is not clear


  • HI @aksharmty After getting the response from api you can perform operation on it to get the stock detail.