efx-api-node
Version:
<img src="https://avatars3.githubusercontent.com/u/33315316?s=200&v=4" align="right" />
26 lines (18 loc) • 588 B
JavaScript
/**
* Requests candle from Bitfinex.
*/
const { get } = require('request-promise')
// TODO: move address to either /r/get/conf or to ENV variables
const BFX_API = 'https://api.deversifi.com/bfx/v2/'
module.exports = async (token, timestamp, timeframe) => {
const symbol = `t${token}USD`
let url = ''
url += `${BFX_API}candles/trade:${timeframe}:${symbol}`
url += `/hist?limit=1&end=${timestamp}`
candle = await get(url, { json: true })
// ~ candle data
// const date = new Date(candle[0][0])
// console.log("date ->", date)
candle = candle[0]
return candle
}