Tcl
Tcl
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 Tcl Downloads
load ./chilkat.dll
set success 0
# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set http [new_CkHttp]
# 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
set crypt [new_CkCrypt2]
set apiPath "v2/auth/r/info/user"
set apiKey "MY_API_KEY"
set apiSecret "MY_API_SECRET"
set dt [new_CkDateTime]
CkDateTime_SetFromCurrentSystemTime $dt
set sbNonce [new_CkStringBuilder]
CkStringBuilder_Append $sbNonce [CkDateTime_getAsUnixTimeStr $dt 0]
CkStringBuilder_Append $sbNonce "000"
set nonce [CkStringBuilder_getAsString $sbNonce]
# This particular request has an empty body.
set body ""
set sbSignature [new_CkStringBuilder]
CkStringBuilder_Append $sbSignature "/api/"
CkStringBuilder_Append $sbSignature $apiPath
CkStringBuilder_Append $sbSignature $nonce
CkStringBuilder_Append $sbSignature $body
CkCrypt2_put_EncodingMode $crypt "hex_lower"
CkCrypt2_put_HashAlgorithm $crypt "sha384"
CkCrypt2_put_MacAlgorithm $crypt "hmac"
CkCrypt2_SetMacKeyString $crypt $apiSecret
set sig [CkCrypt2_macStringENC $crypt [CkStringBuilder_getAsString $sbSignature]]
CkHttp_SetRequestHeader $http "bfx-apikey" $apiKey
CkHttp_SetRequestHeader $http "bfx-signature" $sig
CkHttp_SetRequestHeader $http "bfx-nonce" $nonce
set resp [new_CkHttpResponse]
set success [CkHttp_HttpNoBody $http "POST" "https://api.bitfinex.com/v2/auth/r/info/user" $resp]
if {$success == 0} then {
puts [CkHttp_lastErrorText $http]
delete_CkHttp $http
delete_CkCrypt2 $crypt
delete_CkDateTime $dt
delete_CkStringBuilder $sbNonce
delete_CkStringBuilder $sbSignature
delete_CkHttpResponse $resp
exit
}
puts "Response body:"
puts [CkHttpResponse_bodyStr $resp]
# Sample response body:
# [1234567,"joe@example.com","joe_trader",1527691729000,0,null,null,"Central Time (US & Canada)"]
delete_CkHttp $http
delete_CkCrypt2 $crypt
delete_CkDateTime $dt
delete_CkStringBuilder $sbNonce
delete_CkStringBuilder $sbSignature
delete_CkHttpResponse $resp