NAME
WebService::CoinSpot - Perl API for CoinSpot API
VERSION
version 0.001
SYNOPSIS
use WebService::CoinSpot;
my $coinspot = WebService::CoinSpot->new(
auth_key => 'xxxxxxxx',
auth_secret => 'xxxxxxxx',
base_url => 'https://www.coinspot.com.au', # optional, default shown
);
DESCRIPTION
A perl API for convenience in using CoinSpot's vaguely RESTful API
ALPHA STATUS WARNING
This API software is an Alpha release, which I am published for people to comment on and provide pull requests.
Test it carefully before relying upon it with your valuable currency.
METHODS
CoinSpot Object
new
my $coinspot = WebService::CoinSpot->new(
auth_key => 'xxxxxxxx',
auth_secret => 'xxxxxxxx',
base_url => 'https://www.coinspot.com.au', # optional, default shown
);
Creates new object. No ping type operation is performed, so you won't know if there's is a problem with your parameters until you try to do something.
Parameters
- auth_key
-
Optional. But without it you will only get some "Market Status" features.
The API key that CoinSpot will provide you. Look on the account settings web page.
- auth_secret
-
Optional. But without it you will only get some "Market Status" features.
The Secret key that CoinSpot will provide you. Look on the account settings web page.
WARNING: do not commit this secret to public source control repositories.
- base_url
-
Optional.
Specify a different base URL for the API. This will likely never be needed.
auth_key
Read only accessory for auth_key
auth_secret
Read only accessory for auth_secret
Market Status
Get information about whats happening in the market. None of these spend your money or sell your assets.
latest
my $response = $coinspot->latest();
Get Latest Prices (doesn't require auth_key or auth_secret)
Parameters
None.
Returns
Hash or hash reference with all the latest prices.
- prices
-
One property for each coin with the latest prices for that coin
orders
my $response = $coinspot->orders( cointype => 'BTC' );
List Open Orders
Parameters
- cointype
-
i.e. BTC, LTC, DOGE, ETH, ETC.
Returns
Hash or hash reference with all the latest open orders.
- buyorders
-
Array containing all the open buy orders
- sellorders
-
Array containing all the open sell orders
orders_history
my $response = $coinspot->orders_history( cointype => 'BTC' );
List Order History
Parameters
- cointype
-
i.e. BTC, LTC, DOGE, ETH, ETC.
Returns
Hash or hash reference with last 1,000 completed orders
- orders
-
Array of the last 1,000 completed orders
My Account
Examine what's in your account. None of these functions spend your money or sell your assets.
balances
my $response = $coinspot->balances();
List My Balances
Parameters
None.
Returns
Hash or hash reference with balances for your account
- balances
-
One property for each coin with your balance for that coin
myorders
my $response = $coinspot->myorders();
List My Orders
Parameters
None.
Returns
Hash or hash reference with balances for your account
- buyorders
-
Array containing all your buy orders
- sellorders
-
Array containing all your sell orders
Buying
Exchange AUD for Crypto Currency. These functions will spend your money.
quotebuy
my $response = $coinspot->quotebuy(
cointype => 'BTC',
amount => 9_999_999,
);
Quick Buy Quote
Note: This is just a quote, not a commitment to buy.
Parameters
- cointype
-
i.e. BTC, LTC, DOGE, ETH, ETC.
- amount
-
The amount of coins to buy
Returns
Hash or hash reference with estimations
- quote
-
The rate per coin
- timeframe
-
Estimated hours to wait for trade to complete (0 = immediate trade)
buy
my $response = $coinspot->buy(
cointype => 'BTC',
amount => 9_999_999,
rate => 0.50,
);
Place Buy Order
DANGER DANGER DANGER
This function will try to spend your hard earned money on Crypto Currency.
DANGER DANGER DANGER
You can cancel orders via "cancelbuy"
Parameters
- cointype
-
i.e. BTC, LTC, DOGE, ETH, ETC.
- amount
-
The amount of coins to buy
- rate
-
The rate in AUD you are willing to pay, max precision 6 decimal places
Returns
Ok or error only.
cancelbuy
my $response = $coinspot->cancelbuy( id => 1234 );
Cancel Buy Order
WARNING WARNING WARNING
This function will cancel buy orders, if unfulfilled.
WARNING WARNING WARNING
Parameters
- id
-
The id of the order to cancel
Returns
Ok or error only.
Sending / Depositing
Moves / sends coins from wallet to wallet. These functions will cause assets to leave your CoinSpot account.
sendcoin
my $response = $coinspot->sendcoin(
cointype => 'BTC',
address => 'abc1234',
amount => 9_999_999,
);
Send Coins
DANGER DANGER DANGER
This function will move assets from your CoinSpot account to other wallets.
DANGER DANGER DANGER
Parameters
- cointype
-
i.e. BTC, LTC, DOGE, ETH, ETC.
- address
-
The address to send coins to
- amount
-
The amount of coins to buy
Returns
Ok or error only.
depositcoin
my $response = $coinspot->depositcoin(
cointype => 'BTC',
);
Deposit Coins
Parameters
- cointype
-
i.e. BTC, LTC, DOGE, ETH, ETC.
Returns
Hash or hash reference with estimations
- address
-
Your deposit address for the coin
Selling
Exchange Crypto Currency for AUD. These functions will sell your assets
quotesell
my $response = $coinspot->quotesell(
cointype => 'BTC',
amount => 9_999_999,
);
Quick Sell Quote
Note: This is just a quote, not a commitment to sell.
Parameters
- cointype
-
i.e. BTC, LTC, DOGE, ETH, ETC.
- amount
-
The amount of coins to buy
Returns
Hash or hash reference with estimations
- quote
-
The rate per coin
- timeframe
-
Estimated hours to wait for trade to complete (0 = immediate trade)
sell
my $response = $coinspot->sell(
cointype => 'BTC',
amount => 9_999_999,
rate => 0.50,
);
Place Sell Order
DANGER DANGER DANGER
This function will try to sell your Crypto Currency in exchange for Australian Dollars
DANGER DANGER DANGER
You can cancel orders via "cancelsell"
Parameters
- cointype
-
i.e. BTC, LTC, DOGE, ETH, ETC.
- amount
-
The amount of coins you want to sell, max precision 8 decimal places
- rate
-
The rate in AUD you are willing to pay, max precision 6 decimal places
Returns
Ok or error only.
cancelsell
my $response = $coinspot->cancelsell( id => 1234 );
Cancel Buy Order
WARNING WARNING WARNING
This function will cancel sell orders, if unfulfilled.
WARNING WARNING WARNING
Parameters
- id
-
The id of the order to cancel
Returns
Ok or error only.
SEE ALSO
AUTHOR
Dean Hamstead <dean@bytefoundry.com.au>
COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Dean Hamstad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.