Home > Software engineering >  How i convert USD to ETH using json?
How i convert USD to ETH using json?

Time:02-15

I used this API but it displays BTC. I want to convert USD to ETH

<?php
$url = "https://blockchain.info/tobtc?currency=USD&value=2000";
$stats = json_decode(file_get_contents($url), true);
echo "$stats BTC";
?> 

CodePudding user response:

with this api you cant convert to ETH because this api is only meant to convert a currency to Bitcoin

if you look at the documantation of the api you call
https://www.blockchain.com/api/exchange_rates_api

it says all the way at the bottom that it only converts to BTC so not to ETH

  • Related