index.js
1.31 KB
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
38
39
40
41
42
const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args));
const url = 'https://api.upbit.com/v1/market/all';
const options = { method: 'GET', headers: { Accept: 'application/json' } };
const express=require('express');
const app=express();
async function get_marketName() {
var data=new Array();
//전체 암호화폐 리스트 불러오기
let response= await fetch(url, options)
.then(res => res.json())
.then(json => {
for(i in json){
data.push(json[i].market);
}
})
return data;
}
async function get_marketInfo(name_list){
//각 암호화폐 정보 조회
const url=`https://api.upbit.com/v1/ticker/?markets=${name_list}`;
var arr=new Array();
let response2=await fetch(url,options)
.then(res=>res.json())
.then(json=>{
for(i in json){
if(json[i].acc_trade_price_24h>100000000000){
arr.push([json[i].market,json[i].acc_trade_price_24h,json[i].trade_price]);
}
}
})
return arr;
}
app.get('/get_market',async (req,res)=>{
var name_list=(await get_marketName());
var market_info=(await get_marketInfo(name_list));
res.json(market_info);
})
app.listen(5000,()=>{
console.log('server')
})