const HOST = "https://sec-event-intelligence.p.rapidapi.com"; function SEC_FILINGS(tickers) { const key = PropertiesService .getScriptProperties() .getProperty("RAPIDAPI_KEY"); if (!key) { throw new Error("Set RAPIDAPI_KEY in Apps Script project settings."); } const query = [ ["tickers", tickers || "AAPL,MSFT"], ["since", "2026-07-01"], ["limit", "10"] ].map(([name, value]) => `${name}=${encodeURIComponent(value)}`).join("&"); const response = UrlFetchApp.fetch( `${HOST}/v1/sec/watchlist/changes?${query}`, { headers: { "x-rapidapi-host": "sec-event-intelligence.p.rapidapi.com", "x-rapidapi-key": key }, muteHttpExceptions: true } ); if (response.getResponseCode() >= 300) { throw new Error(response.getContentText()); } const payload = JSON.parse(response.getContentText()); const rows = [["Ticker", "Form", "Filed At", "Company", "Accession"]]; for (const group of payload.data) { for (const change of group.changes || []) { const filing = change.filing || {}; rows.push([ group.ticker, filing.form || "", filing.filedAt || "", filing.companyName || "", filing.accessionNo || "" ]); } } return rows; }