Reputation: 19
In Bitstamp's API documentation, a client_id is mentioned. It is used to generate a signature. https://www.bitstamp.net/api/
But I couldn't find how I can get that client_id.
Any hint on that? Many thanks.
Upvotes: 0
Views: 1982
Reputation: 139
The page where you change password on Bitstamp presents you your client id (contains letters and digits).
Upvotes: 0
Reputation: 5270
Use this code to get idea. This is Ruby code
require 'open-uri'
require 'json'
require 'base64'
require 'openssl'
require 'hmac-sha2'
require 'net/http'
require 'net/https'
require 'uri'
def bitstamp_private_request(method, attrs = {})
secret = "xxx"
key = "xxx"
client_id = "xxx"
nonce = nonce_generator
message = nonce + client_id + key
signature = HMAC::SHA256.hexdigest(secret, message).upcase
url = URI.parse("https://www.bitstamp.net/api/#{method}/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
data = {
nonce: nonce,
key: key,
signature: signature
}
data.merge!(attrs)
data = data.map { |k,v| "#{k}=#{v}"}.join('&')
headers = {
'Content-Type' => 'application/x-www-form-urlencoded'
}
resp = http.post(url.path, data, headers)
console_log "https://www.bitstamp.net/api/#{method}/"
resp.body
end
def nonce_generator
(Time.now.to_f*1000).to_i.to_s
end
Upvotes: 0
Reputation: 1
I have some probelm with bitstamp api
below is my code php
$message = $nonce.$client_id.$api_key;
$signature = strtoupper(hash_hmac('sha256', $message, $secret_key));
$post_string = 'api_key='.$api_key.'&signature='.$signature.'&nonce='.$nonce;
$url = "https://www.bitstamp.net/api/balance/";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 4);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
$json = curl_exec($ch);
if(!$json) {
echo curl_error($ch);
}
curl_close($ch);
$tempData = json_decode($json);
print_r($tempData);<br>
Output:
stdClass Object ( [error] => Missing key, signature and nonce parameters )
Upvotes: -2
Reputation: 1636
Did you register for an API key via their instructions? They say:
To get an API key, go to "Account", "Security" and then "API Access". Set permissions and click "Generate key".`
Once you have the API key, you use a HMAC encoded of the API key, API secret, and your customer/client id. You should be able to get your client id by going to the "Account Balance" page, where I believe it's referred to as your "Customer ID".
Upvotes: 3