Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bfx-pulse-rest-v2-del.js
/*
INSTALL DEPENDENCIES:
$ npm install request
CONFIGURE:
set `apiKey` and `apiSecret` variables
RUN:
node bfx-pulse-rest-v2-del.js
*/
const fs = require('fs')
const crypto = require('crypto')
const request = require('request')
const apiKey = '...'
const apiSecret = '...
const url = 'v2/auth/w/pulse/del'
const nonce = (Date.now() * 1000).toString()
const body = {
pid: '...' // id of the pulse you want to delete
}
const rawBody = JSON.stringify(body)
let signature = `/api/${url}${nonce}${rawBody}`
signature = crypto
.createHmac('sha384', apiSecret)
.update(signature)
.digest('hex')
const options = {
url: `https://api.bitfinex.com/${url}`,
headers: {
'bfx-nonce': nonce,
'bfx-apikey': apiKey,
'bfx-signature': signature
},
json: body
}
request.post(options, (err, response, data) => {
if (err) {
return console.error(err)
}
console.log(data)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment