node-binance-api icon indicating copy to clipboard operation
node-binance-api copied to clipboard

Invalid API key, IP or permission for this action on testnet

Open hammadhere7 opened this issue 3 years ago • 3 comments

I am facing an issue with trying testnet for new orders. I get this error: -2015 Invalid API key, IP or permission for this action

I tried with new keys as well but same error. It works with live keys. Also if I use same keys via PHP SDK then orders get placed successfully for testnet too. So something wrong with sending test order via testnet.

Can you please help, I need to test my app in testnet before moving to production

hammadhere7 avatar Jul 21 '21 06:07 hammadhere7

Getting the same, seems node-binance-api still uses production API URLs for the test: true case.

url: Url {
      protocol: 'https:',
      slashes: true,
      auth: null,
      host: 'api.binance.com',
      port: null,
      hostname: 'api.binance.com',
      hash: null,
      search: '?timestamp=1626882617481&recvWindow=5000&signature=1fe1bf5934a4c186572d95a4d15310d83ea288ac370b68ad2f7c7c6e16d1c5e2',
      query: 'timestamp=1626882617481&recvWindow=5000&signature=1fe1bf5934a4c186572d95a4d15310d83ea288ac370b68ad2f7c7c6e16d1c5e2',
      pathname: '/api/v3/account',
      path: '/api/v3/account?timestamp=1626882617481&recvWindow=5000&signature=1fe1bf5934a4c186572d95a4d15310d83ea288ac370b68ad2f7c7c6e16d1c5e2',
      href: 'https://api.binance.com/api/v3/account?timestamp=1626882617481&recvWindow=5000&signature=1fe1bf5934a4c186572d95a4d15310d83ea288ac370b68ad2f7c7c6e16d1c5e2'
    },

Production API URLs are use while I provide node-binance-api with the 'test: true' option.

export const binance = new Binance().options({
  APIKEY: config.binance.test.api.key,
  APISECRET: config.binance.test.api.secret,
  test: true,
  useServerTime: true,
  verbose: true,
});

Error:

 body: '{"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}',

Edit: It can be overriden with:

urls: {
  base: "https://testnet.binance.vision/api/"
}

This will make it work. But I just wonder what the meaning of the test option then is? Seems like it's unfortunately not fully implemented, hence the confusion.

sand3r avatar Jul 21 '21 15:07 sand3r

The testnet futures need a separate account on https://testnet.binancefuture.com/. After the registration in the chart scroll down to "Positions" etc. There you will find a tab API Key. Try this key for your future trading testnet API.

CFlop avatar Oct 07 '21 09:10 CFlop

The testnet futures need a separate account on https://testnet.binancefuture.com/. After the registration in the chart scroll down to "Positions" etc. There you will find a tab API Key. Try this key for your future trading testnet API.

thank you , i found the API Key and API Secret .

nvdong1108 avatar Nov 27 '21 13:11 nvdong1108