jaggedsoft / node-binance-api

Node Binance API is an asynchronous node.js library for the Binance API designed to be easy to use.
MIT License
1.57k stars 767 forks source link

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

Open hammadhere7 opened 3 years ago

hammadhere7 commented 3 years ago

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

sand3r commented 3 years ago

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.

CFlop commented 2 years ago

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.

nvdong1108 commented 2 years ago

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 .