-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbithumb_price.js
29 lines (23 loc) · 1.01 KB
/
bithumb_price.js
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
import axios from 'axios';
export async function BithumbfetchPriceData() {
const options = {
method: 'GET',
url: 'https://api.bithumb.com/public/orderbook/EL_KRW',
headers: {accept: 'application/json'}
};
try {
const response = await axios.request(options);
const bids_price = response.data.data.bids[0]['price'];
const bids_quantity = response.data.data.bids[0]['quantity'];
const asks_price = response.data.data.asks[0]['price'];
const asks_quantity = response.data.data.asks[0]['quantity'];
// const currentTime = new Date().toLocaleString();
return { bids_price , asks_price };
// console.log(`[${currentTime}] Bids price: ${bids_price} / Volume: ${bids_price * bids_quantity}`);
// console.log(`[${currentTime}] Asks price: ${asks_price} / Volume: ${asks_price * asks_quantity}`);
} catch (error) {
console.error(error);
}
}
// Call the function every second
// setInterval(fetchPriceData, 1000);