++ed by:

1 non-PAUSE user(s).

John Beppu

NAME

WebService::MtGox - access to mtgox.com's bitcoin trading API

SYNOPSIS

Creating the client

  use WebService::MtGox;
  my $m = WebService::MtGox->new(
    user     => 'you',
    password => 'secret',
  );

Getting Trade Data

  my $ticker = $m->get_ticker;
  my $depth  = $m->get_depth;

Placing Buy and Sell Orders

  my $r1 = $m->buy(amount => 24, price => 7.77);
  my $r2 = $m->sell(amount => 10, price => 8.12);

Make it AnyEvent+Coro-friendly

  use WebService::MtGox;
  use LWP::Protocol::Coro::http;

Finally, use the command line client, mg

  mg help
  mg ticker

DESCRIPTION

WebService::MtGox gives you access to MtGox's bitcoin trading API. With this module, you can get current market data and initiate your buy and sell orders.

It's great for writing bitcoin trading bots.

API

Creation

WebService::MtGox->new(user => $user, password => $password)

This constructs a WebService::MtGox object. If user and password are not provided (or are invalid), you will only be able to get market information from the API. You will not be able to buy or sell bitcoins without a valid MtGox username and password.

Market Information

The following methods do not require authentication.

$m->get_ticker

Get the daily lows and highs along with the current price in USD for BTC.

$m->get_depth

Get a list of the current buy and sell orders.

$m->get_trades

Get a list of recent trades.

Buying and Selling

The following methods require authentication.

$m->get_balance

Get your balance

$m->buy(amount => $n, price => $p)

Create a buy order.

$m->sell(amount => $n, price => $p)

Create a sell order.

$m->list

List all of your open orders.

$m->cancel(oid => $oid, type => $t)

Cancel an order based on oid and type. Type may be 1 for buy or 2 for sell.

$m->send(bitcoin_address => $addr, amount => $n)

Use this method to withdraw money from mtgox.

NOTICE: As of 2011-05-30, this API function has not yet been implemented at mtgox.com.

SEE ALSO

API Documentation

https://mtgox.com/support/tradeAPI

Catalyst::Model::Bitcoin, Finance::Bitcoin, Finance::MtGox

(Had I known about Finance::MtGox, I wouldn't have made this module.)

Command Line Client

Buy and sell bitcoins on mtgox.com from the command line.

mg

AUTHOR

John BEPPU <beppu {at} cpan.org>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.




Hosting generously
sponsored by Bytemark