qowltmd

Whale_Alert

This diff is collapsed. Click to expand it.
{
"name": "coin-trade-assistant",
"version": "1.0.0",
"description": "",
"main": "test.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "http://khuhub.khu.ac.kr/2018102235/Coin-trade-assistant.git"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"node-fetch": "^2.6.1"
}
}
const express = require('express');
const app = express();
const fetch = require('node-fetch');
const api_key = '4h4PrjdPl04aplYHbM5xUK1xoGPffEfE';//Delete before commit API ddaro bonae jum.
const url = 'https://api.whale-alert.io/v1/status?api_key=' + api_key;
const options = {method: 'GET', headers: {Accept: 'application/json'}};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error('error:' + err));
const url2 = 'https://api.whale-alert.io/v1/transactions?api_key=' + api_key;
function data_collector(data){
var ret = '';
var str = '';
for(var i = 0; i < data.transactions.length; i++){
str = '#' + (i+1)+' ChainName: '+data.transactions[i].blockchain+'\tAmount: '+data.transactions[i].amount+' USD'
if(data.transactions[i].amount > 1000000){
str = '=====!WARNING!=====\n</br>' + str + '\n</br>=====!WARNING!====='
console.log(str)
}
else{
console.log(str)
}
ret += '</br>' + str;
}
console.log(data.transactions)
console.log(typeof(data.transactions))
return ret;
}
app.get('/', function (req, res) {
fetch(url2, options)
.then(res => res.json())
.then(json => res.send(data_collector(json)))
.catch(err => console.error('error:' + err));
})
var server = app.listen(23023)
\ No newline at end of file