ash-rain / laravel-binance-api
为 Binance API 提供的 Laravel 包装器。
dev-main
2022-08-31 21:45 UTC
Requires
- php: ^7.4|8.*
- illuminate/contracts: ^9.0
- illuminate/http: ^9.0
- illuminate/support: ^9.0
- spatie/laravel-package-tools: ^1.9
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.3
This package is auto-updated.
Last update: 2024-08-29 06:18:12 UTC
README
此包提供了对 Binance API 的 Laravel 包装器,并允许您轻松与之通信。
重要提示
该包处于早期开发阶段。建议在生产应用程序中使用之前,不要使用它,直到发布 v1.0
。请随意提交PR以贡献此项目并帮助我完成一个可生产的构建。
安装
您可以通过 composer 安装此包
composer require ash-rain/laravel-binance-api
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="binance-api-config"
打开您的 .env
文件,并添加以下内容(将 YOUR_API_KEY
和 YOUR_SECRET
替换为从 Binance 收到的 API 密钥和密钥) -
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)。请参阅 许可证文件 了解更多信息。