in reply to bitcoin price from command line
Here's a basic example using Mojo::UserAgent:
use feature 'say'; use Mojo::UserAgent; my $ua = Mojo::UserAgent->new; my $coinbaseURL = 'https://api.coindesk.com/v1/bpi/currentprice/usd.js +on'; my $value = $ua->get( $coinbaseURL )->result->json->{bpi}{USD}{rate}; say "Bitcoin Price (USD): $value";
If I were doing such a thing I'd likely just use Mojolicious::Lite for the site/page, and create a little route based on the example above (throw in some error checking etc) to return this as json, and call that route on the page every few minutes via JavaScript, so that the Bitcoin price updated without having to refresh/reload the page, from expedience tends to be how users expect things to work these days. See also Mojolicious -> Tutorial and UserAgent.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: bitcoin price from command line
by hippo (Archbishop) on Jan 08, 2019 at 12:13 UTC | |
by marto (Cardinal) on Jan 08, 2019 at 12:20 UTC | |
|
Re^2: bitcoin price from command line
by *alexandre* (Scribe) on Jan 08, 2019 at 12:56 UTC | |
by marto (Cardinal) on Jan 08, 2019 at 13:07 UTC |