Skip to main content

Download SEC EDGAR filings by quarter/year via master index.

Project description

secfetcher

git Download SEC EDGAR filings by quarter or year using the official SEC master index as the source of truth. secfetcher downloads each filing’s EDGAR folder and saves only the file types you request.

  • PyPI package name: secfetcher
  • Python module / CLI name: secfetch (also importable as secfetcher)

Install

pip install secfetcher

If your system Python is “externally managed” (PEP 668), install into a virtual environment:

python -m venv .venv
. .venv/bin/activate
pip install secfetcher

Required: SEC User-Agent

The SEC requires a descriptive User-Agent string with contact information.

Set it via environment variable:

export SEC_USER_AGENT="Your Name or Company contact@example.com"

You can also pass a user-agent explicitly in code (if the API you call supports it).

Quickstart (Python API)

Download one quarter

from secfetcher import download_quarter

download_quarter(
    year=2024,
    quarter=3,
    forms=["10-Q", "10-K"],
    data_dir="data",
    file_types=[".xml", ".htm", ".html", ".pdf"],
)

Download a full year (all quarters)

from secfetcher import download_year

download_year(
    year=2024,
    forms=["8-K"],
    data_dir="data",
    file_types=[".htm", ".html"],
)

CLI

secfetch quarter --year 2024 --quarter 3 --forms 10-Q 10-K --data-dir data --file-types .xml .htm .html .pdf
secfetch year --year 2024 --forms 8-K --data-dir data --file-types .htm .html

Module form also works:

python -m secfetch --help

Form type allowlist (strict)

secfetch only accepts SEC form types listed in:

  • data/config/form_types.json (auto-created on first run), sourced from
  • src/secfetch/resources/form_types.json (packaged default)

Edit data/config/form_types.json to add or remove accepted form types.

Output layout

data/
  index/
    master/
      2024/
        QTR3/
          master.idx
  filings/
    10-Q/
      0000320193/
        0000320193-24-000069/
          <downloaded files...>
  _state/
    manifest.json

Index cache cleanup (per-quarter)

After a quarter finishes with no errors, secfetch deletes the cached master index for that quarter under data/index/master/<year>/QTR<q>/.

Development

python -m venv .venv
. .venv/bin/activate
python -m pip install -e ".[test]"
pytest

Release to PyPI

This repo is set up to publish to PyPI via GitHub Actions. A publish typically happens when you push a v* tag (for example v0.1.1), and can also be run manually from the Actions UI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

secfetcher-0.1.1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secfetcher-0.1.1-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file secfetcher-0.1.1.tar.gz.

File metadata

  • Download URL: secfetcher-0.1.1.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for secfetcher-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b45a97ad04f359b3ade829c6fc5fcc9abef62a0e75c4aefa896229b1c1a1d5fc
MD5 9eb99eaff9f96166978de1aa3de017f9
BLAKE2b-256 cbc226e91b52b01e1a8c5b46f3ccda07e44dacf863497e7e3edc3f1cfd62666d

See more details on using hashes here.

File details

Details for the file secfetcher-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: secfetcher-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for secfetcher-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d177fa2af2f9057037964d4dfaad4cf00b2d11eccd0bb57b521234e9b52315bd
MD5 77f4b7b68a4047bcac9c4b44e09beaf8
BLAKE2b-256 b4507867c7d448d7d9aa60a98d6f236c9886c3cfbd9678c1983bfedd0d58bb8e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page