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 it's reverse (convert from bitcoins to currency). Also, I don't know whether this result is correct or not.

Mar 29, 2022 in Blockchain by Soham
• 9,710 points
727 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.
Voila

answered Mar 31, 2022 by Rahul
• 9,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 Apr 7, 2022 in Blockchain by Aditya
• 7,680 points
1,657 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
869 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,407 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,385 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,900 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,423 views
0 votes
1 answer

How to set fee in raw bitcoin transaction using btcutil

To answer your question, the settxfee is ...READ MORE

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

how Localbitcoins and other bitcoin wallet able to send/receive without network fee

Organizations that offer online wallets aren't obligated ...READ MORE

answered Mar 31, 2022 in Blockchain by Rahul
• 9,680 points
537 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