Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Delphi DLL) Bitfinex v2 REST User InfoRetrieve the user ID, email, username and timezone setting for the account associated with the API key used. For more information, see https://docs.bitfinex.com/reference#rest-auth-info-user
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Http, StringBuilder, HttpResponse, CkDateTime, Crypt2; ... procedure TForm1.Button1Click(Sender: TObject); var http: HCkHttp; success: Boolean; crypt: HCkCrypt2; apiPath: PWideChar; apiKey: PWideChar; apiSecret: PWideChar; dt: HCkDateTime; sbNonce: HCkStringBuilder; nonce: PWideChar; body: PWideChar; sbSignature: HCkStringBuilder; sig: PWideChar; resp: HCkHttpResponse; begin // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http := CkHttp_Create(); // 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 crypt := CkCrypt2_Create(); apiPath := 'v2/auth/r/info/user'; apiKey := 'MY_API_KEY'; apiSecret := 'MY_API_SECRET'; dt := CkDateTime_Create(); CkDateTime_SetFromCurrentSystemTime(dt); sbNonce := CkStringBuilder_Create(); CkStringBuilder_Append(sbNonce,CkDateTime__getAsUnixTimeStr(dt,False)); CkStringBuilder_Append(sbNonce,'000'); nonce := CkStringBuilder__getAsString(sbNonce); // This particular request has an empty body. body := ''; sbSignature := CkStringBuilder_Create(); CkStringBuilder_Append(sbSignature,'/api/'); CkStringBuilder_Append(sbSignature,apiPath); CkStringBuilder_Append(sbSignature,nonce); CkStringBuilder_Append(sbSignature,body); CkCrypt2_putEncodingMode(crypt,'hex_lower'); CkCrypt2_putHashAlgorithm(crypt,'sha384'); CkCrypt2_putMacAlgorithm(crypt,'hmac'); CkCrypt2_SetMacKeyString(crypt,apiSecret); 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); resp := CkHttp_QuickRequest(http,'POST','https://api.bitfinex.com/v2/auth/r/info/user'); if (CkHttp_getLastMethodSuccess(http) = False) then begin Memo1.Lines.Add(CkHttp__lastErrorText(http)); Exit; end; Memo1.Lines.Add('Response body:'); Memo1.Lines.Add(CkHttpResponse__bodyStr(resp)); // Sample response body: // [1234567,"joe@example.com","joe_trader",1527691729000,0,null,null,"Central Time (US & Canada)"] CkHttp_Dispose(http); CkCrypt2_Dispose(crypt); CkDateTime_Dispose(dt); CkStringBuilder_Dispose(sbNonce); CkStringBuilder_Dispose(sbSignature); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.