tarcisioruas / php-bitgrail-sdk
PHP BitGrail API is a PHP library for the BitGrail API designed to be easy to use.
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: @stable
This package is auto-updated.
Last update: 2024-09-11 14:11:47 UTC
README
This project is designed to help you make your own projects that interact with the Bitgrail API. You can register buy, sell or cancel orders, request deposit address, withdraws and others features. This project seeks to have complete API coverage.
Installation
composer require "tarcisioruas/php-bitgrail-sdk"
Click for help with installation
Install Composer
If the above step didn't work, install composer and try again.
Debian / Ubuntu
sudo apt-get install curl
curl -s http://getcomposer.org/installer | php
php composer.phar install
Composer not found? Use this command instead:
php composer.phar require "tarcisioruas/php-bitgrail-sdk"
Windows:
How To Use
Setting Security Params
To use private API you have to create keys pair to authenticate user at BitGrail.
Code Examples
Security
Setting security params.
... /* * 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'); ...
Markets
Returns array with all tickers of all markets on BitGrail.
<?php require 'vendor/autoload.php'; //Defining auth parameters putenv('BITGRAIL_API_KEY=YourApiKey'); putenv('BITGRAIL_API_SECRET=YourSecret'); $api = new \BitGrail\Markets(); $markets = $api->call(); var_dump($markets);
Balances
Gets balances of all coins present on BitGrail you don't need parameters, except the authentication ones.
<?php require 'vendor/autoload.php'; //Defining auth parameters putenv('BITGRAIL_API_KEY=YourApiKey'); putenv('BITGRAIL_API_SECRET=YourSecret'); //listing balances $api = new \BitGrail\Balances(); $balances = $api->call(); var_dump($balances);
Ticker
Returns last ticker price details for a market.
<?php require 'vendor/autoload.php'; //Defining 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);
OrderBook
Returns array composed by bids and asks of a market orderbook.
<?php require 'vendor/autoload.php'; //Defining 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);
Trade History
Returns array of latest 500 transactions.
<?php require 'vendor/autoload.php'; //Defining 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);
Open Orders
Get a list of open orders by a user.
<?php require 'vendor/autoload.php'; //Defining 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);
Buy Order
Creates a buy order.
<?php require 'vendor/autoload.php'; //Defining 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);
Sell Order
Creates a sell order.
<?php require 'vendor/autoload.php'; //Defining 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);
Cancel Order
Cancels an order.
<?php require 'vendor/autoload.php'; //Defining 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);
Latest Trades
Gets a list of latest trade of authenticated user.
<?php require 'vendor/autoload.php'; //Defining 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);
Deposit Address
Gets a deposit address.
<?php require 'vendor/autoload.php'; //Defining 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);
Deposit History
Gets a list of deposits of authenticated user.
<?php require 'vendor/autoload.php'; //Defining 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);
Withdraw
Withdraws coins to other wallet / exchange.
<?php require 'vendor/autoload.php'; //Defining 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);
Withdraw History
Get a list of withdrawals of authenticated user.
<?php require 'vendor/autoload.php'; //Defining 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);
Development
Want to contribute? Great!
If you find a bug or want improve new features, be free to change de code and send a pull requests. You will be added to the developers list.
Donate
The developer spent a lot of time developing those classes. What about to contribute with some help? It will be cool to receive some XRB/MRai at xrb_31t8ncrcn1hr7xc7rpoqrjx9ufisgpaf9fbeg8nz7oyfcfd4ora7oadpjff8