how can i get and show below link data, can someone please help me


i am trying by this but failed to show like up link

//define API endpoint
$url = "https://api.gdax.com/products/BTC-USD/stats";

//fetch the url and convert the JSON into an associative array
$fgc = json_decode(file_get_contents($url), true);

//assign values to variables
$open = $fgc["open"];
$high = $fgc["high"];
$low = $fgc["low"];
$close = $fgc["close"];
<h1>My Website</h1>
<p>Bitcoin 24 HR stats</p>
Open: $<?php echo $open; ?><br>
High: $<?php echo $high; ?><br>
Low: $<?php echo $low; ?><br>
Close: $<?php echo $close; ?><br>

1 Answer 1


They are just using websocket to connect to the exchange and then outputting the lives trades to the page by appending it to an element.

Here's a simple example using bitfinex:

<div id="btc"></div>
var ws = new WebSocket("wss://api2.bitfinex.com:3000/ws");
ws.onopen = function(){
  ws.send(JSON.stringify({"event":"subscribe", "channel":"ticker", "pair":"BTCUSD"}))
ws.onmessage = function(msg){
  var response = JSON.parse(msg.data);
  var hb = response[1];
  if(hb != "hb"){
    document.getElementById("btc").innerHTML = "$" + response[7];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.