messerli90/bittrex

Laravel Bittrex API 封装器

安装: 393

依赖: 0

建议: 0

安全性: 0

星标: 5

关注者: 2

分支: 4

开放问题: 0

类型:封装器

dev-master 2019-10-31 03:18 UTC

This package is auto-updated.

Last update: 2024-09-29 04:42:54 UTC


README

Build Status Built For Laravel License Total Downloads

简介

此包提供了一种简单易用的封装器,用于围绕 Bittrex API 进行操作,以便在您的 Laravel 应用程序中使用。

为了使用 Bittrex API,您必须有一个账户和 API 密钥。

示例

获取所有货币的余额报表

use Messerli90\Bittrex\Bittrex;

$bittrex = new Bittrex(config('services.bittrex.key'), config('services.bittrex.secret'));

$balances = $bittrex->getBalances();

return $balances;
{
  "success": true,
  "message": "",
  "result": [
    {
      "Currency": "BTC",
      "Balance": 2.20529678,
      "Available": 2.20529678,
      "Pending": 0,
      "CryptoAddress": null
    },
    {
      "Currency": "LTC",
      "Balance": 12.96782052,
      "Available": 12.96782052,
      "Pending": 0,
      "CryptoAddress": null
    }
  ]
}

安装

messerli90/bittrex 添加到您的 composer.json 文件中。

"messerli90/bittrex": "~1.0"

或者

composer require messerli90/bittrex

运行 composer update 以拉取包的最新版本。

现在打开 app/config/app.php 并将服务提供者添加到您的 providers 数组中。

'providers' => array(
    Messerli90\Bittrex\BittrexServiceProvider::class,
)

可选地,将外观添加到您的 aliases 数组

'Bittrex' => \Messerli90\Bittrex\Facades\Bittrex::class,

配置

bittrex 添加到您的 config/services.php 数组中

'bittrex' => [
    'key' => 'YOUR_API_KEY',
    'secret' => 'YOUR_API_SECRET'
]

使用方法

use Messerli90\Bittrex\Bittrex;

$bittrex = new Bittrex(config('services.bittrex.key'), config('services.bittrex.secret'));

公共 API

// Used to get the open and available trading markets at Bittrex along with other meta data.
$bittrex->getMarkets();

// Used to get all supported currencies at Bittrex along with other meta data.
$bittrex->getCurrencies();

// Used to get the current tick values for a market.
$bittrex->getTicker('BTC-LTC');

// Used to get the last 24 hour summary of all active exchanges
$bittrex->getMarketSummaries();

// Used to get the last 24 hour summary of all active exchanges
$bittrex->getMarketSummary('BTC-LTC');

// Used to get retrieve the orderbook for a given market
$bittrex->getOrderBook('BTC-LTC', 'both');

// Used to retrieve the latest trades that have occured for a specific market.
$bittrex->getMarketHistory('BTC-LTC');

市场

// Used to place a buy order in a specific market. Use buylimit to place limit orders. Make sure you have the proper permissions set on your API keys for this call to work
$bittrex->buyLimit('BTC-LTC', 1.2, 1.3);

// Used to place an sell order in a specific market. Use selllimit to place limit orders.
$bittrex->sellLimit('BTC-LTC', 1.2, 1.3);

// Used to cancel a buy or sell order.
$bittrex->cancel('ORDER_UUID');

// Get all orders that you currently have opened. A specific market can be requested
$bittrex->getOpenOrders('BTC-LTC');

账户

// Used to retrieve all balances from your account
$bittrex->getBalances();

// Used to retrieve the balance from your account for a specific currency.
$bittrex->getBalance('BTC');

// Used to retrieve or generate an address for a specific currency. If one does not exist, the call will fail and return ADDRESS_GENERATING until one is available.
$bittrex->getDepositAddress('BTC');

// Used to withdraw funds from your account. note: please account for txfee.
$bittrex->withdraw('BTC', 1, 'BTC-ADDRESS');

// Used to retrieve all balances from your account
$bittrex->getBalances();

// Used to retrieve a single order by uuid.
$bittrex->getOrder('0cb4c4e4-bdc7-4e13-8c13-430e587d2cc1');

// Used to retrieve your order history.
$bittrex->getOrderHistory('BTC-LTC');

// Used to retrieve your withdrawal history.
$bittrex->getWithdrawalHistory('BTC');

// Used to retrieve your deposit history.
$bittrex->getDepositHistory('BTC');

返回数据的格式

返回的 JSON 数据被解码为 PHP 对象。

运行单元测试

如果您在环境中安装了 PHPUnit,请运行

$ phpunit

IGDB API

贡献

请参阅 CONTRIBUTING 获取详细信息。

致谢

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 获取更多信息。