WebService-Cryptsy
view release on metacpan or search on metacpan
# NAME
WebService::Cryptsy - implementation of www.cryptsy.com API
# SYNOPSIS
use WebService::Cryptsy;
use Data::Dumper;
my $cryp = WebService::Cryptsy->new(
public_key => 'YOUR PUBLICE KEY',
private_key => 'YOUR PRIVATE KEY',
);
print Dumper( $cryp->getinfo || $cryp->error ) . "\n";
print Dumper( $cryp->marketdatav2 || $cryp->error ) . "\n";
my ( $currency_id, $currency_code ) = ( 3, 'BTC' );
my $generated_address
= $cryp->generatenewaddress( $currency_id, $currency_code )
or die "Error: " . $cryp->error;
$cryp = WebService::Cryptsy->new; # no need for keys for some methods
my $data = $cryp->marketdatav2
or die "Error: $cryp"; # error checking and using interpolation
# to get the error message
printf "%s: %f\n", @{ $data->{markets}{$_} }{qw/label lasttradeprice/}
for sort keys %{ $data->{markets} };
# MAINTENANCE NOTE
**NOTE: this module has not been keeping up with Cryptsy's API updates
since Feb 4, 2014. Reason being is that I don't personally use this
module and the person I wrote it for might not be using it any more
either. But if you do use this module and need it updated, just
submit a bug report (patches are also welcome!).**
# DESCRIPTION
This module implements the [www.cryptsy.com API](https://www.cryptsy.com/pages/api) whose description is available here:
[https://www.cryptsy.com/pages/api](https://www.cryptsy.com/pages/api)
# INSTALLATION NOTES
Depending on your configuration, you might need to install
cpan LWP::Protocol::https Net::SSLeay
Or some such, to make [LWP::UserAgent](https://metacpan.org/pod/LWP::UserAgent) work over HTTPS, as that's what
Cryptsy's API requires.
# GETTING API KEY
To use this module, you'll need to obtain the API key from
[www.cryptsy.com](https://www.cryptsy.com/). Once logged in,
go to [account settings page](https://www.cryptsy.com/users/settings)
and scroll all the way to the bottom. Click the _Generate New Key_ button
to generate new key.
**IMPORTANT!!! Ensure to toggle the "API Disabled"
button into the "on" position, otherwise your API will be off and this
module will give a confusing error message.**
# CONSTRUCTOR
## `new`
my $cryp = WebService::Cryptsy->new(
public_key => 'YOUR PUBLIC KEY',
private_key => 'YOUR PRIVATE KEY',
timeout => 30,
);
# or if you're only going to use the public methods:
my $cryp = WebService::Cryptsy->new;
Creates and returns a new `WebService::Cryptsy` object. **Takes**
three optional arguments as key/value pairs. The
`public_key` and `private_key` are optional only for the
_Public Methods_ of the API. They both are required for calling the
_Authenticated Methods_. To obtain your keys, see the ["GETTING API KEY"](#getting-api-key)
section above.
### `public_key`
my $cryp = WebService::Cryptsy->new(
public_key => '479c5eee116f8f5972bdaf12dd0a3f82562c8a7c',
private_key => 'b408e899526142eee13304669a657c8782435ccda2f65dbea05270fe8dfa5d3d2ef7eb4812ce1c35',
);
This is the key from the _Public Key_ box on
[Cryptsy's settings page](https://www.cryptsy.com/users/settings).
### `private_key`
my $cryp = WebService::Cryptsy->new(
public_key => '479c5eee116f8f5972bdaf12dd0a3f82562c8a7c',
private_key => 'b408e899526142eee13304669a657c8782435ccda2f65dbea05270fe8dfa5d3d2ef7eb4812ce1c35',
);
This is the key from the _Private Key_ box on
[Cryptsy's settings page](https://www.cryptsy.com/users/settings).
### `timeout`
my $cryp = WebService::Cryptsy->new(
timeout => 30,
);
**Optional**. Specifies the timeout, in seconds, of the API requests.
**Default:** `60`
# MODULE METHODS / OVERLOADS
## `error`
# these two are equivalent
my $data = $cryp->marketdata
or die "Error: $cryp";
my $data = $cryp->marketdata
or die "Error: " . $cryp->error;
The API methods will return `undef` or an empty list,
depending on the context, and the human-readable error will be available
using the `->error` method. This method is overloaded for object
interpolation, thus you can simply interpolate the object in a string
to get the error message.
## `timeout`
printf "Current API request timeout is %d\n", $cryp->timeout;
$cryp->timeout( 30 );
Gets/sets the `timeout` constructor's argument. **Takes** one optional
argument that specifies the new timeout in seconds. **Returns** the
current timeout in seconds.
# GENERAL CONVENTION FOR API METHODS
All methods are named exactly the same as in
[Cryptsy's API](https://www.cryptsy.com/pages/api). If the API method
takes any arguments, you'd supply them to the method, in the same order
(e.g. `$cryp->mytrades( $market_id, $limit );`)
# PUBLIC API METHODS
These methods do not require API keys.
## `marketdata`
my $data = $cryp->marketdata
or die "Error: $cryp";
**NOTE: this API call doesn't seem to be listed on Cryptsy's site
any more. You're likely supposed to use marketdatav2 instead.**
( run in 2.345 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )