React Native
React Native
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 React Native Downloads
import { CkDateTime, Crypt2, Http, HttpResponse, StringBuilder } from '@chilkat/react-native'
async function chilkatExample() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = new 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
const crypt = new Crypt2();
const apiPath = 'v2/auth/r/info/user';
const apiKey = 'MY_API_KEY';
const apiSecret = 'MY_API_SECRET';
const dt = new CkDateTime();
dt.setFromCurrentSystemTime();
const sbNonce = new StringBuilder();
sbNonce.append(dt.getAsUnixTimeStr(false));
sbNonce.append('000');
const nonce = sbNonce.getAsString();
// This particular request has an empty body.
const body = '';
const sbSignature = new StringBuilder();
sbSignature.append('/api/');
sbSignature.append(apiPath);
sbSignature.append(nonce);
sbSignature.append(body);
crypt.encodingMode = 'hex_lower';
crypt.hashAlgorithm = 'sha384';
crypt.macAlgorithm = 'hmac';
crypt.setMacKeyString(apiSecret);
const sig = crypt.macStringENC(sbSignature.getAsString());
http.setRequestHeader('bfx-apikey', apiKey);
http.setRequestHeader('bfx-signature', sig);
http.setRequestHeader('bfx-nonce', nonce);
const resp = new HttpResponse();
try {
await http.httpNoBodyAsync('POST', 'https://api.bitfinex.com/v2/auth/r/info/user', resp);
} catch {
console.log(http.lastErrorText);
return;
}
console.log('Response body:');
console.log(resp.bodyStr);
// Sample response body:
// [1234567,"joe@example.com","joe_trader",1527691729000,0,null,null,"Central Time (US & Canada)"]
}