Skip to main content

Async client for the REST API of EDGAR which returns data structured into pydantic schemas and SEC filings

Project description

This project provides a async client for the EDGAR REST API which structures the responses into pydantic schemas.

The following purposes include adding financial statement reader classes, computing common metrics such as FCF, and adding classes to spot investment red flags.

Finally, perhaps adding, as a fallback to the EDGAR REST API, the pipeline of downloading, extracting and loading into the pydantic schemas the data directly from edgar txt/xbrl submissions.

Installation

python -m pip install edgarito

Example usage of the async API

from edgarito.services.edgar_rest_client.low_level_client import EDGARLowLevelClient
from edgarito.services.cache.filesystem_cache import FileSystemCache
from edgarito.enums.edgar.filing_type import FilingType


async def main():
    # A cache is required to comply with SEC request of optimizing requests.
    cache = FileSystemCache(root_directory="./cache")

    # We create a client to interact with the SEC API.
    async with EDGARLowLevelClient(cache=cache, user_agent="Your Name (your-email@gmail.com)") as edgar:

        # Search for Apple CIK from the tickers.
        tickers = await edgar.get_tickers()
        for ticker_info in tickers:
            if ticker_info.ticker == "AAPL":
                print(f"CIK for AAPL is {ticker_info.cik}")
                cik = ticker_info.cik
                break
        else:
            raise ValueError("Ticker not found")

        # Display some company facts
        company = await edgar.get_company_facts(cik=cik)

        for fact_name, fact_info in company.facts.us_gaap.items():

            if fact_info.units.USD:  # or fact_info.units.shares...

                print(f"{fact_name} - {fact_info.label}:")
                for measurement in fact_info.units.USD:

                    if measurement.parsed_type != FilingType.FILING_10K:
                        continue
                    print(f"\t{measurement.fy}: {measurement.val}")


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Examples of CLI usage.

  • Find submissions python -m edgarito.cli submissions --cik 320193 --type 10-K
[2025-03-01 12:37:41,330][INFO][edgarito.services.edgar_rest_client.submissions_client] Got 1000 filings for CIK 320193
[2025-03-01 12:37:41,330][INFO][edgarito.services.edgar_rest_client.submissions_client] Getting additional filings for name='CIK0000320193-submissions-001.json' filingCount=1125 filingFrom=datetime.date(1994, 1, 26) filingTo=datetime.date(2014, 5, 28)
[2025-03-01 12:37:41,330][INFO][edgarito.services.edgar_rest_client.submissions_client] Got 1125 additional filings for name='CIK0000320193-submissions-001.json' filingCount=1125 filingFrom=datetime.date(1994, 1, 26) filingTo=datetime.date(2014, 5, 28)
[2025-03-01 12:37:41,346][INFO][Cli] 1994-12-13         0000320193-94-000016    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 1995-12-19         0000320193-95-000016    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 1996-12-19         0000320193-96-000023    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 1997-12-05         0001047469-97-006960    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 1999-12-22         0000912057-99-010244    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 2000-12-14         0000912057-00-053623    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 2002-12-19         0001047469-02-007674    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 2003-12-19         0001047469-03-041604    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 2004-12-03         0001047469-04-035975    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 2005-12-01         0001104659-05-058421    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 2006-12-29         0001104659-06-084288    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 2007-11-15         0001047469-07-009340    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 2008-11-05         0001193125-08-224958    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 2009-10-27         0001193125-09-214859    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 2010-10-27         0001193125-10-238044    10-K (10-K)
[2025-03-01 12:37:41,346][INFO][Cli] 2011-10-26         0001193125-11-282113    10-K (10-K)
[2025-03-01 12:37:41,347][INFO][Cli] 2012-10-31         0001193125-12-444068    10-K (10-K)
[2025-03-01 12:37:41,347][INFO][Cli] 2013-10-30         0001193125-13-416534    10-K (10-K)
[2025-03-01 12:37:41,347][INFO][Cli] 2014-10-27         0001193125-14-383437    10-K (10-K)
[2025-03-01 12:37:41,347][INFO][Cli] 2015-10-28         0001193125-15-356351    10-K (10-K)
[2025-03-01 12:37:41,347][INFO][Cli] 2016-10-26         0001628280-16-020309    10-K (10-K)
[2025-03-01 12:37:41,347][INFO][Cli] 2017-11-03         0000320193-17-000070    10-K (10-K)
[2025-03-01 12:37:41,347][INFO][Cli] 2018-11-05         0000320193-18-000145    10-K (10-K)
[2025-03-01 12:37:41,347][INFO][Cli] 2019-10-31         0000320193-19-000119    10-K (XBRL)
[2025-03-01 12:37:41,347][INFO][Cli] 2020-10-30         0000320193-20-000096    10-K (XBRL)
[2025-03-01 12:37:41,347][INFO][Cli] 2021-10-29         0000320193-21-000105    10-K (XBRL)
[2025-03-01 12:37:41,347][INFO][Cli] 2022-10-28         0000320193-22-000108    10-K (XBRL)
[2025-03-01 12:37:41,347][INFO][Cli] 2023-11-03         0000320193-23-000106    10-K (XBRL)
[2025-03-01 12:37:41,347][INFO][Cli] 2024-11-01         0000320193-24-000123    10-K (XBRL)
  • Download last 10-K for AAPL python -m edgarito.cli download --ticker aapl --type 10-K --limit 5
[2025-03-01 12:37:03,588][INFO][Cli] CIK: 320193
[2025-03-01 12:37:03,590][INFO][edgarito.services.edgar_rest_client.submissions_client] Got 1000 filings for CIK 320193
[2025-03-01 12:37:03,590][INFO][edgarito.services.edgar_rest_client.submissions_client] Getting additional filings for name='CIK0000320193-submissions-001.json' filingCount=1125 filingFrom=datetime.date(1994, 1, 26) filingTo=datetime.date(2014, 5, 28)
[2025-03-01 12:37:03,592][INFO][edgarito.services.edgar_rest_client.submissions_client] Got 1125 additional filings for name='CIK0000320193-submissions-001.json' filingCount=1125 filingFrom=datetime.date(1994, 1, 26) filingTo=datetime.date(2014, 5, 28)
[2025-03-01 12:37:03,601][INFO][Cli] 2020-10-30         0000320193-20-000096    10-K (XBRL)
[2025-03-01 12:37:03,601][INFO][Cli] 2021-10-29         0000320193-21-000105    10-K (XBRL)
[2025-03-01 12:37:03,602][INFO][Cli] 2022-10-28         0000320193-22-000108    10-K (XBRL)
[2025-03-01 12:37:03,602][INFO][Cli] 2023-11-03         0000320193-23-000106    10-K (XBRL)
[2025-03-01 12:37:03,602][INFO][Cli] 2024-11-01         0000320193-24-000123    10-K (XBRL)
[2025-03-01 12:37:03,602][INFO][DownloadService] Fetching https://www.sec.gov/Archives/edgar/data/320193/000032019320000096/0000320193-20-000096.txt
[2025-03-01 12:37:03,604][INFO][DownloadService] Fetching https://www.sec.gov/Archives/edgar/data/320193/000032019321000105/0000320193-21-000105.txt
[2025-03-01 12:37:03,604][INFO][DownloadService] Fetching https://www.sec.gov/Archives/edgar/data/320193/000032019322000108/0000320193-22-000108.txt
[2025-03-01 12:37:03,605][INFO][DownloadService] Fetching https://www.sec.gov/Archives/edgar/data/320193/000032019323000106/0000320193-23-000106.txt
[2025-03-01 12:37:03,605][INFO][DownloadService] Fetching https://www.sec.gov/Archives/edgar/data/320193/000032019324000123/0000320193-24-000123.txt

You can find more commands in edgarito.cli.__main__

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

edgarito-0.1.1.tar.gz (31.5 kB view details)

Uploaded Source

Built Distribution

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

edgarito-0.1.1-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: edgarito-0.1.1.tar.gz
  • Upload date:
  • Size: 31.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for edgarito-0.1.1.tar.gz
Algorithm Hash digest
SHA256 09db2cad62ea895bfd887cb113cdb791577a7473febbea112122e12096b3ea4e
MD5 5a4f00965f68fac735d32e6db667f45c
BLAKE2b-256 524d4dd3d56aca03079aa154cea4b6d71a352d60a2d01626f4daaa1c0737877e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: edgarito-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 33.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for edgarito-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae1831bf0481e2414f2834790bffa996d0e55b53ea05470ef29255f159ea3674
MD5 c033f33b13bc8283c6a812aea3a2e0a5
BLAKE2b-256 1024e6f8a9bbdad9ddbeaf43f35b5cd0ffe492981e2d6c72bfe4b0b3ca95d255

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