1

I was trying to call binance batchOrder CLICK HERE for the documentation reference. Basically i was trying to call binnace batchOrder api for placing multiple order i have provided the clear code and output along with my input. I am looking forward to expert advice

Here is the batchOrder data

 [

 {

  symbol: 'ETHUSDT',

  quantity: 0.425,

  positionSide: 'LONG',         

  side: 'SELL',

  type: 'MARKET'              

 },

 {

  symbol: 'LTCUSDT',

  quantity: 20.765,

  positionSide: 'LONG',

  side: 'SELL',

  type: 'MARKET'

 }

]
const timestamp = Date.now() - 1000
    const recvWindow = 60000
    let doneFlag = false

    var burl = "https://testnet.binancefuture.com";
    var endPoint = "/fapi/v1/batchOrders";
    var dataQueryString = `batchOrders=${encodeURIComponent(JSON.stringify(allOpositeOrders))}&recvWindow=${recvWindow}&timestamp=${timestamp}`;
    var signature = crypto.createHmac('sha256', api_secret).update(dataQueryString).digest('hex');
    var url = burl + endPoint + '?' + dataQueryString + '&signature=' + signature;
    await axios
    .post(url,{}, {
        headers: {
            'Content-Type': 'application/json',
            'X-MBX-APIKEY': api_key
        }
    })
    .then((result) => {
        if (result) {
            return result.data
        } else {
            return null
        }
    }).catch((err) => {
        console.log('err', err)
    });

This is the header of my request

headers: {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'application/json',
      'X-MBX-APIKEY': '772d7e9f365aad46411b867c5c110731a32d19fec30ee179bda21d486c9cd129',
      'User-Agent': 'axios/0.27.2',
      'Content-Length': 2
    },
    method: 'post',
    url: 'https://testnet.binancefuture.com/fapi/v1/batchOrders?batchOrders=%5B%7B%22symbol%22%3A%22ETHUSDT%22%2C%22quantity%22%3A0.425%2C%22positionSide%22%3A%22LONG%22%2C%22side%22%3A%22SELL%22%2C%22type%22%3A%22MARKET%22%7D%2C%7B%22symbol%22%3A%22LTCUSDT%22%2C%22quantity%22%3A20.765%2C%22positionSide%22%3A%22LONG%22%2C%22side%22%3A%22SELL%22%2C%22type%22%3A%22MARKET%22%7D%5D&recvWindow=60000&timestamp=1655141771830&signature=275e55faa71e0ba87e444e3ae82b81d98eaf69946e06a659a984d9a58ced0de0',
    data: '{}'
  },

but i am getting following error. I have also tried with .post(url,data=null, {}.... but it return the same error

data: { code: -1022, msg: 'Signature for th9s request is not valid.' }
piash
  • 153
  • 1
  • 5
  • have you looked at this ? https://stackoverflow.com/questions/71358449/signature-for-this-request-is-not-valid-error-for-binance-us-api and this https://github.com/jaggedsoft/php-binance-api/pull/248 – Alex B Jun 13 '22 at 18:07
  • I have seen this but i was trying to call a different api and i guess i am following all the recommended way to call the api. – piash Jun 13 '22 at 18:14

0 Answers0