Skip to content

Instantly share code, notes, and snippets.

@prdn
Created November 1, 2019 14:25
Show Gist options
  • Save prdn/bfcfffbbe8759047694d2ab6c04ce898 to your computer and use it in GitHub Desktop.
Save prdn/bfcfffbbe8759047694d2ab6c04ce898 to your computer and use it in GitHub Desktop.
bfx-rest-notify-mobile.js
const fs = require('fs')
const crypto = require('crypto')
const request = require('request')
const apiKey = '...'
const apiSecret = '...'
const url = 'v2/auth/w/expo/notify'
const nonce = (Date.now() * 1000).toString()
const body = {
payload: {
title: 'Bitfinex is f**king awesome',
body: 'BTC to the mooon!'
}
}
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, (error, response, body) => console.log(body))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment