Lua
Lua
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 Lua Downloads
local chilkat = require("chilkat")
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local http = chilkat.Http.new()
-- 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
local crypt = chilkat.Crypt2.new()
local apiPath = "v2/auth/r/info/user"
local apiKey = "MY_API_KEY"
local apiSecret = "MY_API_SECRET"
local dt = chilkat.DateTime.new()
dt:set_from_current_system_time()
local sbNonce = chilkat.StringBuilder.new()
sbNonce:append(dt:get_as_unix_time_str(false))
sbNonce:append("000")
local nonce = sbNonce:get_as_string()
-- This particular request has an empty body.
local body = ""
local sbSignature = chilkat.StringBuilder.new()
sbSignature:append("/api/")
sbSignature:append(apiPath)
sbSignature:append(nonce)
sbSignature:append(body)
crypt.encoding_mode = "hex_lower"
crypt.hash_algorithm = "sha384"
crypt.mac_algorithm = "hmac"
crypt:set_mac_key_string(apiSecret)
local sig = crypt:mac_string_enc(sbSignature:get_as_string())
http:set_request_header("bfx-apikey", apiKey)
http:set_request_header("bfx-signature", sig)
http:set_request_header("bfx-nonce", nonce)
local resp = chilkat.HttpResponse.new()
local success = http:http_no_body("POST", "https://api.bitfinex.com/v2/auth/r/info/user", resp)
if not success then
print(http.last_error_text)
return
end
print("Response body:")
print(resp.body_str)
-- Sample response body:
-- [1234567,"joe@example.com","joe_trader",1527691729000,0,null,null,"Central Time (US & Canada)"]