jaggedsoft / php-binance-api

PHP Binance API is an asynchronous PHP library for the Binance API designed to be easy to use. https://github.com/binance-exchange/php-binance-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: Signature for this request is not valid.

kojoakyer opened this issue · comments

Short Description:

  • im nit able to fetch data form binance api, i have set everything right but i keep getting Signature for this request is not valid.

var apiSecret = process.env.SECRET_KEY

const getParameters = async ()=>{
const response = await fetch('https://api.binance.com/api/v3/time',{
headers:{
"X-MBX-APIKEY":process.env.API_KEY
}
})
const {serverTime}= await response.json()
const query_string = timestamp=${serverTime};
const signature = crypto
.createHmac('sha256', apiSecret)
.update(query_string)
.digest('hex')

console.log(serverTime);
console.log(signature);

return {serverTime,signature}

}

try{
const {serverTime,signature}= await getParameters()

    const response = await fetch(`https://api.binance.com/api/v3/order?symbol=${base}&timestamp=${serverTime}&signature=${signature}`,{
        headers:{
            "X-MBX-APIKEY":process.env.API_KEY,
            "signature":signature
        }
    })
    .then((response) => response.json())
    .then((data) => console.log(data));
    // console.log(response);
    res.status(200).json(response)
  • windows

nodejs version: