배지승

Pull whale_alert

Showing 1 changed file with 33 additions and 0 deletions
1 const express = require('express'); 1 const express = require('express');
2 const app = express(); 2 const app = express();
3 3
4 +const fetch = require('node-fetch');
5 +const api_key = '';//Delete before commit API ddaro bonae jum.
6 +
7 +const url = 'https://api.whale-alert.io/v1/status?api_key=' + api_key;
8 +const options = {method: 'GET', headers: {Accept: 'application/json'}};
9 +
10 +fetch(url, options)
11 + .then(res => res.json())
12 + .then(json => console.log(json))
13 + .catch(err => console.error('error:' + err));
14 +
15 +
16 +const url2 = 'https://api.whale-alert.io/v1/transactions?api_key=' + api_key;
17 +
18 +function data_collector(data){
19 + var ret = '';
20 + var str = '';
21 + for(var i = 0; i < data.transactions.length; i++){
22 + str = '#' + (i+1)+' ChainName: '+data.transactions[i].blockchain+'\tAmount: '+data.transactions[i].amount+' USD'
23 + if(data.transactions[i].amount > 1000000){
24 + str = '=====!WARNING!=====\n</br>' + str + '\n</br>=====!WARNING!====='
25 + console.log(str)
26 + }
27 + else{
28 + console.log(str)
29 + }
30 + ret += '</br>' + str;
31 + }
32 + console.log(data.transactions)
33 + console.log(typeof(data.transactions))
34 + return ret;
35 +}
36 +
4 app.get('/', function (req, res) { 37 app.get('/', function (req, res) {
5 result = "" 38 result = ""
6 if(req.query.hi == "hi"){ 39 if(req.query.hi == "hi"){
......