techtailor/laravel-binance-api

为Binance API提供Laravel包装器。

0.1.0 2021-11-28 13:30 UTC

This package is auto-updated.

Last update: 2024-09-24 22:45:41 UTC


README

GitHub release GitHub issues Software License Total Downloads

此包为Binance API提供了Laravel包装器,并允许您轻松地与之通信。

重要提示

此包处于早期开发阶段。在发布v1.0版本之前,不建议在生产应用程序中使用它。请随时提出PR以贡献于此项目并帮助我完成生产就绪构建。

安装

您可以通过Composer安装此包

composer require techtailor/laravel-binance-api

您可以使用以下命令发布配置文件

php artisan vendor:publish --tag="binance-api-config"

打开您的.env文件,并添加以下内容(用从Binance收到的API密钥和密钥替换YOUR_API_KEYYOUR_SECRET) -

BINANCE_KEY=YOUR_API_KEY
BINANCE_SECRET=YOUR_SECRET

或者

打开位于config/binance-api.php的已发布的配置文件,并添加您的API和密钥

return [
    'auth' => [
        'key'        => env('BINANCE_KEY', 'YOUR_API_KEY'),
        'secret'     => env('BINANCE_SECRET', 'YOUR_SECRET')
    ],
];

使用方法

使用此包非常简单。只需初始化API并调用其中一种可用方法

use TechTailor\BinanceApi\BinanceAPI;

$binance = new BinanceAPI();

$time = $binance->getTime();

您也可以在初始化后传递用户API和密钥(当您需要为单个用户隔离API密钥时非常有用)

$binance = new BinanceApi();

$binance->setApi($apiKey, $secretKey);

$accountInfo = $binance->getAccountInfo();

可用方法

可用公共方法(安全类型:NONE[不需要API密钥]

- getSystemStatus()         // returns system status, expect msg to be "normal".
- getTime()                 // returns server timestamp.
- getExchangeInfo($symbol)  // returns current exchange trading rules and symbol information.
- getOrderBook($symbol)     // returns the order book for the symbol.
- getAvgPrice($symbol)      // returns the average price for a symbol.
- getTicker($symbol)        // returns the 24hr ticker for a symbol (if no symbol provided, returns an array of all symbols).

可用私有方法(安全类型:USER_DATA[需要API密钥]

- getAccountInfo()          // returns current account information.
- getAllOrders()            // return all current account orders (active, canceled or filled).
- getOpenOrders($symbol)    // returns all current account open orders (Careful when accessing without symbol).
- getTrades($symbol)        // returns all trades for a symbol.
- getOrderStatus($symbol, $orderId) // returns status of a given order.
- getUserCoinsInfo()        // returns information of all coins available to the user.
- getDepositHistory()       // returns the user's deposit history.
- getWithdrawHistory()      // returns the user's withdraw history.

待办事项

我们正在开发的功能或附加功能列表(不分先后) -

- Improve exception handling.
- Add rate limiting to API Calls.
- Add response for API ban/blacklisting response.
- Improve ReadMe.

变更日志

请参阅CHANGELOG以获取有关最近更改的更多信息。

贡献

请参阅CONTRIBUTING以获取详细信息。

安全漏洞

请查阅我们的安全策略以了解如何报告安全漏洞。

鸣谢

许可

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