
如果沒有要下單交易,只是單純看看買賣價,串接MAX API 似乎不是很困難,只要參考MAX API的文件 即可。
「bot.學習.人」只是想查詢一下最近的買賣價,所以用app scritp 寫了以下的code
const REPLY_RATE_TEMPLATE = '👋 您好,USDT/TWD在\nMAX Maicoin的最新交易價\n--------------------\n💰買價:${buyprice} \n💰賣價:${sellprice}\n'+OKX_UR
function getMAXRates() {
const marketsArray = ['usdttwd'];
const queryString = marketsArray.map(market => `markets[]=${market}`).join('&');
const apiUrl = `https://max-api.maicoin.com/api/v3/tickers?${queryString}`;
try {
const response = UrlFetchApp.fetch(apiUrl);
const tickerArray = JSON.parse(response.getContentText());
if (Array.isArray(tickerArray) && tickerArray.length > 0) {
const usdttwdData = tickerArray[0];
const currentBuyPrice = usdttwdData.buy;
const currentSellPrice = usdttwdData.sell;
const currentPrice = REPLY_RATE_TEMPLATE.replace('${buyprice}',currentBuyPrice).replace('${sellprice}', currentSellPrice);
return currentPrice;
} else {
return "N/A";
}
} catch (e) {
return "API 錯誤";
}
}
當然,如果上面的程式有回傳值,就可以傳給Line bot 或 Telegarm bot。
不過,如果要用串接API 的方式,查同一個集團下MaiCoin 的買賣價,好像就得換另外一個方式了。就只好等待來日再來研究。























