Am having a problem with Bitstamp API, am getting this error
Error: {“status”: “error”, “reason”: “Invalid signature”, “code”: “API0005”}
Reference API Link: https://www.bitstamp.net/api/
API Examples: https://www.bitstamp.net/api/#section/Authentication/Authentication-examples
Below is my script, i dont know where the problem comes from
#!/usr/bin/perl
use strict;
use warnings;
use URI qw();
use Time::HiRes qw(gettimeofday);
use Digest::SHA qw(hmac_sha256_hex);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 }, );
$ua->agent("MyApp/0.1");
my $apiKey = 'BITSTAMP XXXXXXYv2yx2bQPXSh2XXXXX';
my $apiSecret = 'LLLLLSSS13aJJJJJNuYXQQQQQQQ';
my $urlcb = "https://www.bitstamp.net";
my $url = URI->new($urlcb);
my $urlpath = $url->path('/api/v2/eth_withdrawal/');
my @set = ('0' ..'9', 'a' .. 'f');
my $nonce = join '' => map $set[rand @set], 1 .. 36;
my $timestamp = int (gettimeofday * 1000);
my $Query = URI->new();
$Query->query_form(
'currency' => "ETH",
'network' => "ethereum",
'address' => "",
'amount' => "5"
);
my $API_Version = 'v2';
my $ContentType = "application/x-www-form-urlencoded";
my $msg = $apiKey.'POST'.$urlcb.$urlpath.$ContentType.$nonce.$timestamp.$API_Version.$Query, $apiSecret;
my $signature = hmac_sha256_hex($msg, $apiSecret);
my %payload = (
"X-Auth" => $apiKey,
"X-Auth-Signature" => $signature,
"X-Auth-Nonce" => $nonce,
"X-Auth-Timestamp" => $timestamp,
"X-Auth-Version" => $API_Version,
"Content-Type" => $ContentType
);
my $req = HTTP::Request->new(POST=>$url);
$req->header(%payload);
$req->content($Query);
my $resp = $ua->request($req);
print "Content-type: text/htmlnn";
if($resp->is_success){
print $resp->content ."n";
}
else{
print "Error: " . $resp->content;
}
New contributor
Frank is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.