回答 · Google Sheets · トリガー
タイマーでGoogleスプレッドシートのピナクルオッズを更新する
回答: Apps Scriptの UrlFetchApp で GET /v1/odds を呼び、時間主導トリガー(15分ごと)をインストールします。完全なボード用スクリプト:Google Sheetsガイド。Freeプランで十分です(30秒遅延、1日1,000リクエスト)。
トリガー用スニペット#
const KEY = PropertiesService.getScriptProperties().getProperty("PINNFEED_KEY");
const SPORT = "soccer";
function refreshOdds() {
const url = "https://pinnfeed.io/v1/odds"
+ "?sport=" + encodeURIComponent(SPORT)
+ "&market=moneyline&main=true&limit=30";
const res = UrlFetchApp.fetch(url, {
headers: { "x-api-key": KEY, accept: "application/json" },
muteHttpExceptions: true,
});
if (res.getResponseCode() !== 200) throw new Error(res.getContentText());
const events = JSON.parse(res.getContentText()).events || [];
const sheet = SpreadsheetApp.getActive().getSheetByName("Odds");
const rows = [["home", "away", "home_dec", "away_dec", "fair_home", "updated"]];
for (const ev of events) {
const m = (ev.markets || []).find((x) => x.type === "moneyline");
if (!m) continue;
const by = Object.fromEntries((m.outcomes || []).map((o) => [o.name, o]));
rows.push([
ev.home, ev.away,
by.home?.decimal, by.away?.decimal, by.home?.fair,
new Date().toISOString(),
]);
}
sheet.clearContents();
sheet.getRange(1, 1, rows.length, rows[0].length).setValues(rows);
}
/** Run once from the editor to install the 15-minute trigger. */
function installTrigger() {
ScriptApp.getProjectTriggers().forEach((t) => ScriptApp.deleteTrigger(t));
ScriptApp.newTrigger("refreshOdds").timeBased().everyMinutes(15).create();
}
キーはプロジェクトの設定 → スクリプト プロパティに保存し、セルには置かないでください。Excelの場合はPower Query(英語)。ライブのプッシュには引き続きBuilder(月額99ユーロ)が必要です。有料プラン:3日間のトライアル。カード登録が必要で、解約しない場合は3日目の後に課金されます。
18歳以上の方を対象とした教育目的のコンテンツです。予想や利益の約束ではありません。日本では刑法により賭博は原則として禁止されています。
よくある質問#
15分更新でFree枠を使い果たしますか?#
トリガーだけなら1日96回 — Freeの1日1,000上限内です。スポーツを増やすときは注意してください。
IMPORTDATAでできますか?#
IMPORTDATA は x-api-key を送れません。Apps Script(このページ)か、自分で制御する公開プロキシ付きのIMPORTDATA回答だけを使ってください。当社はプロキシを提供しません。