oralunal / laravel-binance-api
此包已被弃用,不再维护。未建议替代包。
Laravel 对 Binance API 的封装。
dev-main
2023-01-13 22:59 UTC
Requires
- php: ^7.4|^8.0
- illuminate/contracts: ^7.0|^8.0|^9.0
- illuminate/http: ^7.0|^8.0|^9.0
- illuminate/support: ^7.0|^8.0|^9.0
- spatie/laravel-package-tools: ^1.9
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.3
This package is not auto-updated.
Last update: 2023-06-17 23:38:07 UTC
README
此包提供了对 Binance API 的 Laravel 封装,并允许您轻松与之通信。
重要提示
此包处于早期开发阶段。在 v1.0 发布之前,不建议在生产应用中使用。请随意打开 PR 以贡献于此项目并帮助我达到生产就绪的构建。
安装
您可以通过 composer 安装此包
composer require techtailor/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.
更新日志
请参阅 更新日志 以获取有关最近更改的更多信息。
贡献
请参阅 CONTRIBUTING 以获取详细信息。
安全漏洞
请参阅 我们的安全策略 了解如何报告安全漏洞。
鸣谢
许可
MIT 许可证(MIT)。请参阅 许可文件 以获取更多信息。