-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.js
38 lines (30 loc) · 1.04 KB
/
api.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const express = require('express');
const server = express();
const axios = require('axios');
server.set('port', 9000);
server.use(express.static(__dirname + '/dist/ohlc'));
server.use(express.json())
server.listen(server.get('port'), function () {
console.log('Express server listening on port ' + server.get('port'));
});
server.get('/api/getCandles', (req, res) => {
let param = req.query;
axios.get('https://api-pub.bitfinex.com/v2/candles/trade%3A' + param.timeFrame + '%3A'+ param.symbol + '/hist')
.then(function (response) {
res.send(response.data)
})
.catch(function (error) {
console.log(error);
res.json({error: "Technical Error"});
})
})
server.get('/api/getAllSymbols', (req, res) => {
axios.get('https://api-pub.bitfinex.com/v2/tickers?symbols=ALL')
.then(function (response) {
res.send(response.data)
})
.catch(function (error) {
console.log(error);
res.json({error: "Technical Error"});
})
})