From where can I import live cryptocurrency market values into my webpage?

2

2

I am planning to build a webpage where a user can enter his/her stock of various cryptocurrencies, and the webpage should display the current market value (in USD) for each of the cryptocurrency he/she has chosen.

I was wondering from where (which website/database) I can import the live market value for cryptocurrencies, so I can use the values in my website script?

Thank you very much in advance.

spartan81

Posted 2016-11-11T11:50:52.133

Reputation: 35

Answers

0

You can import straight from the exchanges market API.

Php example

$url = "https://api.bitfinex.com/v1/ticker/btcusd";
$json = json_decode(file_get_contents($url), true);
$price = $json["last_price"];
echo $price;

Javascript xml

var xbtc = new XMLHttpRequest();
        xbtc.open('GET',         'https://api.bitcoinaverage.com/ticker/global/USD/', true);
        xbtc.onreadystatechange = function(){
        if(xbtc.readyState == 4){
            var ticker = JSON.parse(xbtc.responseText);
            var price = ticker.last;
        document.getElementById('MyDiv').innerHTML = "$" + price;
        }
        };
        xbtc.send();

http://btcthreads.com/display-the-exchange-rate-on-your-website/

m1xolyd1an

Posted 2016-11-11T11:50:52.133

Reputation: 3 356

0

Take a look here: https://blockchain.info/api

https://blockchain.info/ticker gives you a json-object with recent data.

Daniel

Posted 2016-11-11T11:50:52.133

Reputation: 1