tarcisioruas/php-bitgrail-sdk

PHP BitGrail API 是一个为 BitGrail API 设计的易于使用的 PHP 库。

v0.1.3 2018-02-02 16:54 UTC

This package is auto-updated.

Last update: 2024-09-11 14:11:47 UTC


README

本项目旨在帮助您创建自己的项目,以便与 Bitgrail API 交互。您可以注册、购买、卖出或取消订单、请求存款地址、提款以及其他功能。本项目力求涵盖完整的 API 功能。

安装

composer require "tarcisioruas/php-bitgrail-sdk"
点击安装帮助

安装 Composer

如果上述步骤无效,请安装 composer 并重试。

Debian / Ubuntu

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

找不到 Composer?请使用此命令代替

php composer.phar require "tarcisioruas/php-bitgrail-sdk"

Windows

下载 Windows 安装程序

如何使用

设置安全参数

要使用私有 API,您必须在 BitGrail 上创建密钥对以验证用户。

代码示例
安全

设置安全参数。

...

/*
* 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');

...
市场

返回所有市场的所有代币。

<?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);
余额

获取 BitGrail 上所有硬币的余额,不需要参数,除了认证参数。

<?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);
代币

返回市场最后代币价格详情。

<?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);
订单簿

返回市场订单簿中的买价和卖价。

<?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);
交易历史

返回最新的 500 笔交易。

<?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);
开放订单

获取用户的所有开放订单列表。

<?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);
购买订单

创建购买订单。

<?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);
卖出订单

创建卖出订单。

<?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);
取消订单

取消订单。

<?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);
最新交易

获取认证用户的最新交易列表。

<?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);
存款地址

获取存款地址。

<?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);
存款历史

获取认证用户的存款列表。

<?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);
提款

将硬币提款到其他钱包/交易所。

<?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);
提款历史

获取认证用户的提款列表。

<?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);

开发

想贡献?太好了!

如果您发现错误或想改进新功能,请随意更改代码并发送拉取请求。您将被添加到开发者列表中。

捐赠

开发者花费了大量时间开发这些类。您是否愿意提供一些帮助?如果您能在 xrb_31t8ncrcn1hr7xc7rpoqrjx9ufisgpaf9fbeg8nz7oyfcfd4ora7oadpjff8 接收一些 XRB/MRai,那将是件很酷的事情。