Binance docs https://github.com/binance-exchange/binance-official-api-docs
All interface methods are initialized the same as those provided by binance. See details src/api
Many interfaces are not yet complete, and users can continue to extend them based on my design. Welcome to improve it with me
Exchanges It includes all of the following exchanges and is highly recommended.
composer require "linwj/binance dev-master"
Support for more request Settings More
$binance=new Binance($key,$secret);
//You can set special needs
$binance->setOptions([
//Set the request timeout to 60 seconds by default
'timeout'=>10,
//If you are developing locally and need an agent, you can set this
'proxy'=>true,
//More flexible Settings
'proxy'=>[
'http' => 'http://127.0.0.1:12333',
'https' => 'http://127.0.0.1:12333',
'no' => ['.cn']
],
//Close the certificate
'verify'=>false,
]);
System related API More
$binance=new Binance();
//Order book
try {
$result=$binance->system()->getDepth([
'symbol'=>'BTCUSDT',
'limit'=>'20',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
//Recent trades list
try {
$result=$binance->system()->getTrades([
'symbol'=>'BTCUSDT',
'limit'=>'20',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
//Current average price
try {
$result=$binance->system()->getAvgPrice([
'symbol'=>'BTCUSDT'
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
Trade related API More
$binance=new Binance($key,$secret);
//Send in a new order.
try {
$result=$binance->trade()->postOrder([
'symbol'=>'BTCUSDT',
'side'=>'BUY',
'type'=>'LIMIT',
'quantity'=>'0.01',
'price'=>'2000',
'timeInForce'=>'GTC',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
//Check an order's status.
try {
$result=$binance->user()->getOrder([
'symbol'=>'BTCUSDT',
'orderId'=>$result['orderId'],
'origClientOrderId'=>$result['origClientOrderId'],
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
//Cancel an active order.
try {
$result=$binance->trade()->deleteOrder([
'symbol'=>'BTCUSDT',
'orderId'=>$result['orderId'],
'origClientOrderId'=>$result['origClientOrderId'],
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
User related API More
$binance=new Binance($key,$secret);
//Get all account orders; active, canceled, or filled.
try {
$result=$binance->user()->getAllOrders([
'symbol'=>'BTCUSDT',
'limit'=>'20',
//'orderId'=>'',
//'startTime'=>'',
//'endTime'=>'',
]);
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}
//Get current account information.
try {
$result=$binance->user()->getAccount();
print_r($result);
}catch (\Exception $e){
print_r(json_decode($e->getMessage(),true));
}