PHP code example of obydul / lypto-api

1. Go to this page and download the library: Download obydul/lypto-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

obydul / lypto-api example snippets


php artisan vendor:publish --provider="Obydul\LyptoAPI\LyptoAPIServiceProvider" --tag="config"

// 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,

php artisan optimize

// 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"

use Obydul\LyptoAPI\Libraries\LyptoRequest;

$request = new LyptoRequest();
$request->param1 = 'Value 1';
$request->param2 = "Value 2";
$request->param2 = "Value 2";

// exchange object
$exchange->functionName($request);

// exchange facade
Exchange::functionName($request);

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);

$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

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);

$api_key = "YOUR_API_KEY";
$response = TAAPI::config($api_key)->get($indicator_endpoint, $request);

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);

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);

array:3 [▼
  "valueMACD" => 289.32379962478
  "valueMACDSignal" => 257.39665148897
  "valueMACDHist" => 31.92714813581
]