Skip to content

Instantly share code, notes, and snippets.

@Retord
Created May 5, 2016 19:40
Show Gist options
  • Save Retord/971d09e2d4f17d1a8dd2696280fde325 to your computer and use it in GitHub Desktop.
Save Retord/971d09e2d4f17d1a8dd2696280fde325 to your computer and use it in GitHub Desktop.
Simple DCR to USD
<?php
$dcrurl = "https://bittrex.com/api/v1.1/public/getmarketsummary?market=btc-dcr";
$usdurl = "https://bitpay.com/api/rates";
$dcrjson = file_get_contents($dcrurl);
$dcrdata = json_decode($dcrjson, TRUE);
$usdjson = file_get_contents($usdurl);
$usddata = json_decode($usdjson, TRUE);
$DCRrate = $dcrdata['result'][0]['Last'];
$USDrate = $usddata[1]["rate"];
$DCRtoUSD = round( $DCRrate * $USDrate , 8 );
?>
1 BTC is:
<ul>
<li>USD: <?=$USDrate ?> $ </li>
<li>Decred: <?=$DCRrate ?> DCR </li>
<li>1 DCR = <?=$DCRtoUSD ?> $ </li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment