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
(Swift 3,4,5...) 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
func chilkatTest() { // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. let http = CkoHttp()! var success: Bool // 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 let crypt = CkoCrypt2()! var apiPath: String? = "v2/auth/r/info/user" var apiKey: String? = "MY_API_KEY" var apiSecret: String? = "MY_API_SECRET" let dt = CkoDateTime()! dt.setFromCurrentSystemTime() let sbNonce = CkoStringBuilder()! sbNonce.append(dt.getAsUnixTimeStr(false)) sbNonce.append("000") var nonce: String? = sbNonce.getAsString() // This particular request has an empty body. var body: String? = "" let sbSignature = CkoStringBuilder()! 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) var sig: String? = crypt.macStringENC(sbSignature.getAsString()) http.setRequestHeader("bfx-apikey", value: apiKey) http.setRequestHeader("bfx-signature", value: sig) http.setRequestHeader("bfx-nonce", value: nonce) var resp: CkoHttpResponse? = http.quickRequest("POST", url: "https://api.bitfinex.com/v2/auth/r/info/user") if http.lastMethodSuccess == false { print("\(http.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)"] } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.