Toggle navigation
Toggle navigation
This project
Loading...
Sign in
정홍주
/
Coin-trade-assistant
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
배지승
2021-06-04 19:25:23 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e0428e1f39ec5bb252ccd3b859ec342f2264239d
e0428e1f
1 parent
739fbf25
최솟값 parameter 추가
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
0 deletions
.gitignore
app.js
.gitignore
0 → 100644
View file @
e0428e1
/node_modules
apikey
test.js
README.md
\ No newline at end of file
app.js
0 → 100644
View file @
e0428e1
const
express
=
require
(
'express'
);
const
app
=
express
();
const
fetch
=
require
(
'node-fetch'
);
const
fs
=
require
(
'fs'
)
const
api_key
=
fs
.
readFileSync
(
'apikey'
,
'ascii'
)
console
.
log
(
'apikey:'
,
api_key
)
//const url = 'https://api.whale-alert.io/v1/status?api_key=' + api_key;
const
options
=
{
method
:
'GET'
,
headers
:
{
Accept
:
'application/json'
}};
cursor
=
''
const
url2
=
'https://api.whale-alert.io/v1/transactions?api_key='
+
api_key
;
// fetch(url, options)
// .then(res => res.json())
// .then(json => console.log(json))
// .catch(err => console.error('error:' + err));
function
chk_param
(
data
,
query_limit
,
callback
){
//query_limit (non_int) => return 0;
//query_limit (int) => return query_limit;
query_limit
=
parseInt
(
query_limit
)
if
(
isNaN
(
query_limit
)){
return
callback
(
data
,
0
)}
else
{
return
callback
(
data
,
query_limit
)}
}
function
data_collector
(
data
,
limit
){
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
>
limit
){
//console.log(str)
ret
+=
'</br>'
+
str
;
}
else
{
//console.log(str)
}
}
return
ret
;
}
app
.
get
(
'/'
,
function
(
req
,
res
)
{
fu
=
fetch
(
url2
,
options
);
fu
.
then
(
res
=>
res
.
json
())
.
then
(
json
=>
{
//API usage limit
console
.
log
(
json
)
if
(
json
.
result
==
'error'
){
res
.
send
(
"Please try later"
)
}
else
{
res
.
send
(
chk_param
(
json
,
req
.
query
.
limit
,
data_collector
))
}
})
.
catch
(
err
=>
console
.
error
(
'error:'
+
err
))
})
var
server
=
app
.
listen
(
23023
)
\ No newline at end of file
Please
register
or
login
to post a comment