A better version of sec-edgar-downloader. Includes an alternative
implementation (a wrapper instead of a fork), to keep compatibility with
new sec-edgar-downloader releases. This library partially uses
nbdev.
Features
Advantages over sec-edgar-downloader:
Flexibility in Download Process
Tailored for choosing what, where, and how to download.
Files stored in memory for faster operations and no unnecessary disk
clutter.
Separate Metadata and File Downloads
Easily skip unneeded files.
Download metadata first, then selectively download files.
Option to save metadata for better organization.
More Input Options
Ticker or CIK (e.g., AAPL, 0000320193) for latest filings.
Accession Number (e.g., 0000320193-23-000077). Not supported in
sec-edgar-downloader.
SEC EDGAR URL (e.g.,
https://www.sec.gov/ix?doc=/Archives/edgar/data/0001067983/000119312523272204/d564412d8k.htm).
Not supported in sec-edgar-downloader.
Install
pip install sec-downloader
How to use
Download the metadata
Note The company name and email address are used to form a
user-agent string that adheres to the SEC EDGAR’s fair access policy
for programmatic downloading.
Source
from sec_downloader import Downloader
dl = Downloader("MyCompanyName", "email@example.com")
After obtaining the Primary Document URL, for example from the metadata,
you can proceed to download the HTML using this URL.
for metadata in metadatas:
html = dl.download_filing(url=metadata.primary_doc_url).decode()
print(html[:50])
break # same for all filings, let's just print the first one
Files are downloaded to a temporary folder, immediately read into
memory, and then deleted. Let’s demonstrate how to download a single
file (latest 10-Q filing details in HTML format) to memory. The “glob”
pattern is used to select which files are read to memory.
from sec_edgar_downloader import Downloader as SecEdgarDownloader
from sec_downloader.download_storage import DownloadStorage
ONLY_HTML = "**/*.htm*"
storage = DownloadStorage(filter_pattern=ONLY_HTML)
with storage as path:
dl = SecEdgarDownloader("MyCompanyName", "email@example.com", path)
dl.get("10-Q", "AAPL", limit=1, download_details=True)
# all files are now deleted and only stored in memory
content = storage.get_file_contents()[0].content
print(f"{content[:50]}...")
storage = DownloadStorage()
with storage as path:
dl = SecEdgarDownloader("MyCompanyName", "email@example.com", path)
dl.get("10-K", "GOOG", limit=2)
# all files are now deleted and only stored in memory
for path, content in storage.get_file_contents():
print(f"Path: {path}\nContent [len={len(content)}]: {content[:30]}...\n")
Q: I’m encountering a ValueError stating ‘8-K/A’ forms are not
supported. How can I download “8-K/A” filings?
A: To download amended filings such as “8-K/A”, you need to set the
parameter include_amends=True. For example, to download this
filing,
you would use: