PHP code example of tarcisioruas / php-bitgrail-sdk

1. Go to this page and download the library: Download tarcisioruas/php-bitgrail-sdk 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/ */

    

tarcisioruas / php-bitgrail-sdk example snippets


...

/*
* You can set yours API KEY and API SECRET at Environment Variables 
* or put that in a main file, like index.php.
*/
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');

...


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');

$api = new \BitGrail\Markets();
$markets = $api->call();
var_dump($markets);



fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');

//listing balances
$api = new \BitGrail\Balances();
$balances = $api->call();
var_dump($balances);


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');

//getting ticker
$api = new \BitGrail\Ticker('BTC-XRB');
$ticker = $api->call();
var_dump($ticker);


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');

//listing order book
$api = new \BitGrail\OrderBook('BTC-XRB');
$book = $api->call();
var_dump($book);


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');

//listing trade history
$api = new \BitGrail\TradeHistory('BTC-XRB');
$tradeHistory = $api->call();
var_dump($tradeHistories);


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');

//listing the opened orders
$api = new \BitGrail\OpenedOrders();
$opened = $api->call();
var_dump($opened);


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');

//registering a buy order
$api = new \BitGrail\Buy();
$buyOrder = $api->call([
            'market' => 'BTC-XRB',
            'amount' => 1,
            'price' => 0.00177
        ]);
var_dump($buyOrder);


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');
//regitering a sell order
$api = new \BitGrail\Sell();
$sellOrder = $api->call([
            'market' => 'BTC-XRB',
            'amount' => 1,
            'price' => 0.00177
        ]);
var_dump($sellOrder);


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');
//canceling a order
$api = new \BitGrail\CancelOrder();
$response = $api->call([
            'id' => 1 //Order Id
        ]);
var_dump($response);


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');
//listing user latest trades
$api = new \BitGrail\LatestTrades();
$trades = $api->call();
var_dump($trades);


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');
//getting deposit address
$api = new \BitGrail\DepositAddress();
$address = $api->call(['coin' => 'XRB']);
var_dump($address);


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');
//getting a deposit address
$api = new \BitGrail\DepositHistory();
$depositHistory = $api->call(['coin' => 'XRB']);
var_dump($depositHistory);


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');
//withdraw
$api = new \BitGrail\Withdraw();
$withdraw = $api->call([
            'coin' => 'XRB',
            'amount' => 1, //amount of coins to send 
            'address' => 'theaddresstosendcoins'
        ]);
var_dump($withdraw);


fining auth parameters
putenv('BITGRAIL_API_KEY=YourApiKey');
putenv('BITGRAIL_API_SECRET=YourSecret');

//listing withdraw history
$api = new \BitGrail\WithdrawHistory();
$withdrawHistory = $api->call(['coin' => 'XBR']);
var_dump($withdrawHistory);

composer 

sudo apt-get install curl
curl -s http://getcomposer.org/installer | php
php composer.phar install

php composer.phar