obydul / lypto-api
Laravel cryptocurrency trading APIs.
Requires
- laravel/framework: 7.*|8.*|9.*
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:
We will add more exchanges and APIs soon.
Tools
Indicator API list:
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:
Account & Wallet:
Spot trade:
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 ❤️.