0

I am trying to use Blockchain.info Ticker API (https://blockchain.info/ticker) to get current BTC price in USD.

The interesting thing is that script not every time returns the same value. When you visit this page directly, none of the values never changes (well just every 15mins) https://blockchain.info/ticker, but on the script it changes on every nth refresh of the page.

Something similar happens if you go to blockchain.info/ticker? with at least a question mark added. Just refresh it a lot and you will see.

Why this is happening and how to get a stable price every 15mins as their API should provide it?

The script I use:

$api = "https://blockchain.info/ticker";
$json = file_get_contents($api);
$data = json_decode($json, TRUE);
$rate = $data["USD"]["sell"];
echo $rate;
1

There's nothing wrong with your PHP syntax or blockchain.info. The Bitcoin value is always changing. It is traded 365 days a year, 24 hours a day on a multiple exchanges around the globe.

  • I understand that mate. It just seems strange that it changes to the same value over and over again. For example if it's 1200$ in that ~15minutes period it sometimes changes to something value-10, like in this case to 1190$ while refreshing. – Simon Mar 11 '17 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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