How to get insider trades (Form 4) as data

Every Form 4 is XML on EDGAR, free and keyless. What the flat files and the parsers get wrong — partial amendments, transaction codes and a 10b5-1 flag.

Every Form 4 is filed as XML on EDGAR within two business days of the trade, free and keyless: read a company's filing index from the submissions endpoint, fetch the XML, and walk the two transaction tables. The SEC flattens Forms 3, 4 and 5 into quarterly tab-separated files back to 2006. The traps are in reading them: most rows are not purchases or sales, an amendment carries only changed lines, and one 10b5-1 box covers the whole form.

The short way

A company's filing index is one JSON document on EDGAR, and every Form 4 in it is an XML file one request away. No key and no account — but every request has to name you, and the ceiling is ten a second:

import json, time, urllib.request
import xml.etree.ElementTree as ET

UA = {"User-Agent": "Your Name you@example.com"}  # the SEC asks you to declare yourself

def get(url):
    time.sleep(0.15)  # stay under ten requests a second
    with urllib.request.urlopen(urllib.request.Request(url, headers=UA)) as r:
        return r.read()

cik = "320193"  # Apple
recent = json.loads(get(f"https://data.sec.gov/submissions/CIK{cik.zfill(10)}.json"))["filings"]["recent"]

for acc, form, doc in zip(recent["accessionNumber"], recent["form"], recent["primaryDocument"]):
    if form not in ("4", "4/A"):
        continue
    raw = doc.split("/")[-1]  # primaryDocument points at the rendered xslF345X0n/ copy
    url = f"https://www.sec.gov/Archives/edgar/data/{cik}/{acc.replace('-', '')}/{raw}"
    x = ET.fromstring(get(url))
    plan = x.findtext("aff10b5One")  # one box for the whole form
    for t in x.iter("nonDerivativeTransaction"):
        print(acc, form, x.findtext("reportingOwner/reportingOwnerId/rptOwnerName"),
              t.findtext("transactionDate/value"),
              t.findtext("transactionCoding/transactionCode"),
              t.findtext("transactionAmounts/transactionShares/value"),
              t.findtext("transactionAmounts/transactionPricePerShare/value"),
              t.findtext("transactionAmounts/transactionAcquiredDisposedCode/value"),
              plan)

Run on 4 October 2026, the first filing it reaches is a sale of 2,399 shares at $336.18 by Apple's general counsel on 29 September, code S, disposed, with the 10b5-1 box ticked. Two details in that loop are worth keeping. A Form 4 is filed under the issuer's CIK and the insider's, so the issuer's index lists every insider at once. And primaryDocument names the human-readable copy under an xslF345X06/ directory; the raw XML sits one level up.

For history rather than a feed, the SEC's Insider Transactions Data Sets flatten the same XML into quarterly zips back to January 2006: SUBMISSION (one row per filing, with the issuer and form type), REPORTINGOWNER, NONDERIV_TRANS, DERIV_TRANS, two holdings tables, signatures, and FOOTNOTES, which at 37 MB is the largest file in the second-quarter 2026 zip — a measure of how much of a Form 4 lives in prose. Everything joins on ACCESSION_NUMBER.

What the options are

The source. SEC EDGAR is the filing the day it is made and the quarterly flat files above, and the SEC's description of both is data "presented without change from the 'as-filed' submissions", with a disclaimer that it is not a substitute for the filings. In the 2026q2 file downloaded on 5 October 2026, the quarter holds 56,102 filings — 49,832 Form 4s, 713 Form 4 amendments, 5,284 Form 3s — and 78,328 non-derivative transaction rows across all of them. Every rule further down this page is yours to implement.

Somebody else's parser. sec-api.io sells Forms 3, 4 and 5 already turned into JSON, beside 13F, 13D/G and Form 144, with a websocket that pushes new filings as they land. It starts at $55 a month for one key and personal use; business internal use is $239, and redistribution sits only on the sales-quoted Enterprise tier.

Insiders outside the US. Insider Screener carries US Form 4 back to 30 June 2003 plus sixteen non-US regimes, which is where the work is — every one of those is a different regulator, format and language. Its REST API runs on credits: $49 a month buys 1,000, and a US transaction list costs two. The insider-performance and screener endpoints sit only on the $499 Research tier, and every tier is internal use. 2iQ is the institutional version — fifty countries, a stable identifier per insider across companies, role labels harmonised and amendments reconciled — with no self-serve price at all.

Form 4 next to other disclosures. Quiver Quantitative sells insider transactions as one REST dataset among congressional trades, 13F and lobbying, starting on the Trader tier at $75 a month. Both published tiers are marked non-commercial; commercial use is a contact-priced plan. The rest of the shelf — most of it screens for people to read rather than feeds for programs to parse — is in insider, 13F and congressional trade trackers.

Where this breaks

Most rows are neither a purchase nor a sale. The form defines twenty transaction codes, and only two of them are trades at a market price: P, an open-market or private purchase, and S, the matching sale. A is a grant or award, M the exercise of an option under an exempt plan, F shares the company withheld to pay an exercise price or the tax on a vesting award, G a gift, J anything else, explained in a footnote. In the second quarter of 2026, S was 27,601 non-derivative rows, A 19,211, M 10,783, F 9,357 — and P 5,326, or under 7%. Sum the acquired-or-disposed column without filtering on the code and an option exercise reads as a purchase and a tax withholding as a sale. Form 4 sets out why direction is the least informative field on the form.

There are two tables, and the second is not shares. Table I is non-derivative securities — common stock. Table II is options, warrants, restricted stock units and convertibles, with a conversion price, an expiration date and an underlying security of its own; that quarter it held 30,370 transaction rows. An M usually appears twice, once in each table: the option leaves Table II and the stock arrives in Table I. Add the two and you count the same exercise as two acquisitions, one of them in units that are not shares.

An amendment is a patch, not a replacement. The form's instructions are explicit: a 4/A that adds lines carries only the added lines, and one that corrects lines carries only the corrected lines, complete — "do not repeat lines … that were disclosed in the original Form and are not being amended". There were 713 of them that quarter. Replace the original with the amendment and you delete every line it left alone; append it and every corrected line counts twice. The fix is to match a corrected line to the line it replaces, which the data does not do for you: the only link is the original filing date in DATE_OF_ORIG_SUB and a footnote in prose.

The 10b5-1 box is one box, on some filings, spelled four ways. The SEC's December 2022 amendments added a mandatory checkbox for transactions made under a Rule 10b5-1(c) plan, on Forms 4 and 5 filed from 1 April 2023; nothing earlier carries it, so any series crossing that date changes shape. It is a single element for the whole form, ticked if any transaction on it was under a plan, not a flag per row — a filing that mixes a planned sale with a discretionary one marks both. The SEC only added AFF10B5ONE to its flat files in July 2025, back-filling 2023 onward, and in the second-quarter 2026 file Form 4s carry it as 0 (34,677), false (9,882), 1 (3,960) and true (1,313). Normalise it before you count it: 59% of that quarter's sale rows on original Form 4s sit on a form with the box ticked.

One filing, several owners. A Form 4 can be filed jointly by more than one reporting person — a fund and its general partner, a trust and its trustee — and then lists every one of them against the same transactions. That quarter, 1,229 filings name more than one owner, up to ten — 1,022 of them original Form 4s, the rest Forms 3 and amendments. Join REPORTINGOWNER to the transaction tables naively and each of those trades is multiplied by its owner count. The row's DIRECT_INDIRECT_OWNERSHIP column matters for the same reason: 13,927 rows that quarter are indirect holdings — through a trust, a spouse, an entity — where the shares are attributed rather than owned.

The price is often an average, and the detail is in a footnote. A sale executed in dozens of fills is usually reported as one line at a weighted-average price, with the range in a footnote. Of that quarter's 27,378 sale rows on original Form 4s, 19,783 carry a price footnote. The column is right as an average; it is not a fill.

Two business days is the rule, not the data. Of 76,699 non-derivative rows on original Form 4s that quarter — those reported as Form 4 transactions, leaving out 558 rows, all but two of them Form 5 transactions reported early — 3,928 were filed more than two business days after the transaction date, and 1,245 more than thirty. Count weekdays alone, treating Memorial Day and Juneteenth as working days, and the first figure becomes 6,325: two holidays in one quarter move it by more than a third. The TRANS_TIMELINESS column, where a filer can mark a line late, is set on 394. Gifts moved onto Form 4 under the same 2022 amendments; before February 2023 they were reported on Form 5 up to 45 days after the fiscal year, which is one more break in any long series. A study keyed on filing date and a study keyed on transaction date are two different studies.

The population changed in March 2026. The Holding Foreign Insiders Accountable Act amended Section 16(a) to cover directors and officers of foreign private issuers, and the SEC's rules implementing it took effect on 18 March 2026. The second-quarter 2026 file holds 5,284 initial Form 3s against 3,151 a year earlier. Any count of insider filings per quarter has a step in it that is not a change in behaviour.

EDGAR will stop you at ten requests a second. The SEC publishes that ceiling, asks every script to declare a User-Agent with a contact address, and manages anything that looks like an undeclared bot. Walking every Form 4 for the whole market one XML at a time is roughly 200,000 requests a year, which at the ceiling is fine and at an unthrottled loop is a block. For history, use the flat files; for the last few days, use the EDGAR filing index route.

If you outgrow this

When a quarterly file is too slow and polling is too much work, a push feed is the next step: sec-api.io's websocket delivers each filing as EDGAR accepts it. For a person rather than a program, OpenInsider shows each Form 4 a minute or two behind EDGAR with a 40-field screener — but no API, no export and no 10b5-1 column.

When you need insiders outside the US, the parsing work multiplies by regulator, which is the reason Insider Screener and 2iQ exist.

When the question is a fund's position rather than an executive's trade, a Form 4 is the wrong form; How to get 13F holdings as data covers the quarterly one, and when a trade shows up in the public record sets every disclosure deadline side by side.

The tools that do this

In the order this page recommends trying them. Paid placement does not affect this order.

  1. SEC EDGAR

    The filing XML the day it is made, and quarterly flat files of Forms 3, 4 and 5 since 2006. Free and keyless, ten requests a second, nothing reconciled.

    Every US filing since 1994, free and keyless — the limit is ten requests a second.

    FreeFree tier

  2. sec-api.io

    Forms 3, 4 and 5 already parsed to JSON, with a websocket push of new filings, from $55 a month. Redistribution is Enterprise-only.

    Every EDGAR filing since 1993 as JSON, plus a websocket push of new ones.

    $55/mo

  3. Insider Screener

    US Form 4 back to June 2003 plus sixteen non-US regimes over one REST API, from $49 a month in credits. Internal use only.

    Directors' dealings from seventeen regulators in one screener, with a paid REST API.

    $19/mo

  4. Quiver Quantitative

    Form 4 as one dataset beside congressional trades and 13F, from the $75-a-month Trader tier. Both published tiers forbid commercial use.

    US political and SEC disclosure data — congress, insiders, lobbying — over one REST API.

    $30/moFree tier

  5. 2iQ Insider Transactions Data

    Insider filings from fifty countries with an identifier per insider and amendments handled, sold by contract through institutional channels.

    Insider dealings from fifty countries, harmonised and identified, sold by contract.

    —

FAQ

Where can I download every Form 4 in bulk for free?

From the SEC's Insider Transactions Data Sets page. Each quarterly zip flattens the XML portion of Forms 3, 4 and 5 into eight tab-separated tables keyed on accession number, from January 2006 onward, with no account and no key. The second quarter of 2026 is 56,102 filings in an 11 MB zip. Filings made after 5.30pm Eastern on a quarter's last business day roll into the next file.

Which Form 4 transaction codes are actual purchases and sales?

Only P and S — open-market or private purchases and sales. A is a grant or award, M the exercise of a derivative under an exempt plan, F shares withheld to pay an exercise price or tax, G a gift, J anything else. In the second quarter of 2026, P and S together were 42% of non-derivative transaction rows, and P alone under 7%.

How do I tell whether an insider sale was under a 10b5-1 plan?

Read the aff10b5One element in the filing XML, or the AFF10B5ONE column the SEC added to its flat files in July 2025, back-filled to 2023. It exists only on Forms 4 and 5 filed from 1 April 2023, it is one box for the whole form rather than a flag per row, and the flat files spell it four ways — 0, 1, true and false.

Sources

  1. Insider Transactions Data Sets — U.S. Securities and Exchange Commission, read
  2. Form 4 — Statement of Changes in Beneficial Ownership, with General Instructions (SEC 1474) — U.S. Securities and Exchange Commission, read
  3. Accessing EDGAR Data — U.S. Securities and Exchange Commission, read
  4. Insider Trading Arrangements and Related Disclosures (87 FR 80362) — Securities and Exchange Commission, . The Form 4 in use in October 2026 still carries the Rule 10b5-1(c) checkbox and Instruction 10 that this release added.
  5. Holding Foreign Insiders Accountable Act Disclosure (91 FR 10320) — Securities and Exchange Commission,

The catalogue next door

This page names a handful of cards. The rest of them are in Insider, 13F & Congressional Trade Trackers, each filled in against the same schema, with the fields to narrow it yourself.

Last updated . Corrected in place: this is a reference page, not a dated post.