Skip to content

Commit adb5e7d

Browse files
ePascalCdmzoneill
authored andcommitted
Adding systemStatus, accountSnapshot, accountStatus, apiTradingStatus
1 parent 37d9c67 commit adb5e7d

1 file changed

Lines changed: 97 additions & 3 deletions

File tree

php-binance-api.php

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,9 +1218,11 @@ protected function httpRequest(string $url, string $method = "GET", array $param
12181218
}
12191219

12201220
if (isset($json['msg']) && !empty($json['msg'])) {
1221-
// should always output error, not only on httpdebug
1222-
// not outputing errors, hides it from users and ends up with tickets on github
1223-
throw new \Exception('signedRequest error: '.print_r($output, true));
1221+
if ( $url != 'v1/system/status' && $url != 'v3/systemStatus.html' && $url != 'v3/accountStatus.html') {
1222+
// should always output error, not only on httpdebug
1223+
// not outputing errors, hides it from users and ends up with tickets on github
1224+
throw new \Exception('signedRequest error: '.print_r($output, true));
1225+
}
12241226
}
12251227
$this->transfered += strlen($output);
12261228
$this->requestCount++;
@@ -2603,4 +2605,96 @@ public function isOnTestnet() : bool
26032605
{
26042606
return $this->useTestnet;
26052607
}
2608+
2609+
/**
2610+
* systemStatus - Status indicator for sapi and wapi
2611+
* 0 = Normal, 1 = System Maintenance
2612+
*
2613+
* @link https://binance-docs.github.io/apidocs/spot/en/#system-status-system
2614+
*
2615+
* @property int $weight 0
2616+
*
2617+
* @return array containing the response
2618+
* @throws \Exception
2619+
*/
2620+
public function systemStatus()
2621+
{
2622+
$arr = array();
2623+
$arr['sapi'] = $this->httpRequest("v1/system/status", 'GET', [ 'sapi' => true ], true);
2624+
$arr['wapi'] = $this->httpRequest("v3/systemStatus.html", 'GET', [ 'wapi' => true ], true);
2625+
return $arr;
2626+
}
2627+
2628+
/**
2629+
* accountSnapshot - Daily Account Snapshot at 00:00:00 UTC
2630+
*
2631+
* @link https://binance-docs.github.io/apidocs/spot/en/#daily-account-snapshot-user_data
2632+
*
2633+
* @property int $weight 1
2634+
*
2635+
* @param string $type (mandatory) Should be SPOT, MARGIN or FUTURES
2636+
* @param int $nbrDays (optional) Number of days. Default 5, min 5, max 30
2637+
* @param long $startTime (optional) Start time, e.g. 1617580799000
2638+
* @param long $endTime (optional) End time, e.g. 1617667199000
2639+
*
2640+
* @return array containing the response
2641+
* @throws \Exception
2642+
*/
2643+
public function accountSnapshot($type, $nbrDays = 5, $startTime = 0, $endTime = 0)
2644+
{
2645+
if ($nbrDays < 5 || $nbrDays > 30)
2646+
$nbrDays = 5;
2647+
2648+
$params = [
2649+
'sapi' => true,
2650+
'type' => $type,
2651+
];
2652+
2653+
if ($startTime > 0)
2654+
$params['startTime'] = $startTime;
2655+
if ($endTime > 0)
2656+
$params['endTime'] = $startTime;
2657+
if ($nbrDays != 5)
2658+
$params['limit'] = $limit;
2659+
2660+
return $this->httpRequest("v1/accountSnapshot", 'GET', $params, true);
2661+
}
2662+
2663+
/**
2664+
* accountStatus - Fetch account status detail.
2665+
*
2666+
* @link https://binance-docs.github.io/apidocs/spot/en/#account-status-user_data
2667+
* @link https://binance-docs.github.io/apidocs/spot/en/#account-status-sapi-user_data
2668+
*
2669+
* @property int $weight 2
2670+
*
2671+
* @return array containing the response
2672+
* @throws \Exception
2673+
*/
2674+
public function accountStatus()
2675+
{
2676+
$arr = array();
2677+
$arr['sapi'] = $this->httpRequest("v1/account/status", 'GET', [ 'sapi' => true ], true);
2678+
$arr['wapi'] = $this->httpRequest("v3/accountStatus.html", 'GET', [ 'wapi' => true ], true);
2679+
return $arr;
2680+
}
2681+
2682+
/**
2683+
* apiTradingStatus - Fetch account API trading status detail.
2684+
*
2685+
* @link https://binance-docs.github.io/apidocs/spot/en/#account-api-trading-status-user_data
2686+
* @link https://binance-docs.github.io/apidocs/spot/en/#account-api-trading-status-sapi-user_data
2687+
*
2688+
* @property int $weight 2
2689+
*
2690+
* @return array containing the response
2691+
* @throws \Exception
2692+
*/
2693+
public function apiTradingStatus()
2694+
{
2695+
$arr = array();
2696+
$arr['sapi'] = $this->httpRequest("v1/account/apiTradingStatus", 'GET', [ 'sapi' => true ], true);
2697+
$arr['wapi'] = $this->httpRequest("v3/apiTradingStatus.html", 'GET', [ 'wapi' => true ], true);
2698+
return $arr;
2699+
}
26062700
}

0 commit comments

Comments
 (0)