// guide

Get SEC Form 4 Insider Data into Google Sheets

Updated 2026-07-26. By Theodor Nielsen, founder of Form4API.

// answer

To pull SEC Form 4 insider trades into Google Sheets, add a small Apps Script custom function that calls the Form4API REST API with your key, then type =FORM4API_TX("AAPL") in a cell. The transactions spill into the sheet — filter by ticker and transaction code. It works on the free tier (500 requests/day, no card). The full script is below.

Why a tiny script, not IMPORTDATA

Form4API authenticates with an API key sent as an HTTP header, and Google Sheets' built-in IMPORTDATA / IMPORTHTML functions can only fetch fully public URLs — they can't send a header. A one-time Apps Script custom function solves that: it sends the key, calls the API, and returns the rows into your sheet. You paste it once and then use it like any built-in formula.

Setup — about two minutes

  1. Get a free API key on the dashboard (500 requests/day, no card).
  2. In your Google Sheet, open Extensions → Apps Script.
  3. Delete the placeholder code, paste the script below, and save.
  4. Put your key in setForm4ApiKey(), run it once (it stores the key securely), then remove the literal key from the code.
  5. Back in the sheet, type =FORM4API_TX("AAPL").

The script

/**
 * Pull SEC Form 4 insider transactions into a cell range.
 * Usage:  =FORM4API_TX("AAPL")   or   =FORM4API_TX("AAPL", "P", 50)
 *
 * @param {string} ticker  Stock ticker, e.g. "AAPL"
 * @param {string} code    Optional transaction code filter, e.g. "P" (buys)
 * @param {number} limit   Optional row count (default 25, max 100)
 * @return A range of insider transactions
 * @customfunction
 */
function FORM4API_TX(ticker, code, limit) {
  if (!ticker) throw new Error('Pass a ticker, e.g. =FORM4API_TX("AAPL")');
  var key = PropertiesService.getScriptProperties().getProperty('FORM4API_KEY');
  if (!key) throw new Error('Run setForm4ApiKey() once to store your key.');

  var url = 'https://api.form4api.com/v1/transactions'
    + '?ticker=' + encodeURIComponent(ticker.toUpperCase())
    + (code ? '&code=' + encodeURIComponent(code.toUpperCase()) : '')
    + '&per_page=' + (limit || 25);

  var res = UrlFetchApp.fetch(url, {
    headers: { 'X-Api-Key': key },
    muteHttpExceptions: true
  });
  if (res.getResponseCode() !== 200) {
    throw new Error('Form4API error ' + res.getResponseCode());
  }

  var body = JSON.parse(res.getContentText());
  var rows = body.data || body.transactions || body; // handles either shape
  var out = [['Date', 'Insider', 'Code', 'Shares', 'Price', 'Value']];
  rows.forEach(function (t) {
    out.push([t.transactionDate, t.insiderName, t.transactionCode,
              t.sharesAmount, t.pricePerShare, t.totalValue]);
  });
  return out;
}

/** Run this ONCE to store your key, then delete the key from the code. */
function setForm4ApiKey() {
  PropertiesService.getScriptProperties()
    .setProperty('FORM4API_KEY', 'YOUR_FORM4API_KEY');
}

The key lives in Script Properties — encrypted at rest by Google and not visible to people who only have access to the spreadsheet cells.

Using it in cells

  • =FORM4API_TX("AAPL") — recent insider transactions for Apple.
  • =FORM4API_TX("NVDA", "P") — open-market purchases only (code P).
  • =FORM4API_TX("TSLA", "S", 50) — up to 50 open-market sales.

The function returns six columns — Date, Insider, Code, Shares, Price, Value — that spill into the cells below the formula. Extend it to other endpoints (company profiles, signals, 13F holdings) by copying the same fetch pattern; see the API docs for the full parameter list, or the Python guide for the same data in code.

The no-code CSV option

If you'd rather not touch Apps Script at all, the CSV export endpoint (available on the higher tiers) streams filtered transactions as a file you can bring in with File → Import → Upload in Google Sheets. It is a one-time snapshot rather than a live formula, but it needs zero scripting. See the docs for the export parameters.

Frequently asked questions

Can I pull SEC Form 4 insider trading data into Google Sheets?

Yes. Google Sheets can call the Form4API REST API through a small Apps Script custom function. Once you paste the function in (Extensions → Apps Script) and store your API key, you type =FORM4API_TX("AAPL") in a cell and the insider transactions spill into the sheet. It works on the free tier (500 requests/day, no credit card).

Why can’t I just use IMPORTDATA or IMPORTHTML?

Because Form4API requires an API key sent as an HTTP header (X-Api-Key), and Google Sheets’ built-in IMPORTDATA / IMPORTHTML functions cannot send custom headers — they only fetch fully public URLs. A tiny Apps Script custom function can send the header, which is why it is the standard way to bring authenticated API data into Sheets.

Does the data refresh automatically?

Apps Script custom functions recalculate when the sheet is opened or the arguments change, but Google does not re-run them on a timer by design. For scheduled refreshes, add a time-driven trigger (Apps Script → Triggers) that rewrites the cells on an interval you choose, or just re-open the sheet. Form4API responses are also lightly cached to keep you within rate limits.

How do I keep my API key private in a shared sheet?

Store the key with PropertiesService (as the script above does) rather than typing it into a cell or leaving it hardcoded. Script Properties are bound to the script, encrypted at rest by Google, and are not visible to people who only have access to the spreadsheet’s cells. Run setForm4ApiKey() once, then remove the literal key from the code.

Is it free to use insider data in Google Sheets?

Yes, within the free tier — 500 requests per day with no credit card. Each recalculation of a custom function is one or more API calls, so heavy sheets with many formulas can add up; higher limits, longer history, and webhooks are on the paid plans. See the pricing page for the tiers.

Get more from this data

Get API key

500 free requests / day. No credit card.

Get API key

View API docs

curl / JavaScript / Python examples for every endpoint.

View API docs

See pricing

Free, $49, $149, $499 — pick the tier that fits.

See pricing