Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

68
Vistas
Binance Futures API: Signature is not valid

I'm currently developing a trading bot for fun, but when I want to send a POST request with axios I get following error as a response: {code: -1022, msg: 'Signature for this request is not valid.'}

I use the node.js crypto package to create a hmac sha256 hash like mentionend in the binance api docs and in every other tutorial i've seen.

I also already created a new API, so my key & secret is correct!

Here's the code:

let querystring = `symbol=LTCUSDT&side=BUY&type=LIMIT&timeInForce=GTC&quantity=0.05&price=${price}&recvWindow=5000&timestamp=${new Date().getTime()}`;
            let signature = crypto
                .createHmac('sha256', credentials.secret)
                .update(querystring)
                .digest('hex');

            axios
                .post(
                    `https://fapi.binance.com/fapi/v1/order?${querystring}&signature=${signature}`,
                    {},
                    {
                        headers: {
                            'X-MBX-APIKEY': credentials.key,
                            'content-type': 'application/x-www-form-urlencoded',
                        },
                    }
                )
                .then((response) => {
                    console.log(response.data);
                    resolve(response);
                })
                .catch(function (error) {
                    if (error.response) {
                        // Request made and server responded
                        console.log(error.response.data);
                        console.log(error.response.status);
                        console.log(error.response.headers);
                    } else if (error.request) {
                        // The request was made but no response was received
                        console.log(error.request);
                    } else {
                        // Something happened in setting up the request that triggered an Error
                        console.log('Error', error.message);
                    }
                });
5 months ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos