Crypto::API - Universal Plug & Play API
This module mainly used by Inheritance
package Exchange { use Moo; extends 'Crypto::API'; }
You can use this module as parent and the child class can simply define the api spec.
package foo { use Moo; extends 'Crypto::API'; sub _build_base_url { URI->new('https://api.kucoin.com'); } sub set_prices {{ request => { method => 'get', path => '/api/v1/market/stats', data => { pair => 'symbol', }, }, response => { key => 'data', row => { pair => 'symbol', last_price => 'last', }, }, }} }
The main purpose of this is to normalise the request and response for different exchanges that using this API as a standard.
So if you call price data from Binance and Kucoin or etc ...
There will be no different.
$binance->prices(pair => 'XRP-USDC') -> getting { pair => 'XRP-USDC', last_price => 1234 };
OR
$kucoin->prices(pair => 'XRP-USDC') -> getting { pair => 'XRP-USDC', last_price => 1234 };
To install Crypto::API, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Crypto::API
CPAN shell
perl -MCPAN -e shell install Crypto::API
For more information on module installation, please visit the detailed CPAN module installation guide.