Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oCrypt
LOCAL cApiPath
LOCAL cApiKey
LOCAL cApiSecret
LOCAL oDt
LOCAL oSbNonce
LOCAL cNonce
LOCAL cBody
LOCAL oSbSignature
LOCAL cSig
LOCAL oResp

nSuccess := 0

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

oHttp := CreateObject("Chilkat.Http")

//  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

oCrypt := CreateObject("Chilkat.Crypt2")

cApiPath := "v2/auth/r/info/user"
cApiKey := "MY_API_KEY"
cApiSecret := "MY_API_SECRET"

oDt := CreateObject("Chilkat.CkDateTime")
oDt:SetFromCurrentSystemTime()

oSbNonce := CreateObject("Chilkat.StringBuilder")
oSbNonce:Append(oDt:GetAsUnixTimeStr(0))
oSbNonce:Append("000")
cNonce := oSbNonce:GetAsString()

//  This particular request has an empty body.
cBody := ""

oSbSignature := CreateObject("Chilkat.StringBuilder")
oSbSignature:Append("/api/")
oSbSignature:Append(cApiPath)
oSbSignature:Append(cNonce)
oSbSignature:Append(cBody)

oCrypt:EncodingMode := "hex_lower"
oCrypt:HashAlgorithm := "sha384"
oCrypt:MacAlgorithm := "hmac"
oCrypt:SetMacKeyString(cApiSecret)

cSig := oCrypt:MacStringENC(oSbSignature:GetAsString())

oHttp:SetRequestHeader("bfx-apikey", cApiKey)
oHttp:SetRequestHeader("bfx-signature", cSig)
oHttp:SetRequestHeader("bfx-nonce", cNonce)

oResp := CreateObject("Chilkat.HttpResponse")
nSuccess := oHttp:HttpNoBody("POST", "https://api.bitfinex.com/v2/auth/r/info/user", oResp)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oCrypt:destroy()
    oDt:destroy()
    oSbNonce:destroy()
    oSbSignature:destroy()
    oResp:destroy()
    RETURN
ENDIF

? "Response body:"
? oResp:BodyStr

//  Sample response body:

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

oHttp:destroy()
oCrypt:destroy()
oDt:destroy()
oSbNonce:destroy()
oSbSignature:destroy()
oResp:destroy()