Resposta · Google Sheets · trigger
Atualizar odds Pinnacle no Google Sheets com timer
Resposta: Use Apps Script UrlFetchApp contra GET /v1/odds e instale um trigger por tempo (a cada 15 minutos). Script completo: guia Sheets. Free basta (atraso 30 s, 1.000 req/dia).
Só o trigger#
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);
}
function installTrigger() {
ScriptApp.getProjectTriggers().forEach((t) => ScriptApp.deleteTrigger(t));
ScriptApp.newTrigger("refreshOdds").timeBased().everyMinutes(15).create();
}
Guarde a chave em propriedades do script, nunca nas células. Excel: Power Query. Push ao vivo: Builder (€99/mês). Planos pagos: 3 dias de teste; cartão é obrigatório e é cobrado após o dia 3 salvo cancelamento. Conteúdo educativo para adultos (18+).
Perguntas que as pessoas fazem#
15 minutos esgotam o Free?#
96 chamadas/dia se só o trigger dispara — abaixo do teto de 1.000/dia.
IMPORTDATA serve?#
IMPORTDATA não envia x-api-key. Use Apps Script (esta página).