Unicode C++
Unicode C++
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 Unicode C++ Downloads
#include <CkHttpW.h>
#include <CkCrypt2W.h>
#include <CkDateTimeW.h>
#include <CkStringBuilderW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
bool success = false;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttpW 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
CkCrypt2W crypt;
const wchar_t *apiPath = L"v2/auth/r/info/user";
const wchar_t *apiKey = L"MY_API_KEY";
const wchar_t *apiSecret = L"MY_API_SECRET";
CkDateTimeW dt;
dt.SetFromCurrentSystemTime();
CkStringBuilderW sbNonce;
sbNonce.Append(dt.getAsUnixTimeStr(false));
sbNonce.Append(L"000");
const wchar_t *nonce = sbNonce.getAsString();
// This particular request has an empty body.
const wchar_t *body = L"";
CkStringBuilderW sbSignature;
sbSignature.Append(L"/api/");
sbSignature.Append(apiPath);
sbSignature.Append(nonce);
sbSignature.Append(body);
crypt.put_EncodingMode(L"hex_lower");
crypt.put_HashAlgorithm(L"sha384");
crypt.put_MacAlgorithm(L"hmac");
crypt.SetMacKeyString(apiSecret);
const wchar_t *sig = crypt.macStringENC(sbSignature.getAsString());
http.SetRequestHeader(L"bfx-apikey",apiKey);
http.SetRequestHeader(L"bfx-signature",sig);
http.SetRequestHeader(L"bfx-nonce",nonce);
CkHttpResponseW resp;
success = http.HttpNoBody(L"POST",L"https://api.bitfinex.com/v2/auth/r/info/user",resp);
if (success == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
wprintf(L"Response body:\n");
wprintf(L"%s\n",resp.bodyStr());
// Sample response body:
// [1234567,"joe@example.com","joe_trader",1527691729000,0,null,null,"Central Time (US & Canada)"]
}