Skip to content

Repository files navigation

edgar-tools-logo

The world's easiest, most powerful edgar library

PyPI - VersionGitHub last commitGitHub Workflow StatusCodeFactorHatch projectGitHub

edgardemo

Features

  • 🧠 Intuitive and easy to use: edgartools has a super simple API that is easy to use.
  • 🛠️ Works as a library or a CLI: You can use edgartools as a library in your code or as a CLI tool.
  • 📁 Access any SEC filing: You can access any SEC filing since 1994.
  • 📅 List filings for any date range: List filings for year, quarter e.g. or date range 2024-02-29:2024-03-15
  • 🌟 Best looking edgar library: Uses rich library to display SEC Edgar data in a beautiful way.
  • 🔄 Page through filings: Use filings.next() and filings.previous() to page through filings
  • 🏗️ Build Data Pipelines: Build data pipelines by finding, filtering, transforming and saving filings
  • Select a filing: You can select a filing from the list of filings.
  • 📄 View the filing as HTML or text: Find a filing then get the content as HTML or text.
  • 🔢 Chunk filing text: You can chunk the filing text into sections for vector embedding.
  • 🔍 Preview the filing: You can preview the filing in the terminal or a notebook.
  • 🔎 Search through a filing: You can search through a filing for a keyword.
  • 📊 Parse XBRL: If a filing has XBRL, you can parse it to a dataframe.
  • 💾 Data Objects: Automatically downloads and parses filings into data objects.
  • 📥 Download any attachment: You can download any attachment from the filing.
  • 🕒 Automatic throttling: Automatically throttles requests to Edgar to avoid being blocked.
  • 📥 Bulk downloads: Faster batch processing through bulk downloads of filings and facts
  • 🔢 Get company by Ticker or Cik: Get a company by ticker Company("SNOW") or cik Company(1640147)
  • 📚 Get company filings: You can get all the company's historical filings using company.get_filings()
  • 📈 Get company facts: You can get company facts using company.get_facts()
  • 💰 Company Financials: You can get company financials using company.financials
  • 🔍 Lookup Ticker by CUSIP: You can lookup a ticker by CUSIP
  • 📑 Dataset of SEC entities: You can get a dataset of SEC companies and persons
  • 📈 Fund Reports: Search for and get 13F-HR fund reports
  • 👤 Insider Transactions: Search for and get insider transactions

Getting started

Install using pip

pip install edgartools

Import and start using

fromedgarimport*# Tell the SEC who you areset_identity("Michael Mccallum mike.mccalum@indigo.com")
filings=get_filings()

Concepts

How do I find a filing?

Depends on what you know

A. I know the accession number

filing=find("0001065280-23-000273")

B. I know the company ticker or cik

filings=Company("NFLX").get_filings(form="10-Q").latest(1)

C. Show me a list of filings

filings=get_filings(form="10-Q")
filing=filings[0]

What can I do with a filing

You can view it in the terminal or open it in the browser, get the filing as html, xml or text, and download attachments. You can extract data from the filing into a data object.

What can I do with a company

You can get the company's filings, facts and financials.

How to use edgartools

TaskCode
Set your EDGAR identity in Linux/Macexport EDGAR_IDENTITY="First Last email@domain.com"
Set your EDGAR identity in Windowsset EDGAR_IDENTITY="First Last email@domain.com"
Set identity in Windows Powershell$env:EDGAR_IDENTITY="First Last email@domain.com"
Set identity in Pythonset_identity("First Last email@domain.com")
Importing the libraryfrom edgar import *

Working with filings

TaskCode
Get filings for the year to datefilings = get_filings()
Get only xbrl filingsfilings = get_filings(index="xbrl")
Get filings for a specific yearfilings = get_filings(2020)
Get filings for a specific quarterfilings = get_filings(2020, 1)
Get filings for multiple yearsfilings = get_filings([2020, 2021])
Get filigs for a range of yearsfilings = get_filings(year=range(2010, 2020)
Get filings for a specific formfilings = get_filings(form="10-K")
Get filings for a list of formsfilings = get_filings(form=["10-K", "10-Q"])
Show the next page of filingsfilings.next()
Show the previous page of filingsfilings.prev()
Get the first n filingsfilings.head(20)
Get the last n filingsfilings.tail(20)
Get the latest n filings by datefilings.latest(20)
Get a random sample of the filingsfilings.sample(20)
Filter filings on a datefilings = filings.filter(date="2020-01-01")
Filter filings between datesfilings.filter(date="2020-01-01:2020-03-01")
Filter filings before a datefilings.filter(date=":2020-03-01")
Filter filings after a datefilings.filter(date="2020-03-01:")
Get filings as a pandas dataframefilings.to_pandas()

Working with a filing

TaskCode
Get a single filingfiling = filings[3]
Get a filing by accession numberfiling = get_by_accession_number("0000320193-20-34576")
Get the filing homepagefiling.homepage
Open a filing in the browserfiling.open()
Open the filing homepage in the browserfiling.homepage.open()
View the filing in the terminalfiling.view()
Get the html of the filing documentfiling.html()
Get the XBRL of the filing documentfiling.xbrl()
Get the filing document as markdownfiling.markdown()
Get the full submission text of a filingfiling.text()
Get and parse the data object of a filingfiling.obj()
Get the filing attachmentsfiling.attachments
Get a single attachmentattachment = filing.attachments[0]
Open an attachment in the browserattachment.open()
Download an attachmentcontent = attachment.download()

Working with a company

TaskCode
Get a company by tickercompany = Company("AAPL")
Get a company by CIKcompany = Company("0000320193")
Get company factscompany.get_facts()
Get company facts as a pandas dataframecompany.get_facts().to_pandas()
Get company filingscompany.get_filings()
Get company filings by formcompany.get_filings(form="10-K")
Get a company filing by accession_numbercompany.get_filing(accession_number="0000320193-21-000139")
Get the company's financialscompany.financials
Get the company's balance sheetcompany.financials.balance_sheet
Get the company's income statementcompany.financials.income_statement
Get the company's cash flow statementcompany.financials.cash_flow_statement

Installation

pip install edgartools

Usage

Set your Edgar user identity

Before you can access the SEC Edgar API you need to set the identity that you will use to access Edgar. This is usually your name and email, or a company name and email.

Sample Company Name AdminContact@<sample company domain>.com

The user identity is sent in the User-Agent string and the Edgar API will refuse to respond to your request without it.

EdgarTools will look for an environment variable called EDGAR_IDENTITY and use that in each request. So, you need to set this environment variable before using it.

Setting EDGAR_IDENTITY in Linux/Mac

export EDGAR_IDENTITY="Michael Mccallum mcalum@gmail.com"

Setting EDGAR_IDENTITY in Windows Powershell

$Env:EDGAR_IDENTITY="Michael Mccallum mcalum@gmail.com"

Alternatively, you can call set_identity which does the same thing.

fromedgarimportset_identityset_identity("Michael Mccallum mcalum@gmail.com")

For more detail see https://www.sec.gov/os/accessing-edgar-data

Usage

Importing edgar

fromedgarimport*

Use the Filing API when you are not working with a specific company, but want to get a list of filings.

For details on how to use the Filing API see Using the Filing API

With the Company API you can find a company by ticker or CIK, and get the company's filings, facts and financials.

Company("AAPL")
.get_filings(form="10-Q")
.latest(1)
.obj()

expe

See Using the Company API

Viewing and downloading attachments

Every filing has a list of attachments. You can view the attachments using filing.attachments

# View the attachmentsfiling.attachments

Filing attachments

You can access each attachment using the bracket operator [] and the index of the attachment.

# Get the first attachmentattachment=filing.attachments[0]

Filing attachments

You can download the attachment using attachment.download(). This will download the attachment to string or bytes in memory.

Automatic parsing of filing data

Now the reason you may want to download attachments is to get information contained in data files. For example, 13F-HR filings have attached infotable.xml files containing data from the holding report for that filing.

Fortunately, the library handles this for you. If you call filing.obj() it will automatically download and parse the data files into a data object, for several different form types. Currently, the following forms are supported:

FormData ObjectDescription
10-KTenKAnnual report
10-QTenQQuarterly report
8-KEightKCurrent report
MA-IMunicipalAdvisorFormMunicipal advisor initial filing
Form 144Form144Notice of proposed sale of securities
C, C-U, C-AR, C-TRFormCForm C Crowdfunding Offering
DFormDForm D Offering
3,4,5OwnershipOwnership reports
13F-HRThirteenF13F Holdings Report
NPORT-PFundReportFund Report
EFFECTEffectNotice of Effectiveness
And other filing with XBRLFilingXbrl

For example, to get the data object for a 13F-HR filing you can do the following:

filings=get_filings(form="13F-HR")
filing=filings[0]
thirteenf=filing.obj()

Filing attachments

If you call obj() on a filing that does not have a data file, then it will return None.

Working with XBRL filings

Some filings are in XBRL (eXtensible Business Markup Language) format. These are mainly the newer filings, as the SEC has started requiring this for newer filings.

If a filing is in XBRL format then it opens up a lot more ways to get structured data about that specific filing and also about the company referred to in that filing.

The Filing class has an xbrl function that will download, parse and structure the filing's XBRL document if one exists. If it does not exist, then filing.xbrl() will return None.

The function filing.xbrl() returns a FilingXbrl instance, which wraps the data, and provides convenient ways of working with the xbrl data.

filing_xbrl=filing.xbrl()

Filing homapage

Financials

Some filings, notably 10-K and 10-Q filings contain financial statements in XBRL format. You can get the financials from the XBRL data using the Financials class.

fromedgar.financialsimportFinancialsfinancials=Financials.from_xbrl(filing.xbrl())
financials.balance_sheetfinancials.income_statementfinancials.cash_flow_statement

Or automatically through the Tenk and TenQ data objects.

Here is an example that gets the latest Apple financials

tenk=Company("AAPL").get_filings(form="10-K").latest(1).obj()
financials=tenk.financialsfinancials.balance_sheet

Balance Sheet

Get the financial data as a pandas dataframe

Each of the financial statements - BalanceSheet, IncomeStatement and CashFlowStatement - have a to_dataframe() method that will return the data as a pandas dataframe.

balance_sheet_df=financials.balance_sheet.to_dataframe()

Contributing

Contributions are welcome! We would love to hear your thoughts on how this library could be better at working with SEC Edgar.

Reporting Issues

We use GitHub issues to track public bugs. Report a bug by opening a new issue; it's that easy!

Making code changes

  • Fork the repo and create your branch from master.
  • If you've added code that should be tested, add tests.
  • If you've changed APIs, update the documentation.
  • Ensure the test suite passes.
  • Make sure your code lints.
  • Issue that pull request!

License

edgartools is distributed under the terms of the MIT license.

Contact

LinkedIn

Star History

Star History Chart

Subscribe to Polar

2 3 Subscribe on Polar 4

About

Python library for working with SEC Edgar

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages