hitbtc-com/hitbtc-php-sdk
最新稳定版本:1.1.0
Composer 安装命令:
composer require hitbtc-com/hitbtc-php-sdk
包简介
HitBTC SDK for PHP
README 文档
README
The HitBTC SDK for PHP enables PHP developers to use HitBTC rest trading API in their PHP code, and build robust applications and software.
Features
- Get trading and main balances
- Place new order
- Cancel order
- Return list of orders and trades
- Transfers funds between main and trading accounts
- Returns the last created or create new one incoming cryptocurrency address that can be used to deposit cryptocurrency to your account.
- Withdraws money and creates an outgoing crypotocurrency transaction
- Returns a list of payment transactions
Installing via Composer
The recommended way to install hitbtc-php-sdk is through Composer.
# Install Composer curl -sS https://getcomposer.org/installer | php
Next, update your project's composer.json file to include hitbtc-php-sdk:
{ "require": { "hitbtc-com/hitbtc-php-sdk": "~1.0" } }
Getting Started
Go to https://hitbtc.com/settings and create your api keys
Quick Examples
New order:
$client = new \Hitbtc\ProtectedClient('API key', 'API secret', $demo = false); $newOrder = new \Hitbtc\Model\NewOrder(); $newOrder->setSide($newOrder::SIDE_SELL); $newOrder->setSymbol('BTCUSD'); $newOrder->setTimeInForce($newOrder::TIME_IN_FORCE_GTC); $newOrder->setType($newOrder::TYPE_LIMIT); $newOrder->setQuantity(10); $newOrder->setPrice(800); try { $order = $client->newOrder($newOrder); var_dump($order->getOrderId()); var_dump($order->getStatus()); // new } catch (\Hitbtc\Exception\RejectException $e) { echo $e; // if creating order will rejected } catch (\Hitbtc\Exception\InvalidRequestException $e) { echo $e->getMessage(); // error in request } catch (\Exception $e) { echo $e->getMessage(); // other error like network issue }
Cancel order:
try { $order = $client->cancelOrder($order); var_dump($order->getStatus()); // canceled } catch (\Hitbtc\Exception\RejectException $e) { echo $e; // if creating order will rejected } catch (\Hitbtc\Exception\InvalidRequestException $e) { echo $e->getMessage(); // error in request } catch (\Exception $e) { echo $e->getMessage(); // other error like network issue }
Get trading balance:
try { foreach ($client->getBalanceTrading() as $balance) { echo $balance->getCurrency() . ' ' . $balance->getAvailable() . ' reserved:' . $balance->getReserved() . "\n"; } } catch (\Hitbtc\Exception\InvalidRequestException $e) { echo $e; } catch (\Exception $e) { echo $e; } //BTC 18.314848971 reserved:0.7004 //DOGE 1122543 reserved:0
Get incoming cryptocurrency address that can be used to deposit cryptocurrency to your account:
try { $address = $client->getPaymentAddress('BTC'); } catch (\Hitbtc\Exception\InvalidRequestException $e) { echo $e; } catch (\Exception $e) { echo $e; }
Transfers funds between main and trading accounts:
try { $tnxId = $client->transferToMain('BTC', 1.5); } catch (\Hitbtc\Exception\InvalidRequestException $e) { echo $e; } catch (\Exception $e) { echo $e; }
Documentation
See the https://hitbtc.com/api for more detail.
License
hitbtc-php-sdk is licensed under the MIT License
统计信息
- 总下载量: 23.53k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 39
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-10-20