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