bobel/payeer-client

Payeer 交易 API 客户端。

v1.0.0 2022-06-14 16:30 UTC

This package is auto-updated.

Last update: 2024-09-17 10:22:08 UTC


README

安装
composer require bobel\payeer-client
测试
composer init-pest
composer test
初始化客户端
$api = new PayeerClient(
    id: 'bd443f00-092c-4436-92a4-a704ef679e24',
    key: 'your_key');
检查连接
$result = $api->isOk();

返回 IsOkResponse 对象。
抛出 IsOkException。

运行 WebSocket 服务器
$webSocket = new WebSocketServer(
    id: 'bd443f00-092c-4436-92a4-a704ef679e24',
    key: 'your_key');

$webSocket->run();
WebSocket 请求/响应格式

请求

{
  "method": "rates",
  "params": {
    "currencyPairs": [
      ["BTC", "USD"],
      ["BTC", "RUB"]
    ],    
    "action": "Action::Buy",
    "dateFrom": 1630443600,
    "dateTo": 1633035599,
    "pageSize": 3
  }
}

响应

{
  "success": true,
  "limits": {
    "interval": "min",
    "intervalNumber": 1,
    "limit": 600
  },
  "data": [
    {
      "currencyPair": ["BTC", "USD"],
      "pricePrecision": 2,
      "minPrice": "4375.74",
      "maxPrice": "83139.00",
      "minAmount": 0.0001,
      "minValue": 0.5,
      "feeMakerPercent": 0.01,
      "feeTakerPercent": 0.095      
    },
    {
      "currencyPair": ["BTC", "RUB"],
      "pricePrecision": 2,
      "minPrice": "326269.32",
      "maxPrice": "6199117.08",
      "minAmount": 0.0001,
      "minValue": 20,
      "feeMakerPercent": 0.01,
      "feeTakerPercent": 0.095      
    }
  ]
}
获取汇率
根据条件获取汇率
// Get all rates
$result = $api->rates();

// Get rates by criteria
$result = $api->rates([
    ["BTC", "USD"],
    ["BTC", "RUB"]
]);

返回 RatesResponse
抛出 ClientException。

获取统计数据
$result = $api->stats([
    ["BTC", "USD"]
]);

返回 StatsResponse

获取订单
$result = $api->orders([
    ["BTC", "USD"],
    ["BTC", "RUB"]
]);

返回 OrdersResponse

获取交易
$result = $api->trades([
    ["BTC", "USD"],
    ["BTC", "RUB"]
]);

返回 TradesResponse

获取我的交易
// Get all trades
$result = $api->myTrades();

// Get specific trades by criteria
$result = $api->myTrades(
        currencyPairs: [
            ["BTC", "USD"],
            ["BTC", "RUB"]
        ],
        action: Action::Buy,
        dateFrom: 1630443600,
        dateTo: 1633035599,
        pageSize: 3);

返回 MyTradesResponse

获取余额
$result = $api->balance();

返回 BalanceResponse

订单相关操作

列出订单
    // Get all my orders
    $result = $api->order->list(status: Status::Opened);
        
    // Get my orders by criteria
    $result = $api->order->list(
        status: Status::Opened,
        currencyPairs: [
            ["BTC", "USD"],
            ["BTC", "RUB"]
        ],
        action: Action::Buy);
        
    // Get all orders
    $result = $api->order->list(pageSize: 3);
    
    // Get all orders by criteria
    $result = $api->order->list(
        status: Status::Canceled,
        currencyPairs: [
            ["BTC", "USD"],
            ["BTC", "RUB"]
        ],
        action: Action::Buy,
        dateFrom: 1630443600,
        dateTo: 1633035599,
        pageSize: 3);    

返回 ListResponse

取消订单
    // Cancel all orders
    $result = $api->order->cancel();
    
    // Cancel orders by criteria
    $result = $api->order->cancel(
        currencyPairs: [
            ["TRX", "RUB"],
            ["DOGE", "RUB"]
        ],
        action: Action::Buy);
        
    // Cancel exact order by ID
    $result = $api->order->cancel(37054293);

返回 CancelResponse

获取订单状态
$result = $api->order->status(37054293);

返回 StatusResponse

创建订单
$result = $api->order->create(
    currencyPairs: [
        ["TRX", "USD"]
    ],
    type: Type::Limit,
    action: Action::Buy,
    amount: 10,
    price: 0.08);

返回 CreateResponseResponse