Skip to content

Instantly share code, notes, and snippets.

@kremalicious
Last active June 11, 2017 21:51
Show Gist options
  • Save kremalicious/0100395fc90269a43fe4378f3b42be21 to your computer and use it in GitHub Desktop.
Save kremalicious/0100395fc90269a43fe4378f3b42be21 to your computer and use it in GitHub Desktop.
Get wallets in CoinsBank with Node.js
const crypto = require('crypto')
const fetch = require('node-fetch')
const key = process.env.COINSBANK_API_KEY
const secret = process.env.COINSBANK_API_SECRET
const type = 'GET'
const method = 'wallet'
// Create signature
const hmac = crypto.createHmac('sha512', secret)
hmac.update('_key=' + key + '&_method=' + method + '&_type=' + type)
const signature = hmac.digest('hex')
// Get wallets
fetch(url + method, {
method: type,
headers: {
'Content-Type': 'application/json',
Key: key,
Signature: signature
}
})
.then(res => {
if (res.status !== 200) {
return console.log('Non-200 response: ' + res.status)
}
return res.json()
})
.then(data_ => {
if (!data_) {
return
}
console.log(data_)
})
.catch(err => {
console.log('Error parsing json:' + err)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment