-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
72 lines (64 loc) · 2.41 KB
/
index.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const axios = require('axios');
const express = require('express');
const app = express();
const port = 3999;
const array = require('./itemlist')
let interval
let i = 0
const itemList = array.map((e) => {
return e.nama;
});
const itemNama = array.map((e) => {
return e.value;
});
const getItems = async () => {
axios.get(`https://west.albion-online-data.com/api/v2/stats/prices/${itemList[i]}.json?locations=caerleon,blackmarket&qualities=0`)
.then(response => {
const data = response?.data;
const filters = data?.filter(f =>
f.sell_price_min > 0 &&
f.sell_price_max > 0 &&
f.buy_price_min > 0 &&
f.buy_price_max > 0
)
const filteredData = filters.filter((item, index) => {
return filters.some((otherItem, otherIndex) => {
return otherIndex !== index && otherItem.quality === item.quality;
});
});
const caerleon = filteredData?.filter(f => f.city === 'Caerleon');
const blackmarket = filteredData?.filter(f => f.city === 'Black Market');
const caerleonIncludeTax = caerleon?.map(get => {
return {
...get,
sell_price_min: get?.sell_price_min + parseInt(get?.sell_price_min * 0.09)
}
})
if (blackmarket?.buy_price_min > caerleonIncludeTax?.sell_price_min) {
console.log(caerleonIncludeTax);
}
i = i + 1
console.log(i)
})
.catch(error => {
console.error('Error fetching data:', error);
});
}
setInterval(getItems, 1000);
//https://west.albion-online-data.com/api/v2/stats/prices/T4_BAG.json?locations=Caerleon,BLACKMARKET&qualities=0
// app.get('/api', (req, res) => {
// axios.get('https://raw.githubusercontent.com/ao-data/ao-bin-dumps/master/formatted/items.json')
// .then(response => {
// const data = response?.data;
// res.json(data);
// console.log(data['UniqueName'])
// })
// .catch(error => {
// console.error('Error fetching data:', error);
// res.status(500).json({ error: 'Something went wrong' });
// });
// });
// Start the server
app.listen(port, () => {
console.log(`Server is running on http://localhost:${port}`);
});