Dart
Dart
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 Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
final http = 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
final crypt = CkCrypt2();
final apiPath = 'v2/auth/r/info/user';
final apiKey = 'MY_API_KEY';
final apiSecret = 'MY_API_SECRET';
final dt = CkDateTime();
dt.setFromCurrentSystemTime();
final sbNonce = CkStringBuilder();
sbNonce.append(dt.getAsUnixTimeStr(false));
sbNonce.append('000');
final nonce = sbNonce.getAsString();
// This particular request has an empty body.
final body = '';
final sbSignature = CkStringBuilder();
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);
final sig = crypt.macStringENC(sbSignature.getAsString());
http.setRequestHeader('bfx-apikey', apiKey);
http.setRequestHeader('bfx-signature', sig);
http.setRequestHeader('bfx-nonce', nonce);
final resp = CkHttpResponse();
try {
http.httpNoBody('POST', 'https://api.bitfinex.com/v2/auth/r/info/user', resp);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print('Response body:');
print(resp.bodyStr);
// Sample response body:
// [1234567,"joe@example.com","joe_trader",1527691729000,0,null,null,"Central Time (US & Canada)"]
}