NAME

Finance::Dogecoin::API - use the dogeapi.com API from Perl

SYNOPSIS

use Finance::Dogecoin::API;

# may throw errors
eval {
    my $dc      = Finance::Dogecoin::API->new( api_key => $SECRET_KEY );
    my $block   = $dc->get_current_block;
    my $price   = $dc->get_current_price;

    my $balance = $dc->get_balance;
    my $result  = $dc->withdraw(
        payment_address => $ADDY, amount => $AMOUNT
    );
};

# tip the author
$dc->withdraw(
    payment_address => 'DPxuFc7dhNrTvNMCE53ENGF5g7LSGrzyYs',
    amount          => 5,
);

DESCRIPTION

Finance::Dogecoin::API provides an OO interface to the Dogecoin API provided by http://dogeapi.com/. You need to sign up for an API key to use most of the methods in this class; do so at the site. When creating the object, you must provide the api_key as a constructor argument.

METHODS

This module provides several methods. See the documentation at https://www.dogeapi.com/api_documentation for current details. These methods may all throw an exception if a network error or protocol error occurs, so be ready to catch them:

get_current_price()

Returns the current price of Dogecoins in US dollars. This is a floating point number.

get_current_block()

Returns the current block of Doge mining.

get_difficulty()

Returns the current difficulty of Doge mining.

get_balance()

Returns the balance of your entire account across all wallets. This is a floating point number.

get_my_addresses()

Returns an array reference of all payment addresses associated with your account. This array may be empty.

withdraw( payment_address => $address, amount => $amount )

Withdraws $amount from your account and sends it to <$address>. The API and the Doge network each charge a modest transaction fee. The transaction will fail unless your account meets these criteria. In particular, you must transfer at least 5 Doge at a time.

If you do not provide both the payment_address and amount parameters, this method will throw an exception.

get_new_address( address_label => $label )

Creates and returns a new payment address for your account. You may provide an optional address_label parameter. The API will use this alphanumeric value as the label if possible.

get_address_received( payment_address => $address )

Returns the current amount of Dogecoins recieved at the given address or label. This method will throw an exception if you do not provide either the payment_address or address_label parameters. This method will return the number 0 if you provide an invalid address or label.

get_address_by_label( address_label => $label )

Returns the payment address for the given address label. This method will throw an exception if you do not provide the address_label parameter. This method will return the string No matching addresses if there are no matching addresses.

CAVEATS

The Dogecoin API is under development, so these methods might change and new methods might appear.

COPYRIGHT & LICENSE

Copyright 2014 chromatic, some rights reserved.

This program is free software. You can redistribute it and/or modify it under the same terms as Perl 5.18.