Binance::API: can't connect to the exchange

Viewed 875

I'm an algo-trader and Perl fan. I want to create a client which connects to Binance Future Testnet and i decided to exploit the Binance API module developed for Perl.

Once the Binance::API module was installed (no errors or warnings occurred there) i dived into my script first lines of code as follows:

#!/bin/perl 

use Binance::API;

#API di Binance-Testnet
my $api = Binance::API->new(
    apiKey    => 'my api',
    secretKey => 'my secret key',
);
 
$api->account(); 
$api->exchange_info(); 

API KEY and SECRET KEY are taken from my Binance Future Testnet Account (freely available for all users), succesfully used via tradingview and its Pine script tool.

Unfortunatly i got the following error:

[Binance::API::Request::_exec] Unsuccessful request.
Status => 401,
Content => {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."} at C:/Strawberry/perl/site/lib/Binance/API/Request.pm line 107.
[Binance::API::Request::_exec] Unsuccessful request.
Status => 404,
Content => <html><body><h2>404 Not found</h2></body></html> at C:/Strawberry/perl/site/lib/Binance/API/Request.pm line 107.

Any idea on what went wrong with this? I don't want to use Python or C++ as I love Perl and its versatility.

2 Answers

I think you may get confused with spot and futures. There are 4 different base URL for different markets:

  1. Spot Production site: https://api.binance.com
  2. Spot Testnet site: https://testnet.binance.vision
  3. Futures Production site: https://fapi.binance.com
  4. Futures Testnet site: https://testnet.binancefuture.com
Related