Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36";
- function _jsonGet(url) {
- let response = UrlFetchApp.fetch(url, {
- "headers": {
- "User-Agent": UA
- },
- "muteHttpExceptions": true
- });
- let status = response.getResponseCode();
- Logger.log(`Url: ${url} status=${status}`);
- if (status !== 200) {
- return null;
- } else {
- var rsp = response.getContentText();
- return JSON.parse(rsp);
- }
- }
- function getBisqPrice(a, b) {
- const Day = 60 * 60 * 24;
- let now = new Date().getTime() / 1000.0;
- let today = now - (now % Day);
- let json = _jsonGet(`https://bisq.markets/api/hloc?market=${a.toLowerCase()}_${b.toLowerCase()}&interval=day×tamp_from=${today}`);
- if (json !== null) {
- return json[0].avg;
- } else {
- return -0.0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment