Last active
April 20, 2020 08:08
-
-
Save prdn/711aef306ad6d6de500b48da08ff0196 to your computer and use it in GitHub Desktop.
bfx-pulse-rest-v2-del.js
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
/* | |
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