Title: Looking to display Bitcoin price plus extra % that i will set Post by: pamamolf on November 27, 2015, 11:09:06 PM Hi
I am looking for someone that can write a few lines of code (maybe use an API) so i can display the current bitcoin price plus an extra % that i will be able to set on a site. Maybe use a div so it will be easy to use the code in any place on my page. Thank you Title: Re: Looking to display Bitcoin price plus extra % that i will set Post by: coinableS on November 28, 2015, 03:34:25 AM Here's a simple one I created in PHPfiddle: http://phpfiddle.org/lite/code/9mbw-iu5v
http://btcthreads.com/how-to-get-the-current-bitcoin-price/ Code: $url = "https://coinbase.com/api/v1/prices/spot_rate"; Title: Re: Looking to display Bitcoin price plus extra % that i will set Post by: batesresearch on November 28, 2015, 12:04:10 PM Here's a simple one I created in PHPfiddle: http://phpfiddle.org/lite/code/9mbw-iu5v http://btcthreads.com/how-to-get-the-current-bitcoin-price/ Code: $url = "https://coinbase.com/api/v1/prices/spot_rate"; Nice little script, good work. Title: Re: Looking to display Bitcoin price plus extra % that i will set Post by: pamamolf on November 28, 2015, 11:01:54 PM Great THANKS :)
But can you add a few lines of ajax so it can auto refresh? Title: Re: Looking to display Bitcoin price plus extra % that i will set Post by: batesresearch on November 28, 2015, 11:31:25 PM You can add
header("refresh: 240;"); on the next line after the <?php ^ That's a 240 refresh second, just watch the amount of times your pulling from the API don't exceed the limit Title: Re: Looking to display Bitcoin price plus extra % that i will set Post by: jackg on November 28, 2015, 11:34:32 PM Here's a simple one I created in PHPfiddle: http://phpfiddle.org/lite/code/9mbw-iu5v http://btcthreads.com/how-to-get-the-current-bitcoin-price/ Code: $url = "https://coinbase.com/api/v1/prices/spot_rate"; .php code file Code: $k = 0 pythonfile.py Code:
SORRY! for using a previous person's content, i think this should work! If the content owner is unhappy with this, I will remove it (please pm if unhappy)! I would suggest that you use the preev.com api (it refreshes faster!) █████████████████████████████████████████████████████████████████████████████████ or this! .php code file Code: $k = 0 Title: Re: Looking to display Bitcoin price plus extra % that i will set Post by: pamamolf on November 28, 2015, 11:49:02 PM preev.com is cool but no idea how to use the api of them :(
Title: Re: Looking to display Bitcoin price plus extra % that i will set Post by: coinableS on November 29, 2015, 03:37:46 AM Great THANKS :) But can you add a few lines of ajax so it can auto refresh? Not a good idea, you'll get banned for hitting the API too many times, but here you go. HTML: index.html Code: <script src="ajax.js"></script> AJAX: ajax.js Code:
PHP price.php Code: $url = "https://coinbase.com/api/v1/prices/spot_rate"; Title: Re: Looking to display Bitcoin price plus extra % that i will set Post by: pamamolf on November 29, 2015, 09:22:05 PM Great thanks !!!
But: Quote Not a good idea, you'll get banned for hitting the API too many times, but here you go. Is there any other way to make it work like preev (auto refresh) ? Title: Re: Looking to display Bitcoin price plus extra % that i will set Post by: coinableS on November 30, 2015, 12:09:55 AM Great thanks !!! But: Quote Not a good idea, you'll get banned for hitting the API too many times, but here you go. Is there any other way to make it work like preev (auto refresh) ? Yes, the way I do it is to set up a database to store the price/market value. Then set a cron job to run every N minutes to update the database with the updated rate. This way you could have a million visitors and still never exceed the API limits, because you are just querying your own DB instead of hitting them with an API call for every visitor. |