SEC EDGAR Collector Integration

An empty result from an EDGAR lookup can mean nothing matched, EDGAR failed to answer, or the run stopped before it asked. A collector has to record which.
Who this is for: anyone building a scheduled collector against SEC EDGAR. The rules came out of one September week when mine got that wrong twice.
EDGAR in one screen#
What it is. EDGAR is the SEC's primary system for companies and others submitting documents under the federal securities laws, and access to its public database is free. Filings go back to 1994 and 1995, when EDGAR started.
What it tells you, by the question you are asking:
| You want to know | Filings that answer it | Where to start |
|---|---|---|
| Which insiders and large holders report owning or trading a company's stock | Ownership forms 3, 4 and 5; Schedules 13D and 13G | Company search feed |
| What material events happened | 8-K | Company search feed, submissions API |
| The reported financial numbers | 10-Q, 10-K and other forms with XBRL data | XBRL APIs |
| Where a word or phrase appears | Any electronic filing since 2001 | Full-text search |
| Everything, in bulk | All public filings | Index files, nightly ZIP files of API data, daily archives |
How you get it programmatically. The SEC documents these surfaces on its developer resources, EDGAR APIs and accessing EDGAR data pages:
- Search feeds. Some EDGAR searches can be captured as feeds, including a company search filtered by filing type. This guide uses that per-company feed.
- data.sec.gov JSON APIs. Each filer's submission history, and XBRL data from financial statements.
- Full-text search. The full text of filings submitted electronically since 2001, attachments included.
- Bulk files. Daily and quarterly index files, nightly ZIP files of the API data, and daily archives of filings.
Why build on it.
- It is where the filings are submitted, not a copy of them.
- It is free, and the data APIs need no authentication or API key.
- Data freshness: the SEC says the APIs update in real time as filings are disseminated, with a typical delay under a second for submissions, longer at peak filing times.
What it costs you. Each of these has its own section below:
- A fair-access cap and a declared User-Agent (Time budget and pacing).
- Slow days that eat a run's time budget (Why these rules exist).
- Legacy form naming in the feed this guide uses (Two limits in the lookup itself).
- An empty answer that is not proof of absence (The four outcomes of one lookup).
What I use it for. I run a private finance engine that grades stocks. EDGAR supplies context for some of its pages: insider transactions from Form 4, material events from 8-K, and large outside holders from Schedules 13D and 13G. The ownership collector in this guide feeds a marker shown beside a grade, not the grade itself. It answers one question when I look at a stock: has anyone filed an ownership report about this company lately?
When it is the wrong tool. If you need every company checked the same day or a guarantee that an empty answer means no filing, a one-company-at-a-time feed is the wrong shape. The last section covers that.
Access rules#
- Rate. The SEC's developer guidance limits each user to ten requests per second, regardless of how many machines send them.
- User-Agent. The SEC's access rules ask you to declare your User-Agent; their sample gives a company name and an admin contact email.
- Hours. EDGAR accepts filings on business days from 6:00 a.m. to 10:00 p.m. ET. Some filings submitted late in the day are disseminated the next business day.
Free and keyless makes EDGAR easy to start with and easy to misread.
The rules in this guide#
- Classify every company into one of four outcomes: matching filing, no matching result, failed, deferred.
- Count matching filings and no-matches as completed. Count failures and deferrals as not completed.
- Once the ticker map has loaded, refuse to publish only when nothing completed, never because the result is empty.
- When a run publishes, mark it
partialif any company was deferred, and carry the deferred count in the file. - Test three cases, all from a ticker map that loads: an outage, a clean empty run, a short run.
The lookup: 13D and 13G by subject company#
Schedules 13D and 13G both report beneficial ownership of more than 5 percent of a covered class of a company's stock. A 13D is the default form; certain institutional, passive and exempt holders may file the shorter 13G instead.
Amendments count as well, so a 13D in my file is not proof of a fresh crossing or of activist intent.
Once a day my collector asks EDGAR's per-company Atom feed about each company on a capped list that has a CIK in EDGAR's ticker map. This is the URL template in the collector; the CIK is zero-padded to ten digits:
https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK={cik}&type=SC+13&dateb=&owner=include&count=40&output=atom
Among the entries the feed returns, it keeps the latest recognized 13D-family and 13G-family filing inside a configured window, 365 days by default, and writes one JSON file. That is the latest match among what the feed returned, not a complete list of the company's filings that year.
My dashboard reads that file and shows a small marker on the stocks that have an entry.
I look these forms up by subject company. The holder submits them, and EDGAR's submissions history is organized by filer, so a by-subject query is the more direct route to "filed about this company." Searching full text by company name gave me unreliable matches when I tried it.
Two limits in the lookup itself#
- Server-side filter. The feed request asks EDGAR to filter by the legacy
SC 13form type. - Parser prefixes. Separately, my parser recognizes only form names that begin with
SC 13DorSC 13G, so a filing the feed returned under any other form name would parse as nothing.
I have not confirmed which form names the feed returns under that filter. Both pieces assume one naming scheme, and a check on form names is the change I would add.
The four outcomes of one lookup#
"No matching result" describes my query, not the company. Once the ticker map has loaded, each company the loop handles lands in exactly one of these outcomes:
| Outcome | Produced by | Completed? |
|---|---|---|
| Matching filing | A recognized 13D-family or 13G-family entry inside the window | Yes |
| No matching result | No CIK, an empty parse, or a 404, 403 or other non-retryable status | Yes |
| Failed | A timeout, transport error, or 429, 500, 502, 503 or 504 after retries; any other exception that reaches the failure handler | No |
| Deferred | The clock margin was reached before the company was asked | No |
Notes on the table:
- A matching filing is one among the entries the feed returned.
- A company with no CIK in EDGAR's ticker map gets no request at all.
- "After retries run out" applies to the listed timeout, transport and status classes. Any other exception that reaches the failure handler, such as a decoding error, involves no retry. The list is not exhaustive.
- A non-retryable status like 403 or 404 does not reach the failure handler. It stays under No matching result.
A no-match is not proof of absence. A missing CIK, a parser gap or a status code can each produce it.
Status-as-absence is a policy choice. Treating 404, 403 and other non-retryable statuses as no filing is my collector's policy, not an SEC guarantee.
Here is the per-company step, simplified from the collector's loop (logging and the outer loop removed):
attempted += 1
cik = cik_map.get(sym)
if not cik:
continue # no EDGAR identity -> absent, never fabricated
time.sleep(pause)
try:
try:
resp = get_with_retry(
client,
_ATOM_URL.format(cik=f"{cik:010d}"),
headers={"User-Agent": _ua()},
timeout=req_timeout,
)
except Exception as exc:
resp_err = getattr(exc, "response", None)
status = getattr(resp_err, "status_code", None)
if resp_err is not None and status not in RETRYABLE_STATUSES:
# 404, 403 and other non-retryable statuses: no match
continue
# everything else, such as exhausted 429/5xx,
# timeouts and transport errors: failed
raise
if resp.status_code != 200:
continue
block = parse_activist_atom(
resp.text, window_days=window_days, today=today
)
if block:
by_ticker[sym] = block # matching filing
except Exception:
failed.append(sym) # failed
When a run may publish#
This is a simplified model of the loop. The outcomes table above lists what produces each outcome; a deferred company is never asked, and a published file is flagged partial if any company was deferred. The model leaves out the two exits before it: a failed fetch of the ticker map stops the run before anything publishes, and an empty company list skips the run.
The rule: count every company the loop reaches as attempted, subtract the failures, and refuse to publish only when nothing completed. Do not refuse because the result is empty.
An empty answer for most of the list is plausible on any given day. Empty is what a run over companies with no recent filings produces.
Simplified from the collector (metrics, the attempt marker and the upload removed):
# Before each company:
if time.monotonic() >= stop_at:
deferred.extend(universe[idx:])
break
# After the loop:
completed = attempted - len(failed)
if completed <= 0:
raise RuntimeError(
f"no ticker completed (attempted={attempted}, "
f"failed={len(failed)}, deferred={len(deferred)})"
)
snapshot = {
"partial": bool(deferred),
"deferred_count": len(deferred),
"by_ticker": by_ticker,
}
When the run publishes, the file carries the partial flag and the deferred count, so a reader can tell a full run from a short one. That count is a total. It does not say which company was deferred, and it cannot say whether a no-match was a verified absence.
partialmarks deferrals only. It applies to runs that qualify to publish, where at least one company completed; such a run with failures but no deferrals publishes withpartialfalse. A run where every reached company failed does not publish at all.
Time budget and pacing#
| Setting | Value | What it does |
|---|---|---|
| Request timeout | 10 seconds | HTTPX limit on connecting, waiting for a pool connection, and sending or receiving each chunk |
| Attempts | Initial attempt plus two retries | Retries HTTPX timeout and transport exceptions, and status 429, 500, 502, 503 and 504 |
| Retry wait | Exponential backoff | A status retry may instead wait for a numeric Retry-After, in seconds, clamped to 0 to 30 |
| Deadline margin | 45 seconds | Before each company, the loop defers the rest once it is within the margin |
| Pause | 0.15 seconds | Sleeps before each company's feed request to pace this loop |
| Function timeout | 15 minutes | The configured ceiling for one invocation |
What these settings do not guarantee:
- The timeout is not a wall-clock cap on an attempt. It applies per attempt, and a response that keeps trickling in chunks can take longer than ten seconds.
- Neither the request timeout nor the margin check bounds time per company. One slow company can still take several timeouts' worth of time; the 15 minute function timeout still caps the whole invocation.
- Retry-After is honored only as a number of seconds. A missing or unparsable header, including an HTTP-date value, falls back to exponential backoff.
- Other exceptions and other unsuccessful statuses are raised without a retry. The outcomes table above decides how each one counts.
- The margin is not a hard deadline. The check runs between companies.
- The pause is not a global rate limiter. It does not cover retries or the ticker map fetch, and nothing coordinates it with my other EDGAR collectors.
- The margin check does not interrupt a company already in progress. It runs between companies and aims to stop the loop before the function timeout.
The retry loop: the module constants, then the body of my shared fetch helper's get_with_retry function, simplified (the host circuit breaker and telemetry removed). The omitted _retry_after_seconds parses a numeric seconds value, clamps it to 0 to 30 seconds, and returns nothing for a missing or unparsable header, which sends the retry back to exponential backoff:
RETRYABLE_STATUSES = frozenset({429, 500, 502, 503, 504})
MAX_RETRY_AFTER_S = 30.0
for attempt in range(retries + 1): # retries=2 by default
try:
resp = client.get(url, **request_kwargs)
except (httpx.TimeoutException, httpx.TransportError):
if attempt < retries:
sleep(backoff * (2**attempt))
continue
raise
if resp.status_code in RETRYABLE_STATUSES and attempt < retries:
# numeric Retry-After clamped to 0..MAX_RETRY_AFTER_S, else None
wait = _retry_after_seconds(resp)
sleep(wait if wait is not None else backoff * (2**attempt))
continue
# raises HTTPStatusError on any other unsuccessful status
resp.raise_for_status()
return resp
As one example, in the September 17 verification run the loop averaged a little over 5 seconds of wall time per company reached, skips included. Size the time budget from measured work per company plus retry delays, and respect the aggregate request cap as a separate limit.
For a larger list, my insider collector refreshes a quarter of it each day and merges that slice into the previous file. I described that rotation in an earlier post.
Tests to write#
All three start from a ticker map that loads, because a failed map stops the run before any of them matters.
- Outage. With a valid map, make every per-company lookup fail with a 503 after retries. Assert that the collector publishes nothing.
- Clean empty run. With a valid map, have every lookup return a valid, empty response. Assert that it publishes a clean empty file.
- Short run. With a valid map, let at least one lookup complete with an empty response, then run out of time. Assert that it publishes with
partialset.
If you treat 404 as absence, as I do, test that policy separately, because it is a choice and not a guarantee.
Skeletons, reduced from my pytest file. _wire stubs storage, the company list and the ticker map; the other helpers are fakes for the fetch helper and the clock:
def test_outage_refuses_to_publish(monkeypatch):
aws, _calls = _wire(monkeypatch, ["AAA", "BBB"])
monkeypatch.setattr(ac, "get_with_retry", _raise_http_status(503))
with pytest.raises(
RuntimeError, match=r"attempted=2, failed=2, deferred=0"
):
ac.handler(None, _FakeContext(480_000))
assert aws.puts == []
def test_clean_empty_run_publishes(monkeypatch):
aws, _calls = _wire(monkeypatch, ["AAA", "BBB"])
monkeypatch.setattr(
ac, "get_with_retry", _dispatching_get(absent=(1, 2))
)
summary = ac.handler(None, _FakeContext(480_000))
assert summary["completed"] == 2
published = json.loads(aws.puts[0]["Body"].decode())
assert published["by_ticker"] == {}
assert published["partial"] is False
def test_short_run_publishes_partial(monkeypatch):
# AAA no match, BBB fails, CCC deferred.
# handler(None, None) has no Lambda context, so this test path uses
# the RUN_BUDGET_SECONDS fallback; in Lambda the margin applies.
aws, _calls = _wire(monkeypatch, ["AAA", "BBB", "CCC"])
monkeypatch.setenv("RUN_BUDGET_SECONDS", "5")
monkeypatch.setattr(
ac.time, "monotonic", _Clock([0.0, 0.0, 0.0, 100.0])
)
monkeypatch.setattr(
ac, "get_with_retry", _dispatching_get(absent=(1,), failing=(2,))
)
summary = ac.handler(None, None)
assert summary["completed"] == 1
published = json.loads(aws.puts[0]["Body"].decode())
assert published["partial"] is True
assert published["deferred_count"] == 1
def test_404_policy_counts_as_absent(monkeypatch):
aws, _calls = _wire(monkeypatch, ["AAA", "BBB"])
monkeypatch.setattr(ac, "get_with_retry", _raise_http_status(404))
summary = ac.handler(None, _FakeContext(480_000))
assert summary["completed"] == 2
assert summary["failed"] == []
My regression test for the outage case makes every per-company lookup raise the error my fetch helper produces after its retries run out on a 503. It injects that error directly, so it tests how the handler classifies the failure, not the retry helper itself.
Why these rules exist#
From its first version, which I wrote in June 2026, the collector published an empty result when every company came back without an error, and refused to publish when the result was empty and something had failed. September tested both halves of that rule.
No status code said why#
On September 16, by the measurements recorded in the pull request that fixed it, the collector made 290 requests to EDGAR, and every one came back HTTP 200.
Those numbers are gaps between requests, not pure response times: the median gap was 0.56 seconds, 95 gaps ran longer than 3 seconds, the 90th percentile was 17 seconds, and the longest was 119.
My HTTP client then allowed 30 seconds per attempt and up to three attempts per URL, plus backoff, so one slow company could take well over a minute and a half. The function had 480 seconds. It ran out on most weekday runs and published nothing.
Refusing on empty threw away good data#
The first fix, on September 17, added the 10 second timeout, the 45 second margin and the partial flag. It also widened the refusal: an empty result with any failure or any deferral would not publish.
The verification run that evening reached 83 companies in 440 seconds, deferred the rest, and did not time out. Eighty-two of the 83 were classified as no matching result, with no error. The handler logged that no ticker had completed (failed=1) and refused to publish.
The second fix, which keys the refusal on completed count, merged twenty minutes later. I raised the function's timeout from 8 minutes to 15 after the fixes.
A status error passed for absence#
Five days later, a review of the same handler found the opposite problem, older than either fix. On a per-company lookup, an HTTP error status had always counted as "no filing": at first any non-200 response, and later any error that carried a response, which included the 429 and 5xx errors my shared fetch helper raises once its retries run out.
If the ticker map loaded and EDGAR then throttled or failed every per-company lookup, every company would have counted as finished with nothing found. The guard before September and the guard after it would both have published an empty file with a fresh timestamp over the last good one.
The September 22 fix sends exhausted 429, 500, 502, 503 and 504 responses to the failure path. Before that fix, the outage regression test published an empty snapshot. I found this by reading code, and I have no record that it happened in production.
Limits, and when to choose something else#
The by-subject feed costs depth. The file records the form, the date and a link, and the filer's name is one click away.
The choice flips on freshness, volume and completeness. If I needed any of these, polling one company at a time through a legacy feed would be the wrong shape:
- every company checked the same day
- the filer's name in the data
- confidence that an empty answer means no filing
EDGAR publishes bulk index files and nightly archives, and paid feeds exist. I have built neither, so I cannot say what they cost in practice.
The file says when a run was partial, but the dashboard that reads it does not look at that flag yet. On a short day a deferred company shows no marker. That is also what a company with no matching result shows, and what a company would show if the feed returned its filing under a form name my parser does not know.
The dashboard hides a file older than ten days, which catches a collector that stopped and says nothing about one that ran short. I have not decided whether a deferred company should keep yesterday's entry, the way the insider collector's merge does, or show that it was not checked today.
Sources, as of November 26, 2026: the collector, fetch helper, infrastructure and dashboard code at their current main revisions; timings and run counts from the September 2026 pull requests that fixed them, not re-measured; general EDGAR facts and access limits from the SEC's About EDGAR, developer resources, EDGAR APIs, accessing EDGAR data and full-text search FAQ pages, read on November 26, 2026, which can change. None of this describes how the collector is running today.