Hi, i have a problem when i call the “order” endpoint.
My request is:
https://api.binance.com/api/v3/order?symbol=BTCEUR&side=BUY&type=LIMIT&timeInForce=GTC&quantity=0.01&price=9850&recvWindow=30000×tamp=1597066653266&signature=27D1882AF …
The server response with an error:
Remote server error: 400 not valid request;
Why?
i try with postman and i get this error:
{
"code": -1101,
"msg": "Too many parameters; expected '6' and received '9'."
}
My key and signature is valid because with other endpoint works properly
dino
August 11, 2020, 12:20am
3
I had try with similar parameters and has no problem on postman,
do you mind make a screenshot of your postman.
thanks
hi,
I have a problem with the link of Create Order
https://testnet.binance.vision/api/v3/order?symbol=BNBUSDT&side=BUY&type=LIMIT&timeInForce=GTC&quantity=1&price=608.73%C3%97tamp=1743479655617&signature=2190d0d363d3a4510b94f303475905e9ecb2701b2f41a52de3f3*****************
{
"code": -1101,
"msg": "Too many parameters; expected '6' and received '7'."
}
{"symbol":"BNBUSDT","orderId":"12****12","orderListId":-1,"clientOrderId":"*****************************","transactTime":1743479655942,"price":"608.73000000","origQty":"1.00000000","executedQty":"0.00000000","origQuoteOrderQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"BUY","workingTime":1743479655942,"fills":[],"selfTradePreventionMode":"EXPIRE_MAKER"}
I realized that my request was in GET… but the request accept only POST… then i retry
you can help me :((
// $BASE_URL = 'https://api.binance.com/'; // production
$BASE_URL = 'https://testnet.binance.vision/'; // testnet
function signature($query_string, $secret) {
return hash_hmac('sha256', $query_string, $secret);
}
function sendRequest($method, $path) {
global $KEY;
global $BASE_URL;
$url = "${BASE_URL}${path}";
echo "requested URL: ". PHP_EOL;
echo $url. PHP_EOL;
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-MBX-APIKEY:'.$KEY));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, $method == "POST" ? true : false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$execResult = curl_exec($ch);
$response = curl_getinfo($ch);
// if you wish to print the response headers
// echo print_r($response);
curl_close ($ch);
return json_decode($execResult, true);
}
function signedRequest($method, $path, $parameters = []) {
global $SECRET;
$parameters['timestamp'] = round(microtime(true) * 1000);
$query = buildQuery($parameters);
$signature = signature($query, $SECRET);
return sendRequest($method, "${path}?${query}&signature=${signature}");
}
function buildQuery(array $params)
{
$query_array = array();
foreach ($params as $key => $value) {
if (is_array($value)) {
$query_array = array_merge($query_array, array_map(function ($v) use ($key) {
return urlencode($key) . '=' . urlencode($v);
}, $value));
} else {
$query_array[] = urlencode($key) . '=' . urlencode($value);
}
}
return implode('&', $query_array);
}
// get orderbook
$response = sendRequest('GET', 'api/v3/depth?symbol=BNBUSDT&limit=5');
echo json_encode($response);
// get account information, make sure API key and secret are set
$response = signedRequest('GET', 'api/v3/account');
echo json_encode($response);
// place order, make sure API key and secret are set, recommend to test on testnet.
$response = signedRequest('POST', 'api/v3/order', [
'symbol' => 'BNBUSDT',
'side' => 'BUY',
'type' => 'LIMIT',
'timeInForce' => 'GTC',
'quantity' => 1,
'price' => 608.73000000,
// 'newClientOrderId' => 'my_order', // optional
// 'newOrderRespType' => 'FULL' //optional
]);
echo json_encode($response);`Preformatted text`