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.58k stars 768 forks source link

Support of Binance test network #527

Open pdwinkel opened 3 years ago

pdwinkel commented 3 years ago

Is it possible to use/set the Binance test network https://testnet.binance.vision ?

dawadam commented 3 years ago

I think it's possible by using 'test' parametter on options.

    const default_options = {
        recvWindow: 5000,
        useServerTime: false,
        reconnect: true,
        keepAlive: true,
        verbose: false,
        test: false,
        hedgeMode: false,
        localAddress: false,
        family: false,
        log: function ( ...args ) {
            console.log( Array.prototype.slice.call( args ) );
        }
    };

Like this :

const binance = new Binance().options({
  APIKEY: '<key>',
  APISECRET: '<secret>',
  test: true
});

But it seem make error when a request is maked.

jaggedsoft commented 3 years ago

Try setting base: 'https://testnet.binance.vision' in the options should do this automatically if test mode is on, this feature was finally released

pdwinkel commented 3 years ago

I'm using the following options, which seem to work for testing spot trading:

      {
         verbose: true,
         urls: {
            base: 'https://testnet.binance.vision/api/',
            combineStream: 'wss://testnet.binance.vision/stream?streams=',
            stream: 'wss://testnet.binance.vision/ws/'
         }
      }

watch the / and = at the end of the strings!

jaggedsoft commented 3 years ago

thank you, this is very helpful. it should be easy enough for us to enable this automatically if test mode is true and the other options are set to the defaults.

sinamhbb commented 3 years ago

Hello team,

This is my Options:

const binance = new Binance().options({ APIKEY: testnet_APIKEY, APISECRET: testnet_APISECRET, test: true, base: "https://testnet.binance.vision/api" })

But I get: code: -2015, msg: 'Invalid API-key, IP, or permissions for action, request ip: 80.235.34.109'

Can Somebody help me to understand what is going on? I checked the API key and secret as well but they are correct. Thanks

iyenal commented 3 years ago

Same issue. I have tried tweaking too the principal script, to no avail.

iyenal commented 3 years ago

Nevermind, @sinamhbb use @pdwinkel options without test: true, in your case, as it overwrites the custom URLs configuration.