Created
November 1, 2019 14:25
-
-
Save prdn/bfcfffbbe8759047694d2ab6c04ce898 to your computer and use it in GitHub Desktop.
bfx-rest-notify-mobile.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
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