Bitcoin Price Notifications via Pushover

I was looking for a clever way to stay informed about current Bitcoin prices. I have 1 BTC, so, you know, it's super important to keep on top of it. I started out by simply following @bitcoinprice on Twitter and, even though that worked fine, it wasn't geeky enough.

Enter my (mostly) idle Raspberry Pi, some Perl code, the Coinbase API, and Pushover.

On my Raspberry Pi, in my bin directory, I have this simple Perl program:

#!/usr/bin/perl

use warnings;
use strict;
use LWP::Simple;
use JSON;
use URI::Escape;

my $ua = LWP::UserAgent->new;
my $url = "https://coinbase.com/api/v1/prices/buy";
my $response = $ua->get($url);

if ($response->is_success()) {
    my $body =  $response->content;
    my $decoded = decode_json($body);
    my $amount = $decoded->{'amount'};
    my $current = $decoded->{'currency'};

    my $message = "Current Buy Price: $amount"; 

    $url = "https://api.pushover.net/1/messages.json";
    my $token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    my $user = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    my $content = $ua->post($url, {'message' => $message, 'token' => $token, 'user' => $user})->as_string();

    print $content;

}

Then in my crontab:

30 * * * * /home/thomas/bin/push_bitcoin.pl > /home/thomas/logs/push_bitcoin.log 2>&1`

It's a simple as that! The results are awesome: