Sample code for 30+ languages & platforms
Rust

Bitfinex v2 REST User Info

See more Bitfinex v2 REST Examples

Retrieve the user ID, email, username and timezone setting for the account associated with the API key used.

Chilkat Rust Downloads

Rust

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

let http = chilkat::Http::new();

// Implements the following CURL command:

// curl -X POST -H "bfx-nonce: nonce" \
//   -H "bfx-apikey: apiKey" \
//   -H "bfx-signature: sig" \ 
//   https://api.bitfinex.com/v2/auth/r/info/user

// Use the following online tool to generate HTTP code from a CURL command
// Convert a cURL Command to HTTP Source Code

let crypt = chilkat::Crypt2::new();

let api_path = "v2/auth/r/info/user".to_string();
let api_key = "MY_API_KEY".to_string();
let api_secret = "MY_API_SECRET".to_string();

let dt = chilkat::DateTime::new();
let _ = dt.set_from_current_system_time();

let sb_nonce = chilkat::StringBuilder::new();
let _ = sb_nonce.append(&dt.get_as_unix_time_str(false).unwrap_or_default());
let _ = sb_nonce.append("000");
let nonce = sb_nonce.get_as_string().unwrap_or_default();

// This particular request has an empty body.
let body = String::new();

let sb_signature = chilkat::StringBuilder::new();
let _ = sb_signature.append("/api/");
let _ = sb_signature.append(&api_path);
let _ = sb_signature.append(&nonce);
let _ = sb_signature.append(&body);

crypt.set_encoding_mode("hex_lower");
crypt.set_hash_algorithm("sha384");
crypt.set_mac_algorithm("hmac");
let _ = crypt.set_mac_key_string(&api_secret);

let sig = crypt.mac_string_enc(&sb_signature.get_as_string().unwrap_or_default()).unwrap_or_default();

http.set_request_header("bfx-apikey", &api_key);
http.set_request_header("bfx-signature", &sig);
http.set_request_header("bfx-nonce", &nonce);

let resp = chilkat::HttpResponse::new();
if http.http_no_body("POST", "https://api.bitfinex.com/v2/auth/r/info/user", &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

println!("Response body:");
println!("{}", resp.body_str());

// Sample response body:

// [1234567,"joe@example.com","joe_trader",1527691729000,0,null,null,"Central Time (US & Canada)"]