Created
June 19, 2013 06:15
-
-
Save jordanbaucke/5812034 to your computer and use it in GitHub Desktop.
NodeJs example code for Bitfinex API v1 Authenticated call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var https = require('https'); | |
var crypto = require('crypto'); | |
var url = 'https://bitfinex.com/api/v1/balances'; | |
var subPath = '/balances'; | |
var api_key = ''; | |
var api_secret = ''; | |
var path = '/api/v1' + subPath; | |
console.log(path); | |
var payloadObject = { | |
request : path, | |
nonce : "" + Date.now(), | |
options : {} | |
}; | |
var payloadJson = JSON.stringify(payloadObject); | |
console.log(JSON.stringify(payloadObject)); | |
var payload = new Buffer(payloadJson).toString('base64'); | |
console.log(payload); | |
var signature = crypto.createHmac('sha384', api_secret).update(payload).digest('hex'); | |
var headers = { | |
"X-BFX-APIKEY" : api_key, | |
"X-BFX-PAYLOAD" : payload, | |
"X-BFX-SIGNATURE" : signature | |
}; | |
console.log(headers); | |
var options = { | |
hostname : 'bitfinex.com', | |
port : 443, | |
path : '/api/v1/balances', | |
method : 'GET', | |
headers: headers | |
}; | |
var req = https.request(options, function(res) { | |
console.log("statusCode: ", res.statusCode); | |
console.log("headers: ", res.headers); | |
res.on('data', function(d) { | |
process.stdout.write(d); | |
}); | |
}); | |
req.end(); | |
req.on('error', function(e) { | |
console.error(e); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi JB,
I was trying to POST balances from VB.net using below code but getting "404-Not Found" constantly. Can you please assist me finding what I am missing.
Imports System.Net
Imports System.IO
Imports System.Text
Imports System.Web
Imports System.Web.Script.Serialization
Imports System.Security.Cryptography
Public Class Form1
Public Shared api_url As String = "https://bitfinex.com/api"
Public Shared api_key As String = ""
Public Shared api_secret As String = ""
'Public Shared api_path As String = "/v1/symbols"
Public Shared api_path As String = "/v1/balances"
End Class