I’m trying to integrate a binance api with php.
I want to spend my spot wallets and earnings.
I can’t find the url I need for it and I can’t get the endpoint either.
Additional question: For what do I need the timestamp?
$secret = "mySecretKey";
$key = "myApiKey";
$s_time = "timestamp=".time()*1000;
$sign=hash_hmac('SHA256', $s_time, $secret);
$url = "https://api.binance.com/api/v1/balances?".$s_time.'&signature='.$sign;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-MBX-APIKEY:'.$key));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
$result = json_decode($result, true);
echo '<pre>';
var_dump($result);
echo '</pre>';
curl_close($ch);
I’ve tried many urls and looked at the binance documentation for a long time but I just can’t find it.
Thanks for your help!
2
Answers
The only link I found in their API documentation is
Response:
I do not know exactly what you want to do but if you want an overview of your spot balances the right endpoint is :
GET /api/v3/account (HMAC SHA256), link to more info : https://binance-docs.github.io/apidocs/spot/en/#account-information-user_data
response:
more about the timestamp you can find here: https://binance-docs.github.io/apidocs/spot/en/#signed-trade-user_data-and-margin-endpoint-security