i need to view live nse , mcx and option data

geetanjali
$url = "https://api.kite.trade/instruments/NSE";

$params = array(
"exchange" => "NSE",
"segment" => "NSE",
"instrument_type" => "EQ",
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url . "?" . http_build_query($params));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
$records = explode("\n", $response);

// dd($records);

$header = [];
$resData = [];
// $records = explode('\n', $records[0])[0];
// $records = explode('\n', $records);
// dd($records);
foreach($records as $d) {
if(empty($header)) {
$header = explode(',', $d);
}
else {

$resData[] = array_combine($header, explode(',', $d));

dd($resData);
}
}
dd($resData, $header);
Sign In or Register to comment.