obydul/lypto-api
Composer 安装命令:
composer require obydul/lypto-api
包简介
Laravel cryptocurrency trading APIs.
关键字:
README 文档
README
Laravel cryptocurrency trading APIs.
Installation
Requirements
- Minimum Laravel version 7.0
Use the following command to install:
composer require obydul/lypto-api
Run the following command to publish config file:
php artisan vendor:publish --provider="Obydul\LyptoAPI\LyptoAPIServiceProvider" --tag="config"
(Optional) Laravel 5.5 uses package auto-discovery, so doesn't require you to manually add the ServiceProvider. If you don't use auto-discovery,
// add the service provider to your `$providers` array in `config/app.php` file Obydul\LyptoAPI\LyptoAPIServiceProvider::class // and add these lines to `$aliases` array 'Binance' => Obydul\LyptoAPI\Facades\Binance::class, 'TAAPI' =>Obydul\LyptoAPI\Facades\TAAPI::class,
Clear application config, cache (optional):
php artisan optimize
Installation completed.
Configuration
After installation, set API key and secret in the .env file.
// exchange LYPTO_API_MODE="sandbox" // sanbox or live LYPTO_API_BINANCE_KEY="your-binane-api-key" LYPTO_API_BINANCE_SECRET="your-binane-api-secret" // tools LYPTO_API_TAAPI_SECRET="your-taapi-secret"
Exchanges & Tools
Exchanges
Supported exchanges and features:
| Exchange | Features |
|---|---|
| Binance | Spot trade only |
We will add more exchanges and APIs soon.
Tools
Indicator API list:
| Name | Features |
|---|---|
| TAAPI | Provides technical analysis indicator data |
Usage
Create a Lypto request:
use Obydul\LyptoAPI\Libraries\LyptoRequest; $request = new LyptoRequest(); $request->param1 = 'Value 1'; $request->param2 = "Value 2"; $request->param2 = "Value 2";
Pass Laypto request to exchange's function:
// exchange object $exchange->functionName($request); // exchange facade Exchange::functionName($request);
Binance
Take a look at Binance APIs and parameters.
use Obydul\LyptoAPI\Exchanges\Binance; // create a Binance object $binance = new Binance(); // create order $binance->createOrder($request); // using facade use Obydul\LyptoAPI\Facades\Binance; Binance::createOrder($request);
Pass api key, secret & mode without .env file:
$api_key = "YOUR_API_KEY"; $api_secret = "YOUR_API_SECRET"; $mode = "sandbox"; // default is live $this->binance = new Binance($api_key, $api_secret, $mode); // mode doesn't need to pass for live $this->binance = new Binance($api_key, $api_secret); // live // using facade use Obydul\LyptoAPI\Facades\Binance; $account_info = Binance::config($api_key, $api_secret, $mode)->accountInfo(); // sandbox $account_info = Binance::config($api_key, $api_secret)->accountInfo(); // live
Available methods:
Test server:
| Title | Method |
|---|---|
| Test Connectivity | ping() |
| Check Server Time | time() |
| Exchange Information | exchangeInfo() |
Account & Wallet:
| Title | Method |
|---|---|
| Account Status | accountStatus() |
| Get current account information | accountInfo() |
| Get trading status | apiTradingStatus() |
| Get overall balance | accountSnapshot() |
Spot trade:
| Title | Method |
|---|---|
| Current price of a pair | currentPrice($request) |
| Create order | createOrder($request) |
| Cancel an active order | cancelOrder($request) |
| Cancels all active orders on a symbol | cancelOpenOrders($request) |
| Check an order's status | queryOrder($request) |
| Get all open orders on a symbol | currentOpenOrders($request) |
| Get all account orders; active, canceled, or filled | allOrders($request) |
| Get trades for a specific account and symbol | accountTradeList($request) |
| Create a new OCO | createOCO($request) |
| Cancel an entire Order List | cancelOCO($request) |
| Retrieves a specific OCO based on provided optional parameters | queryOCO($request) |
| Retrieves all OCO based on provided optional parameters | queryAllOCO($request) |
| Retrieves open OCO | queryOpenOCO($request) |
| 24hr Ticker Price Change Statistics | priceChange24Hr($request |
| Average price of a pair (5 mins) | avgPrice($request |
TAAPI
TAAPI provides technical analysis (TA) indicator data.
Let's have a look at the uasge:
use Obydul\LyptoAPI\Tools\TAAPI; $taapi = new TAAPI(); $request = new LyptoRequest(); $indicator_endpoint = "rsi"; $taapi->get($indicator_endpoint, $request); // call via facade use Obydul\LyptoAPI\Facades\TAAPI; TAAPI::get($indicator_endpoint, $request);
Pass api key without .env file:
$api_key = "YOUR_API_KEY"; $response = TAAPI::config($api_key)->get($indicator_endpoint, $request);
Examples
Binance
use Obydul\LyptoAPI\Exchanges\Binance; use Obydul\LyptoAPI\Libraries\LyptoRequest; private $binance; /** * constructor. */ public function __construct() { $this->binance = new Binance(); } // account info $account_info = $this->binance->accountInfo(); dd($account_info); // account info using facade use Obydul\LyptoAPI\Facades\Binance; $account_info = Binance::accountInfo(); dd($account_info); // create order $request = new LyptoRequest(); $request->symbol = 'BTCUSDT'; $request->side = "SELL"; $request->type = "LIMIT"; $request->timeInForce = "GTC"; $request->quantity = 0.01; $request->price = 9000; $request->newClientOrderId = "my_order_id_1112"; $create_order = $this->binance->createOrder($request); dd($create_order); // account trade list $request = new LyptoRequest(); $request->symbol = "BTCUSDT"; $trade_list = $this->binance->accountTradeList($request); dd($trade_list);
TAAPI
use Obydul\LyptoAPI\Facades\TAAPI; use Obydul\LyptoAPI\Libraries\LyptoRequest; // lypto request $request = new LyptoRequest(); $request->exchange = 'binance'; $request->symbol = "BTC/USDT"; $request->interval = "1h"; // indicator endpoint $indicator_endpoint = "macd"; // get data $response = TAAPI::get($indicator_endpoint, $request); dd($response);
Output:
array:3 [▼ "valueMACD" => 289.32379962478 "valueMACDSignal" => 257.39665148897 "valueMACDHist" => 31.92714813581 ]
Information
License
The MIT License (MIT). Please see license file for more information.
Others
In case of any issues, kindly create one on the Issues section.
Thank you for installing LyptoAPI ❤️.
obydul/lypto-api 适用场景与选型建议
obydul/lypto-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 543 次下载、GitHub Stars 达 4, 最近一次更新时间为 2021 年 04 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cryptocurrency」 「trading」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 obydul/lypto-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 obydul/lypto-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 obydul/lypto-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Secure Trading driver for the Omnipay PHP payment processing library
Cryptonator Merchant API
TwelveData API client library
Implementation of Bitclout API interaction through its node
trading API Version 1299
eBay Trading PHP SDK
统计信息
- 总下载量: 543
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-08