Skip to content

Commit 5bd8ded

Browse files
authored
Switch wapi to sapi: dustLog and withdraw
As per #363 WAPI endpoints will disappear on Aug 1. The old userAssetDribbletLog function remains available until Binance decommissions it, but a deprecated warning is sent. The new dustLog function allows optional start and end arguments, but has a different output. The withdraw function has been updated to use sapi
1 parent a0f690c commit 5bd8ded

1 file changed

Lines changed: 55 additions & 21 deletions

File tree

php-binance-api.php

Lines changed: 55 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -673,12 +673,41 @@ public function assetDetail()
673673
}
674674
}
675675

676+
/**
677+
* userAssetDribbletLog - Log of the conversion of the dust assets to BNB
678+
* @deprecated
679+
*/
676680
public function userAssetDribbletLog()
677681
{
678682
$params["wapi"] = true;
683+
trigger_error('Deprecated - function will disappear on 2021-08-01 from Binance. Please switch to $api->dustLog().', E_USER_DEPRECATED);
679684
return $this->httpRequest("v3/userAssetDribbletLog.html", 'GET', $params, true);
680685
}
681686

687+
/**
688+
* dustLog - Log of the conversion of the dust assets to BNB
689+
*
690+
* @link https://binance-docs.github.io/apidocs/spot/en/#dustlog-user_data
691+
*
692+
* @property int $weight 1
693+
*
694+
* @param long $startTime (optional) Start time, e.g. 1617580799000
695+
* @param long $endTime (optional) End time, e.g. 1617580799000. Endtime is mandatory if startTime is set.
696+
*
697+
* @return array containing the response
698+
* @throws \Exception
699+
*/
700+
public function dustLog($startTime = NULL, $endTime = NULL)
701+
{
702+
$params["sapi"] = true;
703+
if (!empty($startTime) && !empty($endTime)) {
704+
$params['startTime'] = $startTime;
705+
$params['endTime'] = $endTime;
706+
}
707+
708+
return $this->httpRequest("v1/asset/dribblet", 'GET', $params, true);
709+
}
710+
682711
/**
683712
* @deprecated
684713
*
@@ -722,33 +751,35 @@ public function commissionFee($symbol = '')
722751
}
723752

724753
/**
725-
* withdraw requests a asset be withdrawn from binance to another wallet
726-
*
727-
* $asset = "BTC";
728-
* $address = "1C5gqLRs96Xq4V2ZZAR1347yUCpHie7sa";
729-
* $amount = 0.2;
730-
* $response = $api->withdraw($asset, $address, $amount);
731-
*
732-
* $address = "44tLjmXrQNrWJ5NBsEj2R77ZBEgDa3fEe9GLpSf2FRmhexPvfYDUAB7EXX1Hdb3aMQ9FLqdJ56yaAhiXoRsceGJCRS3Jxkn";
733-
* $addressTag = "0e5e38a01058dbf64e53a4333a5acf98e0d5feb8e523d32e3186c664a9c762c1";
734-
* $amount = 0.1;
735-
* $response = $api->withdraw($asset, $address, $amount, $addressTag);
736-
*
737-
* @param $asset string the currency such as BTC
738-
* @param $address string the addressed to whihc the asset should be deposited
739-
* @param $amount double the amount of the asset to transfer
740-
* @param $addressTag string adtional transactionid required by some assets
741-
* @return array with error message or array transaction
754+
* withdraw - Submit a withdraw request to move an asset to another wallet
755+
*
756+
* @link https://binance-docs.github.io/apidocs/spot/en/#withdraw-sapi
757+
*
758+
* @example https://github.com/jaggedsoft/php-binance-api#withdraw Standard withdraw
759+
* @example https://github.com/jaggedsoft/php-binance-api#withdraw-with-addresstag Withdraw with addressTag for e.g. XRP
760+
*
761+
* @property int $weight 1
762+
*
763+
* @param string $asset (mandatory) An asset, e.g. BTC
764+
* @param string $address (mandatory) The address where to send, e.g. 1C5gqLRs96Xq4V2ZZAR1347yUCpHie7sa or 44tLjmXrQNrWJ5NBsEj2R77ZBEgDa3fEe9GLpSf2FRmhexPvfYDUAB7EXX1Hdb3aMQ9FLqdJ56yaAhiXoRsceGJCRS3Jxkn
765+
* @param string $amount (mandatory) The amount, e.g. 0.2
766+
* @param string $addressTag (optional) Mandatory secondary address for some assets (XRP,XMR,etc), e.g. 0e5e38a01058dbf64e53a4333a5acf98e0d5feb8e523d32e3186c664a9c762c1
767+
* @param string $addressName (optional) Description of the address
768+
* @param string $transactionFeeFlag (optional) When making internal transfer, true for returning the fee to the destination account; false for returning the fee back to the departure account.
769+
* @param string $network (optional)
770+
* @param string $orderId (optional) Client id for withdraw
771+
*
772+
* @return array containing the response
742773
* @throws \Exception
743774
*/
744-
public function withdraw(string $asset, string $address, $amount, $addressTag = null, $addressName = "", bool $transactionFeeFlag = false, $network = null)
775+
public function withdraw(string $asset, string $address, $amount, $addressTag = null, $addressName = "", bool $transactionFeeFlag = false, $network = null, $orderId = null)
745776
{
746777
$options = [
747-
"asset" => $asset,
778+
"coin" => $asset,
748779
"address" => $address,
749780
"amount" => $amount,
750781
"transactionFeeFlag" => $transactionFeeFlag,
751-
"wapi" => true,
782+
"sapi" => true,
752783
];
753784
if (is_null($addressName) === false && empty($addressName) === false) {
754785
$options['name'] = str_replace(' ', '%20', $addressName);
@@ -759,7 +790,10 @@ public function withdraw(string $asset, string $address, $amount, $addressTag =
759790
if (is_null($network) === false && empty($network) === false) {
760791
$options['network'] = $network;
761792
}
762-
return $this->httpRequest("v3/withdraw.html", "POST", $options, true);
793+
if (is_null($orderId) === false && empty($orderId) === false) {
794+
$options['withdrawOrderId'] = $orderId;
795+
}
796+
return $this->httpRequest("v1/capital/withdraw/apply", "POST", $options, true);
763797
}
764798

765799
/**

0 commit comments

Comments
 (0)