June

Get market list & info

Showing 1 changed file with 28 additions and 9 deletions
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 test() {
async function get_marketName() {
var data=new Array();
//전체 암호화폐 리스트 불러오기
let response= await fetch(url, options)
.then(res => res.json())
.then(json => {
console.log(json);
console.log(json.length);
return json;
for(i in json){
data.push(json[i].market);
}
})
var hello=await (await fetch(url,options)).json();
return hello;
return data;
}
app.get('/fetch_test',async (req,res)=>{
res.json(await test());
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')
......