tsukiro / buda-sdk

本项目的目的是生成一个PHP SDK,用于使用Buda.com网站的服务端点

3.3 2021-05-23 07:30 UTC

This package is auto-updated.

Last update: 2024-09-05 13:44:23 UTC


README

Contributors Forks Stargazers Issues MIT License PHP Composer

描述

本项目的目的是生成一个PHP SDK,用于使用Buda.com网站的服务端点。目前该项目使用Tsukiro的Codegen生成,未来版本可能会进行更改。

要求

PHP 5.5 及以上版本

安装与使用

Composer

您可以使用Composer(v2)安装此项目。

您可以将以下命令行添加到您的 composer.json 文件中

{
  "require": {
    "tsukiro/buda-sdk": "*@dev"
  }
}

然后执行 composer install

测试

运行单元测试

composer install
./vendor/bin/phpunit

入门指南

在完成安装和使用的步骤后,您可以执行以下操作

<?php
require_once(__DIR__ . '/vendor/autoload.php');

$apiInstance = new Tsukiro\Client\Api\BudaApi();

try {
    $apiInstance->setApiKey("YOUR_APIKEY");
    $apiInstance->setSecret("YOUR_SECRET");
    $response =  $apiInstance->getBalance();
    list($body, $statusCode, $headers) = $response;

} catch (Exception $e) {
    echo 'Exception when calling BudaApi->apiV2BalancesGet: ', $e->getMessage(), PHP_EOL;
}

$apiInstance = new Tsukiro\Client\Api\BudaApi();

try {
    $response = $apiInstance->getMarkets();
    list($markets, $statusCode, $headers) = $response;
} catch (Exception $e) {
    echo 'Exception when calling BudaApi->getMarkets: ', $e->getMessage(), PHP_EOL;
}

$apiInstance = new Tsukiro\Client\Api\BudaApi();
$market_id = "market_id_example"; // string | Market ID obtenido desde le metodo getMarkets o desde tu base de datos

try {
    $response = $apiInstance->getTicker($market_id);
    list($ticker, $statusCode, $headers) = $response;
} catch (Exception $e) {
    echo 'Exception when calling BudaApi->apiV2MarketsMarketIdTickerGet: ', $e->getMessage(), PHP_EOL;
}
?>

API端点文档

所有URI相对于 https://www.buda.com

授权文档

对于需要认证的路由,例如getBalances,您需要设置您的apikey和secret。自动生成的函数将生成必要的nonce和signature,以便与Buda端点通信。

    $apiInstance->setApiKey("YOUR_APIKEY");
    $apiInstance->setSecret("YOUR_SECRET");