PHP code example of bitbuy-at / kraken-api-client

1. Go to this page and download the library: Download bitbuy-at/kraken-api-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bitbuy-at / kraken-api-client example snippets


use bitbuyAT\Kraken\Facade\Kraken;

$balances = Kraken::getAccountBalance(); 
// Will return bitbuyAT\Kraken\Objects\BalanceCollection

foreach($balances as $balance) {
    $currency = $balance->currency();
    $amount = $balance->amount();
}

use bitbuyAT\Kraken\Contracts\Client;

class BalanceConstroller extends Controller {

    public function getBalance(Client $client)
    {
        $client->getAccountBalance();
        ...
    }
}

$orderVolume = new \bitbuyAT\Kraken\OrderVolume;
$pair = $client->getAssetPairs('EOSETH')->first();
$isValidSize = $orderVolume->checkMinimalSizeForPair($pair, 1.1);

$orderVolume = new \bitbuyAT\Kraken\OrderVolume;
$isValidSize = $orderVolume->checkMinimalSizeForPair('EOS', 1.1);

$orderVolume = new \bitbuyAT\Kraken\OrderVolume;

// Pair
$pair = $client->getAssetPairs('EOSETH')->first();
$minimalsize = $orderVolume->getMinimalSizeForPair($pair);

// Currency
$minimalsize = $orderVolume->getMinimalSize('EOS');

$client->request(string $method, array $parameters, bool $isPublic) : array;

// Public request
$trades = $client->request('Trades', ['pair' => 'BCHXBT']);

// Private request
$balance = $client->request('Balance', [], false);

$pairs = $client->getAssetPairs(string|array $pair, string $info='all') : bitbuyAT\Kraken\Objects\PairCollection;

foreach($pairs as $pair) {
    $pair->name();
}

$pairs = $client->getTicker(string|array $pair) : bitbuyAT\Kraken\Objects\TickerCollection;

foreach($pairs as $pair) {
    $pair->name();
    $pair->askPrice();
    $pair->askWholeLotVolume();
    $pair->askLotVolume();
    $pair->askLotVolume();
    ...
}

$balances = $client->getAccountBalance() : bitbuyAT\Kraken\Objects\BalanceCollection;

foreach($balances as $balance) {
    $currency = $balance->currency();
    $amount = $balance->amount();
}

$orders = $client->getOpenOrders(bool $trades = false) : bitbuyAT\Kraken\Objects\OrdersCollection;

$orders = $client->getClosedOrders(bool $trades = false, Carbon\Carbon $start = null, Carbon\Carbon $end = null) : bitbuyAT\Kraken\Objects\OrdersCollection;

use bitbuyAT\Kraken\Contracts\Order as OrderContract;

$order = new bitbuyAT\Kraken\Order('BCHUSD', OrderContract::TYPE_BUY, OrderContract::ORDER_TYPE_MARKET, 20);

$orderStatus = $client->addOrder($order) : bitbuyAT\Kraken\Objects\OrderStatus;

$txid = $orderStatus->getTransactionId();
$desciption = $orderStatus->getDescription() = bitbuyAT\Kraken\Objects\OrderStatusDescription;

$client->cancelOrder(string $transactionId): array;