PHP code example of sdtech / binance-api-laravel

1. Go to this page and download the library: Download sdtech/binance-api-laravel 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/ */

    

sdtech / binance-api-laravel example snippets


'providers' => [
    // Other Service Providers...
    Sdtech\BinanceApiLaravel\Providers\BinanceApiLaravelServiceProviders::class,
],

'BINANCE_API_LIVE_URL' => env('BINANCE_API_LIVE_URL') ?? "https://api.binance.com/api/",
'BINANCE_API_TESTNET_URL' => env('BINANCE_API_TESTNET_URL') ?? "https://testnet.binance.vision/api/",
'BINANCE_WAPI_URL' => env('BINANCE_WAPI_URL') ?? "https://api.binance.com/wapi/",
'BINANCE_SAPI_URL' => env('BINANCE_SAPI_URL') ?? "https://api.binance.com/sapi/",
'BINANCE_FAPI_URL' => env('BINANCE_FAPI_URL') ?? "https://fapi.binance.com/",
'BINANCE_BAPI_URL' => env('BINANCE_BAPI_URL') ?? "https://www.binance.com/bapi/",
'BINANCE_WSS_STREAM_URL' => env('BINANCE_WSS_STREAM_URL') ?? "wss://stream.binance.com:9443/ws/",
'BINANCE_WSS_STREAM_TESTNET_URL' => env('BINANCE_WSS_STREAM_TESTNET_URL') ?? "wss://testnet.binance.vision/ws/",
'BINANCE_API_KEY' => env('BINANCE_API_KEY'),
'BINANCE_API_SECRET_KEY' => env('BINANCE_API_SECRET_KEY'),
'BINANCE_API_TEST_MODE' => env('BINANCE_API_TEST_MODE')


use Sdtech\BinanceApiLaravel\Service\BinanceApiLaravelService;

class HomeController extends Controller
{
    public function testBinanceApi(Request $request) {

        $api = new BinanceApiLaravelService();
        $response = $api->price('BNBUSDT'); // get the current BNB price in USDT
        $response2 = $api->orderBook('BNBUSDT',100);  // get the order book data
        return $response;
    }
}
 in the same way you can use other function as well

$price = $api->price( "BNBUSDT" );
@param STRING symbol mandetory Parameter symbol and symbols cannot be used in combination.
@param STRING symbols optional Examples of accepted format for the symbols parameter: ["BTCUSDT","BNBUSDT"]
@return array with error message or array with symbol price
@throws \Exception

price(string $symbol='BNBUSDT', $symbols=[]) 


ping() // test connectivity
time() // check server time
$symbol = "BNBUSDT";
exchangeInfo($symbol)  // get exchange info
bash
php artisan vendor:publish --tag=binanceapilaravel