bitcoin to currency converter and it s reverse in php

0 votes

I am using Bitcoin Currency Converter in PHP.So that I can convert Bitcoin to any currency (say USD) and Any Currency (say USD) to Bitcoins.

Is there any API to do it ?? Till now I am using this URL to convert any currency to Bitcoins

https://blockchain.info/tobtc?currency=USD&value=83.652

but how to do its reverse. Also, I don't know whether this result is correct or not.

Apr 5, 2022 in Blockchain by Rahul
• 9,680 points
1,733 views

1 answer to this question.

0 votes

Ok, you can get the value by doing this:

//set currency 
$currency = 'USD'; 
//get json response 
$return = file_get_contents('http://data.mtgox.com/api/1/BTC'.$currency.'/ticker_fast'); 
//decode it (into an array rather than object [using 'true' parameter]) 
$info = json_decode($return, true); 
//access the dollar value 
$value = $info['return']['last_local']['value'];

It's a public API so you don't need to authenticate, you just get the contents of the page which is in JSON format and decode it into an array and access the value element.

You now know that 1 BTC = 90.20505 dollars - so therefore 1 dollar is equal to 0.0110858 Bitcoins. (1 / 90.20505).

You can do this with any currency.

answered Apr 7, 2022 by Aditya
• 7,680 points

Related Questions In Blockchain

0 votes
1 answer

bitcoin to currency converter and it's reverse in php

Ok, you can get the value by ...READ MORE

answered Mar 31, 2022 in Blockchain by Rahul
• 9,680 points
784 views
0 votes
1 answer

How to use bitcoin price as place holder in php?

You can do it by providing an ...READ MORE

answered Aug 21, 2018 in Blockchain by digger
• 26,740 points
951 views
0 votes
1 answer

How to create Bitcoin Address in PHP?

You need to understand that Bitcoin address and ...READ MORE

answered Aug 28, 2018 in Blockchain by Perry
• 17,100 points
5,470 views
+1 vote
1 answer
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,451 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,937 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,462 views
0 votes
1 answer

PHP. Bitcoin to Ukrainian Hrivna price ticker

I would suggest, that instead of dividing ...READ MORE

answered Apr 7, 2022 in Blockchain by Aditya
• 7,680 points
623 views
0 votes
1 answer

BITCOIN TO USD API

You can use blockchain.info API: URL: https://blockchain.info/ticker Response: { "USD" : ...READ MORE

answered Apr 6, 2022 in Blockchain by Aditya
• 7,680 points
645 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP