Installation is easily done via Composer, simply run:
$ composer require erikbooij/bittrex-client
Instantiate an instance of the client with the following code:
$bittrexClient = new ErikBooij\Bittrex\Client('api-key', 'api-secret');
Alternatively, you can pass your own HTTPClient in, as long as it conforms to GuzzleHttp's ClientInterface
.
If you like, you can register your own exception handling, by passing a callable to the ->setExceptionHandler()
method.
$bittrexClient->setExceptionHandler(function (\Exception $exception) {
// Log the exception, or do whatever you prefer
});
This method will return details on your balance.
/** @return ErikBooij\Bittrex\Model\Balance */
$bittrexClient->getBalance('BTC');
This method will return an array containing all balances available within your Bittrex account.
/** @return ErikBooij\Bittrex\Model\Balance[] */
$bittrexClient->getBalances();
This method will return an array containing the currencies available on Bittrex.
/** @return ErikBooij\Bittrex\Model\Currency[] */
$bittrexClient->getCurrencies();
This method will return the current deposit address for the given currency. If there is no address available yet, it will be generated at Bittrex and the call will return 'Address is being generated'
.
/** @return string */
$bittrexClient->getDepositAddress('BTC');
This method will return an array containing 200 of the most recent orders for the market you supply.
/** @return ErikBooij\Bittrex\Model\Transaction[] */
$bittrexClient->getMarketHistory('BTC-LTC');
This method will return an array containing all markets available on Bittrex.
/** @return ErikBooij\Bittrex\Model\Market[] */
$bittrexClient->getMarkets();
This method will return an array containing summaries for each market on Bittrex.
/** @return ErikBooij\Bittrex\Model\MarketSummary[] */
$bittrexClient->getMarketSummaries();
This method will return a single market summary for the market you supply.
/** @return ErikBooij\Bittrex\Model\MarketSummary */
$bittrexClient->getMarketSummary('BTC-LTC');
This method will return an array containing all your orders that are currently open.
/** @return ErikBooij\Bittrex\Model\OpenOrder[] */
$bittrexClient->getOpenOrders();
This method will return an array containing the open orders on the market.
/** @return ErikBooij\Bittrex\Model\Order[] */
$bittrexClient->getOrderBook('BTC-LTC');
This method will return the latest tick for the market.
/** @return ErikBooij\Bittrex\Model\Ticker */
$bittrexClient->getTicker('BTC-LTC');
This method allows you to place a limit buy or sell order. On success it returns the UUID for the order, otherwise it returns the error message.
/** @return string */
$bittrexClient->placeLimitOrder('buy', 'BTC-LTC', 50.0, 0.0055);
$bittrexClient->placeLimitOrder('sell', 'BTC-LTC', 50.0, 0.0055);
This method allows you to place a market buy or sell order. On success it returns the UUID for the order, otherwise it returns the error message.
/** @return string */
$bittrexClient->placeMarketOrder('buy', 'BTC-LTC', 50.0);
$bittrexClient->placeMarketOrder('sell', 'BTC-LTC', 50.0);
This method allows you to cancel an order (market and limit). It returns true if the order was successfully cancelled.
/** @return bool */
$bittrexClient->cancelOrder('e606d53c-8d70-11e3-94b5-425861b86ab6');
$balance = $bittrexClient->getBalance('BTC');
$balance->getAddress(); // <string>
$balance->getAvailable(); // <float>
$balance->getCurrency(); // <string>
$balance->getPending(); // <float>
$balance->getTotal(); // <float>
$currencies = $bittrexClient->getCurrencies();
$currencies[0]->getBaseAddress(); // <string>
$currencies[0]->getCoinType(); // <string>
$currencies[0]->getLongName(); // <string>
$currencies[0]->getMinConfirmation(); // <int>
$currencies[0]->getShortName(); // <string>
$currencies[0]->getTxFee(); // <float>
$currencies[0]->isActive(); // <bool>
$market = $bittrexClient->getMarket('BTC-LTC');
$market->getBaseCurrency(); // <string>
$market->getCreated(); // <DateTime>
$market->getMarketCurrency(); // <string>
$market->getMarketName(); // <string>
$market->getMinTradeSize(); // <float>
$market->isActive(); // <bool>
$marketSummary = $bittrexClient->getMarketSummary('BTC-LTC');
$marketSummary->getAsk(); // <float>
$marketSummary->getBaseVolume(); // <float>
$marketSummary->getBid(); // <float>
$marketSummary->getCreated(); // <DateTime>
$marketSummary->getHigh(); // <float>
$marketSummary->getLast(); // <float>
$marketSummary->getLow(); // <float>
$marketSummary->getMarketName(); // <string>
$marketSummary->getOpenBuyOrders(); // <int>
$marketSummary->getOpenSellOrders(); // <int>
$marketSummary->getPrevDay(); // <float>
$marketSummary->getTimeStamp(); // <DateTime>
$marketSummary->getVolume(); // <float>
$openOrders = $bittrexClient->getOpenOrders();
$openOrders[0]->getCommissionPaid(); // <float>
$openOrders[0]->getCondition(); // <string>
$openOrders[0]->getConditionTarget(); // <float>
$openOrders[0]->getLimit(); // <float>
$openOrders[0]->getMarket(); // <string>
$openOrders[0]->getOpened(); // <DateTime>
$openOrders[0]->getOrderType(); // <string>
$openOrders[0]->getOrderUuid(); // <string>
$openOrders[0]->getPrice(); // <float>
$openOrders[0]->getPricePerUnit(); // <float>
$openOrders[0]->getQuantity(); // <float>
$openOrders[0]->getQuantityRemaining(); // <float>
$openOrders[0]->getUuid(); // <string>
$openOrders[0]->isCancelInitiated(); // <bool>
$openOrders[0]->isConditional(); // <bool>
$openOrders[0]->isImmediateOrCancel(); // <bool>
$orders = $bittrexClient->getOrderBook('BTC-LTC');
$orders[0]->getRate(); // <float>
$orders[0]->getQuantity(); // <float>
$orders[0]->getType(); // <string>
$ticker = $bittrexClient->getTicker('BTC-LTC');
$ticker->getAsk(); // <float>
$ticker->getBid(); // <float>
$ticker->getLast(); // <float>
$transactions = $bittrexApi->getMarketHistory('BTC-LTC');
$transactions[0]->getFillType(); // <string>
$transactions[0]->getId(); // <int>
$transactions[0]->getOrdertype() // <string>
$transactions[0]->getPrice() // <float>
$transactions[0]->getProcessedTime(); // <DateTime>
$transactions[0]->getQuantity(); // <float>
$transactions[0]->getTotal(); // <total>