Skip to content

Instantly share code, notes, and snippets.

@levity
Created March 24, 2017 19:49
Show Gist options
  • Save levity/68184191145e1fcc8b4b13a3931a063f to your computer and use it in GitHub Desktop.
Save levity/68184191145e1fcc8b4b13a3931a063f to your computer and use it in GitHub Desktop.
const request = require('request')
const crypto = require('crypto')
const url = 'https://api.bitfinex.com/v1'
const apiKey = '<Your API key here>'
const apiSecret = '<Your API secret here>'
const payload = {
'request': '/v1/account_infos',
'nonce': Date.now().toString()
}
const body = new Buffer(JSON.stringify(payload))
.toString('base64')
const signature = crypto
.createHmac('sha384', apiSecret)
.update(body)
.digest('hex')
const headers = {
'X-BFX-APIKEY': apiKey,
'X-BFX-PAYLOAD': body,
'X-BFX-SIGNATURE': signature
}
const options = {
url: `${url}/account_infos`,
headers,
body
}
request.post(options, (error, response, body) => console.log(body))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment