<p>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. </p>

<p>Here's a simple example using bitfinex:</p>

<pre><code>&lt;html&gt;
&lt;div id="btc"&gt;&lt;/div&gt;
&lt;script&gt;
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];
  }
};
&lt;/script&gt;
&lt;/html&gt;
</code></pre>

CC BY-SA 4.0
2018-06-08T03:55:03.107Z
2018-06-08T03:55:03.107Z
m1xolyd1an
<p>how can i get and show below link data, can someone please help me </p>

<p><a href="https://runcoders.com/live-bitcoin/" rel="nofollow noreferrer">https://runcoders.com/live-bitcoin/</a></p>

<p>i am trying by this but failed to show like up link </p>

<pre><code>&lt;?php
//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"];
?&gt;
&lt;html&gt;
&lt;h1&gt;My Website&lt;/h1&gt;
&lt;p&gt;Bitcoin 24 HR stats&lt;/p&gt;
Open: $&lt;?php echo $open; ?&gt;&lt;br&gt;
High: $&lt;?php echo $high; ?&gt;&lt;br&gt;
Low: $&lt;?php echo $low; ?&gt;&lt;br&gt;
Close: $&lt;?php echo $close; ?&gt;&lt;br&gt;
&lt;/html&gt;
</code></pre>

<api><php>
how can i get data from GDAX Bitfinex using API and show like bottom
user3308270
# how can i get data from GDAX Bitfinex using API and show like bottom

(Asked by: username_0 on 2018-06-07)

how can i get and show below link data, can someone please help me 
https://runcoders.com/live-bitcoin/
i am trying by this but failed to show like up link 


My Website
Bitcoin 24 HR stats
Open: $
High: $
Low: $
Close: $

**Tags:** api, php


---

## 1 answers

### Answer by username_1 on 2018-06-08. Score: 0 | Accepted answer

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:


---

